Class SetPropertyClass
- java.lang.Object
-
- org.apache.tomcat.util.xreflection.SetPropertyClass
-
- All Implemented Interfaces:
java.lang.Comparable<SetPropertyClass>
public final class SetPropertyClass extends java.lang.Object implements java.lang.Comparable<SetPropertyClass>
Represents a class in the reflection-based property setter/getter code generation system. Tracks properties, parent/child class relationships, and generates optimized reflection-free property access code.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddProperty(org.apache.tomcat.util.xreflection.ReflectionProperty property)Add a property to this class.intcompareTo(SetPropertyClass o)booleanequals(java.lang.Object o)java.lang.StringgenerateGetPropertyForMethod()Generate a complete getProperty method for this class with switch-case statements for each known property.java.lang.StringgenerateGetPropertyMethod(org.apache.tomcat.util.xreflection.ReflectionProperty property)Generate a Java code snippet to get the given property value.java.lang.StringgenerateInvocationGetForPropertyCaseStatement(int level)Generate a switch case statement that invokes the getProperty method for this class.java.lang.StringgenerateInvocationSetForPropertyCaseStatement(int level)Generate a switch case statement that invokes the setProperty method for this class.java.lang.StringgenerateParentGetPropertyForMethodInvocation()Generate a method invocation string for the getProperty method of this class, suitable for use from a parent class.java.lang.StringgenerateParentSetPropertyForMethodInvocation()Generate a method invocation string for the setProperty method of this class, suitable for use from a parent class.java.lang.StringgenerateSetPropertyForMethod()Generate a complete setProperty method for this class with switch-case statements for each known property.java.lang.StringgenerateSetPropertyMethod(org.apache.tomcat.util.xreflection.ReflectionProperty property)Generate a Java code snippet to set the given property value.java.lang.StringgeneratesGetPropertyForMethodHeader()Generate the method header for the getProperty method for this class.java.lang.StringgeneratesSetPropertyForMethodHeader()Generate the method header for the setProperty method for this class.java.util.Set<SetPropertyClass>getChildren()Returns the set of child classes registered under this class.java.lang.Class<?>getClazz()Returns theClassrepresented by this instance.java.lang.reflect.MethodgetGenericGetPropertyMethod()Returns the generic getProperty method if one exists.java.lang.reflect.MethodgetGenericSetPropertyMethod()Returns the generic setProperty method if one exists.SetPropertyClassgetParent()Returns the parent class.java.util.Set<org.apache.tomcat.util.xreflection.ReflectionProperty>getProperties()Returns the set of reflection properties for this class.inthashCode()java.lang.StringtoString()
-
-
-
Method Detail
-
getChildren
public java.util.Set<SetPropertyClass> getChildren()
Returns the set of child classes registered under this class.- Returns:
- the child classes
-
getProperties
public java.util.Set<org.apache.tomcat.util.xreflection.ReflectionProperty> getProperties()
Returns the set of reflection properties for this class.- Returns:
- the reflection properties
-
getGenericSetPropertyMethod
public java.lang.reflect.Method getGenericSetPropertyMethod()
Returns the generic setProperty method if one exists.- Returns:
- the generic setProperty method, or
null
-
getGenericGetPropertyMethod
public java.lang.reflect.Method getGenericGetPropertyMethod()
Returns the generic getProperty method if one exists.- Returns:
- the generic getProperty method, or
null
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
getParent
public SetPropertyClass getParent()
Returns the parent class.- Returns:
- the parent class, or
nullif this is the root class
-
getClazz
public java.lang.Class<?> getClazz()
Returns theClassrepresented by this instance.- Returns:
- the represented class
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
addProperty
public void addProperty(org.apache.tomcat.util.xreflection.ReflectionProperty property)
Add a property to this class.- Parameters:
property- the property to add
-
generateSetPropertyMethod
public java.lang.String generateSetPropertyMethod(org.apache.tomcat.util.xreflection.ReflectionProperty property)
Generate a Java code snippet to set the given property value.- Parameters:
property- the property to generate code for- Returns:
- the generated code snippet, or
nullif no setter is available
-
generateGetPropertyMethod
public java.lang.String generateGetPropertyMethod(org.apache.tomcat.util.xreflection.ReflectionProperty property)
Generate a Java code snippet to get the given property value.- Parameters:
property- the property to generate code for- Returns:
- the generated code snippet, or
nullif no getter is available
-
generateSetPropertyForMethod
public java.lang.String generateSetPropertyForMethod()
Generate a complete setProperty method for this class with switch-case statements for each known property.- Returns:
- the generated Java source code
-
generateInvocationSetForPropertyCaseStatement
public java.lang.String generateInvocationSetForPropertyCaseStatement(int level)
Generate a switch case statement that invokes the setProperty method for this class.- Parameters:
level- the indentation level- Returns:
- the generated Java source code
-
generateParentSetPropertyForMethodInvocation
public java.lang.String generateParentSetPropertyForMethodInvocation()
Generate a method invocation string for the setProperty method of this class, suitable for use from a parent class.- Returns:
- the generated method invocation string
-
generatesSetPropertyForMethodHeader
public java.lang.String generatesSetPropertyForMethodHeader()
Generate the method header for the setProperty method for this class.- Returns:
- the generated method header string
-
generateInvocationGetForPropertyCaseStatement
public java.lang.String generateInvocationGetForPropertyCaseStatement(int level)
Generate a switch case statement that invokes the getProperty method for this class.- Parameters:
level- the indentation level- Returns:
- the generated Java source code
-
generateParentGetPropertyForMethodInvocation
public java.lang.String generateParentGetPropertyForMethodInvocation()
Generate a method invocation string for the getProperty method of this class, suitable for use from a parent class.- Returns:
- the generated method invocation string
-
generatesGetPropertyForMethodHeader
public java.lang.String generatesGetPropertyForMethodHeader()
Generate the method header for the getProperty method for this class.- Returns:
- the generated method header string
-
generateGetPropertyForMethod
public java.lang.String generateGetPropertyForMethod()
Generate a complete getProperty method for this class with switch-case statements for each known property.- Returns:
- the generated Java source code
-
compareTo
public int compareTo(SetPropertyClass o)
- Specified by:
compareToin interfacejava.lang.Comparable<SetPropertyClass>
-
-