Class BuilderSwap<T,B>
java.lang.Object
org.apache.juneau.marshall.swap.spi.BuilderSwap<T,B>
- Type Parameters:
T- The bean class.B- The builder class.
Specialized transform for builder classes.
See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBuilderSwap(Class<T> objectClass, Class<B> builderClass, Constructor<T> objectConstructor, Constructor<B> builderConstructor, MethodInfo createBuilderMethod, MethodInfo createObjectMethod) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionbuild(MarshallingSession session, B builder, ClassMeta<?> hint) Creates a new object from the specified builder.create(MarshallingSession 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(MarshallingContext bc, Class<?> objectClass, Visibility cVis, Visibility mVis) Creates a BuilderSwap from the specified object class if it has one.The builder class.ClassMeta<?>getBuilderClassMeta(MarshallingSession session) Returns theClassMetaof the transformed class type.The object class.
-
Constructor Details
-
BuilderSwap
protected 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. Can benull if the object is created viacreateObjectMethodinstead.builderConstructor- The builder no-arg constructor. Can benull if the builder is created viacreateBuilderMethodinstead.createBuilderMethod- The static create() method on the object class. Can benull if the builder is created viabuilderConstructorinstead.createObjectMethod- The build() method on the builder class. Can benull if the object is created viaobjectConstructorinstead.
-
-
Method Details
-
findSwapFromBuilderClass
public 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. Must not benull .cVis- Minimum constructor visibility.mVis- Minimum method visibility.- Returns:
- A new swap instance, or
null if class wasn't a builder class.
-
findSwapFromObjectClass
public static BuilderSwap<?,?> findSwapFromObjectClass(MarshallingContext 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. Must not benull .objectClass- The object class to check. Must not benull .cVis- Minimum constructor visibility.mVis- Minimum method visibility.- Returns:
- A new swap instance, or
null if class didn't have a builder class.
-
build
Creates 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.
-
create
Creates 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.
-
getBuilderClass
The builder class.- Returns:
- The builder class.
-
getBuilderClassMeta
Returns 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. Must not benull on the first (uncached) call.- Returns:
- The
ClassMetaof the transformed class type.
-
getObjectClass
The object class.- Returns:
- The object class.
-