Class WrapperAdapterUtils
java.lang.Object
io.foldright.inspectablewrappers.utils.WrapperAdapterUtils
@DefaultAnnotationForParameters(edu.umd.cs.findbugs.annotations.NonNull.class)
public final class WrapperAdapterUtils
extends Object
Utility class for creating
WrapperAdapter instances
without writing boilerplate codes of creating new adapter classes.- Author:
- Jerry Lee (oldratlee at gmail dot com)
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> TcreateWrapperAdapter(Class<? super T> bizInterface, T underlying, T adaptee) Creates aWrapperAdapterinstance of the given biz interface type by the underlying(Wrapper.unwrap_()) and adaptee(WrapperAdapter.adaptee_()) instances.static <T> TcreateWrapperAdapter(Class<? super T> bizInterface, T underlying, T adaptee, Attachable<?, ?> attachable) Creates aWrapperAdapterinstance of the given biz interface type andAttachabletype by the underlying(Wrapper.unwrap_()), adaptee(WrapperAdapter.adaptee_()) and attachable instances.static <T> TcreateWrapperAdapter(Class<? super T> bizInterface, T underlying, T adaptee, Attachable<?, ?> attachable, Class<?>... tagInterfaces) Same ascreateWrapperAdapter(Class, Object, Object, Attachable), but the returnedWrapperAdapterinstance also implements the given tag interfaces.static <T> TcreateWrapperAdapter(Class<? super T> bizInterface, T underlying, T adaptee, Class<?>... tagInterfaces) Same ascreateWrapperAdapter(Class, Object, Object), but the returnedWrapperAdapterinstance also implements the given tag interfaces.
-
Method Details
-
createWrapperAdapter
@NonNull public static <T> T createWrapperAdapter(Class<? super T> bizInterface, T underlying, T adaptee) Creates aWrapperAdapterinstance of the given biz interface type by the underlying(Wrapper.unwrap_()) and adaptee(WrapperAdapter.adaptee_()) instances.- Type Parameters:
T- the type of instances that be wrapped- Parameters:
bizInterface- the class of instances that be wrappedunderlying- the underlying instance that be wrapped, more info seeWrapper.unwrap_()adaptee- the adapted/existed wrapper instance, more info seeWrapperAdapter.adaptee_()- Returns:
- the new
WrapperAdapterinstance - Throws:
IllegalArgumentException- ifbizInterfaceis not an interface, orbizInterfaceisWrapper/WrapperAdapter/Attachable, or underlying is not an instance ofbizInterface, or adaptee is not an instance ofbizInterface, or adaptee is an instance ofWrapperNullPointerException- if any argument is null- See Also:
-
createWrapperAdapter
@NonNull public static <T> T createWrapperAdapter(Class<? super T> bizInterface, T underlying, T adaptee, Attachable<?, ?> attachable) Creates aWrapperAdapterinstance of the given biz interface type andAttachabletype by the underlying(Wrapper.unwrap_()), adaptee(WrapperAdapter.adaptee_()) and attachable instances.- Type Parameters:
T- the type of instances that be wrapped- Parameters:
bizInterface- the class of instances that be wrappedunderlying- the underlying instance that be wrapped, more info seeWrapper.unwrap_()adaptee- the adapted/existed wrapper instance, more info seeWrapperAdapter.adaptee_()attachable- the attachable instance, more info seeAttachable- Returns:
- the new
WrapperAdapterinstance - Throws:
IllegalArgumentException- ifbizInterfaceis not an interface, orbizInterfaceisWrapper/WrapperAdapter/Attachable, or underlying is not an instance ofbizInterface, or adaptee is not an instance ofbizInterface, or adaptee is an instance ofWrapperNullPointerException- if any argument is null- See Also:
-
createWrapperAdapter
@NonNull public static <T> T createWrapperAdapter(Class<? super T> bizInterface, T underlying, T adaptee, Class<?>... tagInterfaces) Same ascreateWrapperAdapter(Class, Object, Object), but the returnedWrapperAdapterinstance also implements the given tag interfaces. -
createWrapperAdapter
@NonNull public static <T> T createWrapperAdapter(Class<? super T> bizInterface, T underlying, T adaptee, Attachable<?, ?> attachable, Class<?>... tagInterfaces) Same ascreateWrapperAdapter(Class, Object, Object, Attachable), but the returnedWrapperAdapterinstance also implements the given tag interfaces.
-