public static <T extends HasTypes> Collector<T, ?, List<T>> matchingTypes( T hasTypes ) { return hasTypesToListCollector( hasTypes, new HasAssignableFromType<>( hasTypes ) ); }
@Test public void hasAssignableTypePredicate() { assertTrue( new HasAssignableFromType<>( Number.class ) .test( ValueType.of( String.class, Integer.class ) ) ); assertFalse( new HasAssignableFromType<>( Integer.class ) .test( ValueType.of( Integer.class ) ) ); assertFalse( new HasAssignableFromType<>( String.class ) .test( ValueType.of( LocalDate.class, Integer.class ) ) ); }
/** * Collect a single matching HasTypes. * * TODO Detail * * @param type type to match * @param <T> type of HasTypes * @return an optional best matching HasTypes */ public static <T extends HasTypes> Collector<T, ?, Optional<T>> matchingType( Type type ) { return typeFindFirstCollector( type, new HasAssignableFromType<>( type ) ); }
public static <T extends HasTypes> Collector<T, ?, List<T>> matchingTypes( T hasTypes ) { return hasTypesToListCollector( hasTypes, new HasAssignableFromType<>( hasTypes ) ); }
/** * Collect a single matching HasTypes. * * TODO Detail * * @param type type to match * @param <T> type of HasTypes * @return an optional best matching HasTypes */ public static <T extends HasTypes> Collector<T, ?, Optional<T>> matchingType( Type type ) { return typeFindFirstCollector( type, new HasAssignableFromType<>( type ) ); }
/** * Collect all matching HasTypes. * * First the ones with at least on equal type. * Then the ones with at least one type assignable from {@literal type}. * * @param type type to match * @param <T> type of HasTypes * @return an optional best matching HasTypes */ public static <T extends HasTypes> Collector<T, ?, List<T>> matchingTypes( Type type ) { return typeToListCollector( type, new HasAssignableFromType<>( type ) ); }
/** * Collect all matching HasTypes. * * First the ones with at least on equal type. * Then the ones with at least one type assignable from {@literal type}. * * @param type type to match * @param <T> type of HasTypes * @return an optional best matching HasTypes */ public static <T extends HasTypes> Collector<T, ?, List<T>> matchingTypes( Type type ) { return typeToListCollector( type, new HasAssignableFromType<>( type ) ); }
public static <T extends HasTypes> Collector<T, ?, Optional<T>> matchingType( T hasTypes ) { return hasTypesFindFirstCollector( hasTypes, new HasAssignableFromType<>( hasTypes ) ); }
public static <T extends HasTypes> Collector<T, ?, Optional<T>> matchingType( T hasTypes ) { return hasTypesFindFirstCollector( hasTypes, new HasAssignableFromType<>( hasTypes ) ); }
public HasEqualOrAssignableFromType( Type type ) { composedPredicate = new HasEqualType<T>( type ).or( new HasAssignableFromType<>( type ) ); }
public HasEqualOrAssignableFromType( T hasTypes ) { composedPredicate = new HasEqualType<>( hasTypes ).or( new HasAssignableFromType<>( hasTypes ) ); }
public HasEqualOrAssignableFromType( Type type ) { composedPredicate = new HasEqualType<T>( type ).or( new HasAssignableFromType<>( type ) ); }
public HasEqualOrAssignableFromType( T hasTypes ) { composedPredicate = new HasEqualType<>( hasTypes ).or( new HasAssignableFromType<>( hasTypes ) ); }
@Override public TransientDescriptor lookupTransientModel( final Class<?> type ) { return transientModels.computeIfAbsent( type, key -> { List<? extends TransientDescriptor> allModels = getAllTransients(); TransientDescriptor model = ambiguityMatching( key, allModels, new HasEqualType<>( key ) ); if( model == null ) { model = ambiguityMatching( key, allModels, new HasAssignableFromType<>( key ) ); } return model; } ); }
@Override public EntityDescriptor lookupEntityModel( final Class<?> type ) { return unambiguousEntityModels.computeIfAbsent( type, key -> { List<? extends EntityDescriptor> allModels = getAllEntities(); EntityDescriptor model = ambiguityMatching( key, allModels, new HasEqualType<>( key ) ); if( model == null ) { model = ambiguityMatching( key, allModels, new HasAssignableFromType<>( key ) ); } return model; } ); }
@Override public ObjectDescriptor lookupObjectModel( final Class<?> type ) { return objectModels.computeIfAbsent( type, key -> { List<? extends ObjectDescriptor> allModels = getAllObjects(); ObjectDescriptor model = ambiguityMatching( key, allModels, new HasEqualType<>( key ) ); if( model == null ) { model = ambiguityMatching( key, allModels, new HasAssignableFromType<>( key ) ); } return model; } ); }
@Override public ValueDescriptor lookupValueModel( final Class<?> type ) { return valueModels.computeIfAbsent( type, key -> { List<? extends ValueDescriptor> allModels = getAllValues(); ValueDescriptor model = ambiguityMatching( key, allModels, new HasEqualType<>( key ) ); if( model == null ) { model = ambiguityMatching( key, allModels, new HasAssignableFromType<>( key ) ); } return model; } ); }