Class Adapters

    • Constructor Detail

      • Adapters

        public Adapters()
    • Method Detail

      • adapt

        public static <T> T adapt​(Object sourceObject,
                                  Class<T> adapter,
                                  boolean allowActivation)
        If it is possible to adapt the given object to the given type, this returns the adapter. Performs the following checks:
        1. Returns sourceObject if it is an instance of the adapter type.
        2. If sourceObject implements IAdaptable, it is queried for adapters.
        3. Finally, the adapter manager is consulted for adapters
        Otherwise returns null.
        Type Parameters:
        T - class type to adapt to
        Parameters:
        sourceObject - object to adapt, can be null
        adapter - type to adapt to
        allowActivation - if true, plug-ins may be activated if necessary to provide the requested adapter. if false, the method will return null if an adapter cannot be provided from activated plug-ins.
        Returns:
        a representation of sourceObject that is assignable to the adapter type, or null if no such representation exists
      • adapt

        public static <T> T adapt​(Object sourceObject,
                                  Class<T> adapter)
        If it is possible to adapt the given object to the given type, this returns the adapter.

        Convenience method for calling adapt(Object, Class, true).

        See adapt(Object, Class, boolean).

        Type Parameters:
        T - class type to adapt to
        Parameters:
        sourceObject - object to adapt, can be null
        adapter - type to adapt to
        Returns:
        a representation of sourceObject that is assignable to the adapter type, or null if no such representation exists