Package com.iizix
Interface IWrapper
public interface IWrapper
Helper interface used to verify if an instance of an interface is assignable to a class and also to cast it to the requested class without throwing an error.- Author:
- Freggle, Christopher Mindus
Method Summary
All Methods Instance Methods Default Methods Modifier and Type Method Description default boolean
isWrapperFor(java.lang.Class<?> iface)
Tests if this object instance is of the base- or subclass of theiface
class.default <T> T
unwrap(java.lang.Class<T> iface)
Returns the cast classiface
instance if possible, otherwise null.
Method Detail
unwrap
default <T> T unwrap(java.lang.Class<T> iface)
Returns the cast classiface
instance if possible, otherwise null.- Type Parameters:
T
- The class requested.- Parameters:
iface
- The class to cast to.- Returns:
- The class cast as requested by
iface
, otherwise null.
isWrapperFor
default boolean isWrapperFor(java.lang.Class<?> iface)
Tests if this object instance is of the base- or subclass of theiface
class. This method is typically used to identify an instance known as an instance of an interface, and the caller wishes to verify if it's really an implementation of a class that in turn implements or specifies the interfaceiface
.- Parameters:
iface
- The class to check.- Returns:
- true if the
iface
class is assignable from this instance class. - See Also:
isWrapperFor(java.lang.Class)