/** * Create a new AND specification. * * @param left first operand * @param right second operand * @param optionalRight optional operands * * @return a new AND specification */ @SafeVarargs public static AndSpecification and( Specification<Composite> left, Specification<Composite> right, Specification<Composite>... optionalRight ) { return new AndSpecification( prepend( left, prepend( right, Arrays.asList( optionalRight ) ) ) ); }
@Override @SuppressWarnings( {"raw", "unchecked"} ) public Iterable<Class<?>> map( Type type ) { if( type == null ) { return empty(); } if( type.equals( Object.class ) ) { Class<?> aClass = (Class<?>) type; return cast( iterable( aClass ) ); } else { type = RAW_CLASS.map( type ); Class superclass = ( (Class) type ).getSuperclass(); return prepend( (Class<?>) type, map( superclass ) ); } } };
@Override public Iterable<Type> map( Type type ) { Class clazz = RAW_CLASS.map( type ); if( clazz.isInterface() ) { Iterable<Type> genericInterfaces = iterable( clazz.getGenericInterfaces() ); Iterable<Type> flattenIterables = flattenIterables( Iterables.map( INTERFACES_OF, genericInterfaces ) ); return prepend( type, flattenIterables ); } else { if( type.equals( Object.class ) ) { return iterable( clazz.getGenericInterfaces() ); } else { return flatten( flattenIterables( Iterables.map( INTERFACES_OF, iterable( clazz.getGenericInterfaces() ) ) ), INTERFACES_OF.map( RAW_CLASS.map( type ).getSuperclass() ) ); } } } };
@Override public Iterable<Type> map( Type type ) { Class clazz = RAW_CLASS.map( type ); if( clazz.isInterface() ) { Iterable<Type> genericInterfaces = iterable( clazz.getGenericInterfaces() ); Iterable<Type> flattenIterables = flattenIterables( Iterables.map( INTERFACES_OF, genericInterfaces ) ); return prepend( clazz, flattenIterables ); } else { return flatten( CLASS_HIERARCHY.map( type ), flattenIterables( Iterables.map( INTERFACES_OF, CLASS_HIERARCHY.map( type ) ) ) ); } } };