Package org.apache.juneau.swap
Class BuilderSwap<T,B> 
java.lang.Object
org.apache.juneau.swap.BuilderSwap<T,B> 
- Type Parameters:
- T- The bean class.
- B- The builder class.
Specialized transform for builder classes.
 
See Also:
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedBuilderSwap(Class<T> objectClass, Class<B> builderClass, Constructor<T> objectConstructor, Constructor<B> builderConstructor, MethodInfo createBuilderMethod, MethodInfo createObjectMethod) Constructor.
- 
Method SummaryModifier and TypeMethodDescriptionbuild(BeanSession session, B builder, ClassMeta<?> hint) Creates a new object from the specified builder.create(BeanSession session, ClassMeta<?> hint) Creates a new builder object.static BuilderSwap<?,?> findSwapFromBuilderClass(Class<?> builderClass, Visibility cVis, Visibility mVis) Creates a BuilderSwap from the specified builder class if it qualifies as one.static BuilderSwap<?,?> findSwapFromObjectClass(BeanContext bc, Class<?> objectClass, Visibility cVis, Visibility mVis) Creates a BuilderSwap from the specified object class if it has one.The builder class.ClassMeta<?>getBuilderClassMeta(BeanSession session) Returns theClassMetaof the transformed class type.The object class.
- 
Constructor Details- 
BuilderSwapprotected BuilderSwap(Class<T> objectClass, Class<B> builderClass, Constructor<T> objectConstructor, Constructor<B> builderConstructor, MethodInfo createBuilderMethod, MethodInfo createObjectMethod) Constructor.- Parameters:
- objectClass- The object class created by the builder class.
- builderClass- The builder class.
- objectConstructor- The object constructor that takes in a builder as a parameter.
- builderConstructor- The builder no-arg constructor.
- createBuilderMethod- The static create() method on the object class.
- createObjectMethod- The build() method on the builder class.
 
 
- 
- 
Method Details- 
getObjectClassThe object class.- Returns:
- The object class.
 
- 
getBuilderClassThe builder class.- Returns:
- The builder class.
 
- 
getBuilderClassMetaReturns theClassMetaof the transformed class type.This value is cached for quick lookup. - Parameters:
- session- The bean context to use to get the class meta. This is always going to be the same bean context that created this swap.
- Returns:
- The ClassMetaof the transformed class type.
 
- 
createCreates a new builder object.- Parameters:
- session- The current bean session.
- hint- A hint about the class type.
- Returns:
- A new object.
- Throws:
- ExecutableException- Exception occurred on invoked constructor/method/field.
 
- 
buildCreates a new object from the specified builder.- Parameters:
- session- The current bean session.
- builder- The object builder.
- hint- A hint about the class type.
- Returns:
- A new object.
- Throws:
- ExecutableException- Exception occurred on invoked constructor/method/field.
 
- 
findSwapFromBuilderClasspublic static BuilderSwap<?,?> findSwapFromBuilderClass(Class<?> builderClass, Visibility cVis, Visibility mVis) Creates a BuilderSwap from the specified builder class if it qualifies as one.- Parameters:
- builderClass- The potential builder class.
- cVis- Minimum constructor visibility.
- mVis- Minimum method visibility.
- Returns:
- A new swap instance, or null if class wasn't a builder class.
 
- 
findSwapFromObjectClasspublic static BuilderSwap<?,?> findSwapFromObjectClass(BeanContext bc, Class<?> objectClass, Visibility cVis, Visibility mVis) Creates a BuilderSwap from the specified object class if it has one.- Parameters:
- bc- The bean context to use to look up annotations.
- objectClass- The object class to check.
- cVis- Minimum constructor visibility.
- mVis- Minimum method visibility.
- Returns:
- A new swap instance, or null if class didn't have a builder class.
 
 
-