stddef/src/org/lucidj/api/stddef/Aggregate.java
// Fetch and adapt an specific part for use
Fetch and adapt an specific part for use
Fetch and adapt an specific part for use
default <T> T adapt (Class<T> type)
    {
        if (type == null)
        {
            return (null);
        }
        else if (type.isAssignableFrom (this.getClass ()))
        {
            return (type.cast (this));
        }
        else
        {
            Object object;
            for (Object element: elements ())
            {
                if (element != this && (object = Aggregate.adapt (type, element)) != null)
                {
                    return (type.cast (object));
                }
            }
        }
        return (null);
    }
default < T > T adapt ( Class < T > type ) { if ( type == null ) { return ( null ) ; } else if ( type . isAssignableFrom ( this . getClass ( ) ) ) { return ( type . cast ( this ) ) ; } else { Object object ; for ( Object element : elements ( ) ) { if ( element != this && ( object = Aggregate . adapt ( type , element ) ) != null ) { return ( type . cast ( object ) ) ; } } } return ( null ) ; }
Fetch and adapt an specific part for use
Fetch and adapt an specific part for use