public HasEqualOrAssignableToType( T hasTypes ) { composedPredicate = new HasEqualType<>( hasTypes ).or( new HasAssignableToType<>( hasTypes ) ); }
private static <T extends HasTypes> Collector<T, ?, List<T>> typeToListCollector( Type type, Predicate<T> assignableTypePredicate ) Predicate<T> equalTypePredicate = new HasEqualType<>( type ); return new Collector<T, Map<String, Set<T>>, List<T>>()
@Test public void hasEqualTypePredicate() { assertTrue( new HasEqualType<>( Integer.class ) .test( ValueType.of( Integer.class ) ) ); assertTrue( new HasEqualType<>( Integer.class ) .test( ValueType.of( String.class, Integer.class ) ) ); assertFalse( new HasEqualType<>( Number.class ) .test( ValueType.of( String.class, Integer.class ) ) ); assertFalse( new HasEqualType<>( String.class ) .test( ValueType.of( LocalDate.class, Integer.class ) ) ); assertTrue( new HasEqualType<>( ValueType.of( Integer.class ) ) .test( ValueType.of( Integer.class ) ) ); assertTrue( new HasEqualType<>( ValueType.of( Integer.class ) ) .test( ValueType.of( String.class, Integer.class ) ) ); assertFalse( new HasEqualType<>( ValueType.of( Number.class ) ) .test( ValueType.of( String.class, Integer.class ) ) ); assertFalse( new HasEqualType<>( ValueType.of( String.class ) ) .test( ValueType.of( LocalDate.class, Integer.class ) ) ); }
private static <T extends HasTypes> Collector<T, ?, List<T>> typeToListCollector( Type type, Predicate<T> assignableTypePredicate ) Predicate<T> equalTypePredicate = new HasEqualType<>( type ); return new Collector<T, Map<String, Set<T>>, List<T>>()
public HasEqualOrAssignableFromType( Type type ) { composedPredicate = new HasEqualType<T>( type ).or( new HasAssignableFromType<>( type ) ); }
private static <T extends HasTypes> Collector<T, ?, Optional<T>> typeFindFirstCollector( Type type, Predicate<T> assignableTypePredicate ) Predicate<T> equalTypePredicate = new HasEqualType<>( type ); return new Collector<T, Map<String, Set<T>>, Optional<T>>()
public HasEqualOrAssignableToType( T hasTypes ) { composedPredicate = new HasEqualType<>( hasTypes ).or( new HasAssignableToType<>( hasTypes ) ); }
private static <T extends HasTypes> Collector<T, ?, Optional<T>> typeFindFirstCollector( Type type, Predicate<T> assignableTypePredicate ) Predicate<T> equalTypePredicate = new HasEqualType<>( type ); return new Collector<T, Map<String, Set<T>>, Optional<T>>()
public HasEqualOrAssignableFromType( T hasTypes ) { composedPredicate = new HasEqualType<>( hasTypes ).or( new HasAssignableFromType<>( hasTypes ) ); }
Predicate<T> equalTypePredicate = new HasEqualType<>( hasTypes ); return new Collector<T, Map<String, Set<T>>, List<T>>()
public HasEqualOrAssignableToType( Type type ) { composedPredicate = new HasEqualType<T>( type ).or( new HasAssignableToType<>( type ) ); }
Predicate<T> equalTypePredicate = new HasEqualType<>( hasTypes ); return new Collector<T, Map<String, Set<T>>, Optional<T>>()
public HasEqualOrAssignableToType( Type type ) { composedPredicate = new HasEqualType<T>( type ).or( new HasAssignableToType<>( type ) ); }
Predicate<T> equalTypePredicate = new HasEqualType<>( hasTypes ); return new Collector<T, Map<String, Set<T>>, List<T>>()
public HasEqualOrAssignableFromType( Type type ) { composedPredicate = new HasEqualType<T>( type ).or( new HasAssignableFromType<>( type ) ); }
Predicate<T> equalTypePredicate = new HasEqualType<>( hasTypes ); return new Collector<T, Map<String, Set<T>>, Optional<T>>()
public HasEqualOrAssignableFromType( T hasTypes ) { composedPredicate = new HasEqualType<>( hasTypes ).or( new HasAssignableFromType<>( hasTypes ) ); }
@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 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; } ); }