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

    Modifier and Type
    Method
    Description
    default boolean
    isWrapperFor(Class<?> iface)
    Tests if this object instance is of the base- or subclass of the iface class.
    default <T> T
    unwrap(Class<T> iface)
    Returns the cast class iface instance if possible, otherwise null.
  • Method Details

    • unwrap

      default <T> T unwrap(Class<T> iface)
      Returns the cast class iface 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(Class<?> iface)
      Tests if this object instance is of the base- or subclass of the iface 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 interface iface.
      Parameters:
      iface - The class to check.
      Returns:
      true if the iface class is assignable from this instance class.
      See Also: