Class Refactory
- java.lang.Object
-
- org.jboss.forge.roaster.model.util.Refactory
-
public class Refactory extends java.lang.ObjectUtility refactory methods forJavaClassSourceobjects
-
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static voidcreateEquals(JavaClassSource clazz, FieldSource<?>... fields)Create an equals implementation for the given class and fields.static voidcreateGetterAndSetter(JavaClassSource clazz, FieldSource<JavaClassSource> field)Generates a getXXX and setXXX method for the supplied fieldstatic voidcreateHashCode(JavaClassSource clazz, FieldSource<?>... fields)Create a hashCode implementation for the given class and fields.static voidcreateHashCodeAndEquals(JavaClassSource clazz)Deprecated.UsecreateHashCodeAndEquals(JavaClassSource, FieldSource...)instead, since this method relies on the existence of the id fieldstatic voidcreateHashCodeAndEquals(JavaClassSource clazz, FieldSource<?>... fields)Create a hashCode and equals implementation for the given class and fields.static voidcreateToStringFromFields(JavaClassSource clazz)Create a toString implementation using all the fields in this classstatic voidcreateToStringFromFields(JavaClassSource clazz, java.util.List<FieldSource<JavaClassSource>> fields)Create a toString implementation using the supplied fieldsstatic voidcreateToStringFromFields(JavaClassSource clazz, FieldSource<JavaClassSource>... fields)Create a toString implementation using the supplied fields
-
-
-
Method Detail
-
createGetterAndSetter
public static void createGetterAndSetter(JavaClassSource clazz, FieldSource<JavaClassSource> field)
Generates a getXXX and setXXX method for the supplied field- Parameters:
clazz- the java source class where to generated the methodsfield- the fields for which the methods should be generated
-
createHashCodeAndEquals
@Deprecated public static void createHashCodeAndEquals(JavaClassSource clazz)
Deprecated.UsecreateHashCodeAndEquals(JavaClassSource, FieldSource...)instead, since this method relies on the existence of the id fieldCreate a hashCode and equals implementation for the given class and fields- Parameters:
clazz- the class where to generate the methods
-
createHashCodeAndEquals
public static void createHashCodeAndEquals(JavaClassSource clazz, FieldSource<?>... fields)
Create a hashCode and equals implementation for the given class and fields. Callers must verify that the types of the fields override the default identity based equals and hashcode implementations. No warnings are issued in an event where the field type uses the implementation of java.lang.Object. This method ignores static fields for generating the equals and hashCode methods, since they are ideally not meant to be used in these cases. Although transient fields could also be ignored, they are not since there is no mechanism to convey warnings (not errors) in this case.- Parameters:
clazz- class to be changedfields- fields to be used in the equals/hashCode methods
-
createEquals
public static void createEquals(JavaClassSource clazz, FieldSource<?>... fields)
Create an equals implementation for the given class and fields. Callers must verify that the types of the fields override the default identity based equals implementation. No warnings are issued in an event where the field type uses the implementation of java.lang.Object. This method ignores static fields for generating the equals method, since they are ideally not meant to be used in these cases. Although transient fields could also be ignored, they are not since there is no mechanism to convey warnings (not errors) in this case.- Parameters:
clazz- class to be changedfields- fields to be used in the equals/hashCode methods
-
createHashCode
public static void createHashCode(JavaClassSource clazz, FieldSource<?>... fields)
Create a hashCode implementation for the given class and fields. Callers must verify that the types of the fields override the default identity based hashcode implementation. No warnings are issued in an event where the field type uses the implementation of java.lang.Object. This method ignores static fields for generating the equals method, since they are ideally not meant to be used in these cases. Although transient fields could also be ignored, they are not since there is no mechanism to convey warnings (not errors) in this case.- Parameters:
clazz- class to be changedfields- fields to be used in the equals/hashCode methods
-
createToStringFromFields
public static void createToStringFromFields(JavaClassSource clazz)
Create a toString implementation using all the fields in this class- Parameters:
clazz- the class where the method should be generated
-
createToStringFromFields
public static void createToStringFromFields(JavaClassSource clazz, FieldSource<JavaClassSource>... fields)
Create a toString implementation using the supplied fields- Parameters:
clazz- the class where the method should be generatedfields- the fields which are used for this method
-
createToStringFromFields
public static void createToStringFromFields(JavaClassSource clazz, java.util.List<FieldSource<JavaClassSource>> fields)
Create a toString implementation using the supplied fields- Parameters:
clazz- the class where the method should be generatedfields- the fields which are used for this method
-
-