This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 10.1.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/10.1.x by this push: new 103a29a1c1 Disable default formatting for readability 103a29a1c1 is described below commit 103a29a1c176966bb6d473b53164060a9d47aad1 Author: Mark Thomas <ma...@apache.org> AuthorDate: Fri Aug 29 11:27:33 2025 +0100 Disable default formatting for readability --- .../xreflection/ReflectionLessCodeGenerator.java | 34 ++++++------ .../tomcat/util/xreflection/SetPropertyClass.java | 60 ++++++++++++---------- 2 files changed, 51 insertions(+), 43 deletions(-) diff --git a/java/org/apache/tomcat/util/xreflection/ReflectionLessCodeGenerator.java b/java/org/apache/tomcat/util/xreflection/ReflectionLessCodeGenerator.java index ac83673cb3..f859fb77ba 100644 --- a/java/org/apache/tomcat/util/xreflection/ReflectionLessCodeGenerator.java +++ b/java/org/apache/tomcat/util/xreflection/ReflectionLessCodeGenerator.java @@ -39,7 +39,8 @@ final class ReflectionLessCodeGenerator { String packageName, Set<SetPropertyClass> baseClasses ) throws IOException { - //begin - class + //@formatter:off + // begin - class StringBuilder code = new StringBuilder(AL20_HEADER) .append("package ") .append(packageName) @@ -52,7 +53,7 @@ final class ReflectionLessCodeGenerator { .append(System.lineSeparator()) .append(System.lineSeparator()); - //begin - isEnabled method + // begin - isEnabled method code.append(getIndent(1)) .append("static boolean isEnabled() {") .append(System.lineSeparator()) @@ -64,9 +65,9 @@ final class ReflectionLessCodeGenerator { .append(System.lineSeparator()) .append(System.lineSeparator()) ; - //end - isEnabled method + // end - isEnabled method - //begin - getInetAddress method + // begin - getInetAddress method code.append(getIndent(1)) .append("private static java.net.InetAddress getInetAddress(String value) {") .append(System.lineSeparator()) @@ -84,9 +85,9 @@ final class ReflectionLessCodeGenerator { .append(System.lineSeparator()) .append(System.lineSeparator()) ; - //end - getInetAddress method + // end - getInetAddress method - //begin - getPropertyInternal method + // begin - getPropertyInternal method code.append(getIndent(1)) .append("static Object getPropertyInternal(Object ") .append(SetPropertyClass.OBJECT_VAR_NAME) @@ -107,7 +108,7 @@ final class ReflectionLessCodeGenerator { .append("switch (checkThisClass.getName()) {") .append(System.lineSeparator()); - //generate case statements for getPropertyInternal + // generate case statements for getPropertyInternal generateCaseStatementsForGetPropertyInternal(baseClasses, code); @@ -127,13 +128,13 @@ final class ReflectionLessCodeGenerator { .append(getIndent(1)) .append('}') .append(System.lineSeparator()); - //end - getPropertyInternal method + // end - getPropertyInternal method - //begin - getPropertyForXXX methods + // begin - getPropertyForXXX methods generateGetPropertyForMethods(baseClasses, code); - //end - getPropertyForXXX methods + // end - getPropertyForXXX methods - //begin - setPropertyInternal method + // begin - setPropertyInternal method code.append(getIndent(1)) .append("static boolean setPropertyInternal(Object ") .append(SetPropertyClass.OBJECT_VAR_NAME) @@ -155,7 +156,7 @@ final class ReflectionLessCodeGenerator { .append("switch (checkThisClass.getName()) {") .append(System.lineSeparator()); - //generate case statements for setPropertyInternal + // generate case statements for setPropertyInternal generateCaseStatementsForSetPropertyInternal(baseClasses, code); @@ -175,15 +176,16 @@ final class ReflectionLessCodeGenerator { .append(getIndent(1)) .append('}') .append(System.lineSeparator()); - //end - setPropertyInternal method + // end - setPropertyInternal method - //begin - setPropertyForXXX methods + // begin - setPropertyForXXX methods generateSetPropertyForMethods(baseClasses, code); - //end - setPropertyForXXX methods + // end - setPropertyForXXX methods code.append('}') .append(System.lineSeparator()); - //end - class + // end - class + //@formatter:on File destination = new File(directory, className+".java"); try (BufferedWriter writer = new BufferedWriter(new FileWriter(destination, false))) { writer.write(code.toString()); diff --git a/java/org/apache/tomcat/util/xreflection/SetPropertyClass.java b/java/org/apache/tomcat/util/xreflection/SetPropertyClass.java index 396b09d904..6180946d6f 100644 --- a/java/org/apache/tomcat/util/xreflection/SetPropertyClass.java +++ b/java/org/apache/tomcat/util/xreflection/SetPropertyClass.java @@ -159,6 +159,7 @@ public final class SetPropertyClass implements Comparable<SetPropertyClass> { } public String generateSetPropertyForMethod() { + //@formatter:off StringBuilder code = new StringBuilder(ReflectionLessCodeGenerator.getIndent(1)) .append(generatesSetPropertyForMethodHeader()) .append(System.lineSeparator()) @@ -168,7 +169,7 @@ public final class SetPropertyClass implements Comparable<SetPropertyClass> { .append(") {") .append(System.lineSeparator()); - //case statements for each property + // case statements for each property for (ReflectionProperty property : getProperties()) { String invocation = generateSetPropertyMethod(property); if (invocation != null) { @@ -183,25 +184,22 @@ public final class SetPropertyClass implements Comparable<SetPropertyClass> { .append(System.lineSeparator()) .append(ReflectionLessCodeGenerator.getIndent(4)) .append("return true;") - .append(System.lineSeparator()) - ; + .append(System.lineSeparator()); } else { code.append(ReflectionLessCodeGenerator.getIndent(3)).append("//no set") - .append(IntrospectionUtils.capitalize(property.getPropertyName())).append(" method found on this class") - .append(System.lineSeparator()) - ; + .append(IntrospectionUtils.capitalize( + property.getPropertyName())).append(" method found on this class") + .append(System.lineSeparator()); } } - - - //end switch statement + // end switch statement code.append(ReflectionLessCodeGenerator.getIndent(2)) .append('}') .append(System.lineSeparator()); - //we have a generic setProperty(String, String) method, invoke it + // we have a generic setProperty(String, String) method, invoke it if (getGenericSetPropertyMethod() != null) { ReflectionProperty p = new ReflectionProperty( clazz.getName(), @@ -226,7 +224,7 @@ public final class SetPropertyClass implements Comparable<SetPropertyClass> { .append(System.lineSeparator()); } - //invoke parent or return false + // invoke parent or return false code.append(ReflectionLessCodeGenerator.getIndent(2)) .append("return ") .append(getSetPropertyForExitStatement()) @@ -235,6 +233,7 @@ public final class SetPropertyClass implements Comparable<SetPropertyClass> { .append('}'); return code.toString(); + //@formatter:on } private String getSetPropertyForExitStatement() { @@ -247,6 +246,7 @@ public final class SetPropertyClass implements Comparable<SetPropertyClass> { } public String generateInvocationSetForPropertyCaseStatement(int level) { + //@formatter:off StringBuilder code = new StringBuilder(ReflectionLessCodeGenerator.getIndent(level)) .append("case \"") .append(getClazz().getName()) @@ -257,6 +257,7 @@ public final class SetPropertyClass implements Comparable<SetPropertyClass> { .append(generateParentSetPropertyForMethodInvocation()) .append(System.lineSeparator()); return code.toString(); + //@formatter:on } public String generateParentSetPropertyForMethodInvocation() { @@ -265,8 +266,9 @@ public final class SetPropertyClass implements Comparable<SetPropertyClass> { for (String s : classParts) { methodInvocation.append(IntrospectionUtils.capitalize(s)); } + //@formatter:off methodInvocation.append('(') - .append(OBJECT_VAR_NAME) + .append(OBJECT_VAR_NAME) .append(", ") .append(NAME_VAR_NAME) .append(", ") @@ -275,6 +277,7 @@ public final class SetPropertyClass implements Comparable<SetPropertyClass> { .append(SETP_VAR_NAME) .append(");"); return methodInvocation.toString(); + //@formatter:on } public String generatesSetPropertyForMethodHeader() { @@ -283,6 +286,7 @@ public final class SetPropertyClass implements Comparable<SetPropertyClass> { for (String s : classParts) { methodInvocation.append(IntrospectionUtils.capitalize(s)); } + //@formatter:off methodInvocation.append("(Object ") .append(OBJECT_VAR_NAME) .append(", String ") @@ -293,9 +297,11 @@ public final class SetPropertyClass implements Comparable<SetPropertyClass> { .append(SETP_VAR_NAME) .append(") {"); return methodInvocation.toString(); + //@formatter:on } public String generateInvocationGetForPropertyCaseStatement(int level) { + //@formatter:off StringBuilder code = new StringBuilder(ReflectionLessCodeGenerator.getIndent(level)) .append("case \"") .append(getClazz().getName()) @@ -307,9 +313,9 @@ public final class SetPropertyClass implements Comparable<SetPropertyClass> { .append(System.lineSeparator()) .append(ReflectionLessCodeGenerator.getIndent(level+1)) .append("break;") - .append(System.lineSeparator()) - ; + .append(System.lineSeparator()); return code.toString(); + //@formatter:on } public String generateParentGetPropertyForMethodInvocation() { @@ -318,12 +324,14 @@ public final class SetPropertyClass implements Comparable<SetPropertyClass> { for (String s : classParts) { methodInvocation.append(IntrospectionUtils.capitalize(s)); } + //@formatter:off methodInvocation.append('(') .append(OBJECT_VAR_NAME) .append(", ") .append(NAME_VAR_NAME) .append(");"); return methodInvocation.toString(); + //@formatter:on } public String generatesGetPropertyForMethodHeader() { @@ -332,12 +340,14 @@ public final class SetPropertyClass implements Comparable<SetPropertyClass> { for (String s : classParts) { methodInvocation.append(IntrospectionUtils.capitalize(s)); } + //@formatter:off methodInvocation.append("(Object ") .append(OBJECT_VAR_NAME) .append(", String ") .append(NAME_VAR_NAME) .append(") {"); return methodInvocation.toString(); + //@formatter:on } private String getGetPropertyForExitStatement() { @@ -349,6 +359,7 @@ public final class SetPropertyClass implements Comparable<SetPropertyClass> { public String generateGetPropertyForMethod() { + //@formatter:off StringBuilder code = new StringBuilder(ReflectionLessCodeGenerator.getIndent(1)) .append(generatesGetPropertyForMethodHeader()) .append(System.lineSeparator()) @@ -361,7 +372,7 @@ public final class SetPropertyClass implements Comparable<SetPropertyClass> { .append(") {") .append(System.lineSeparator()); - //case statements for each property + // case statements for each property for (ReflectionProperty property : getProperties()) { String invocation = generateGetPropertyMethod(property); if (invocation != null) { @@ -376,23 +387,20 @@ public final class SetPropertyClass implements Comparable<SetPropertyClass> { .append(System.lineSeparator()) .append(ReflectionLessCodeGenerator.getIndent(4)) .append("break;") - .append(System.lineSeparator()) - ; - + .append(System.lineSeparator()); } else { code.append(ReflectionLessCodeGenerator.getIndent(3)).append("//no get") .append(IntrospectionUtils.capitalize(property.getPropertyName())).append(" method found on this class") - .append(System.lineSeparator()) - ; + .append(System.lineSeparator()); } } - //end switch statement + // end switch statement code.append(ReflectionLessCodeGenerator.getIndent(2)) .append('}') .append(System.lineSeparator()); - //invoke parent or return null + // invoke parent or return null code.append(ReflectionLessCodeGenerator.getIndent(2)) .append("if (result == null) {") .append(System.lineSeparator()) @@ -402,10 +410,9 @@ public final class SetPropertyClass implements Comparable<SetPropertyClass> { .append(System.lineSeparator()) .append(ReflectionLessCodeGenerator.getIndent(2)) .append('}') - .append(System.lineSeparator()) - ; + .append(System.lineSeparator()); - //we have a generic getProperty(String, String) method, invoke it + // we have a generic getProperty(String, String) method, invoke it if (getGenericGetPropertyMethod() != null) { ReflectionProperty p = new ReflectionProperty( clazz.getName(), @@ -431,9 +438,8 @@ public final class SetPropertyClass implements Comparable<SetPropertyClass> { .append('}') .append(System.lineSeparator()); - - return code.toString(); + //@formatter:on } @Override --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org