### Question:
HasTypesCollectors { public static <T extends HasTypes> Collector<T, ?, List<T>> closestTypes( T hasTypes ) { return hasTypesToListCollector( hasTypes, new HasAssignableToType<>( hasTypes ) ); } private  HasTypesCollectors(); static Collector<T, ?, Optional<T>> matchingType( T hasTypes ); static Collector<T, ?, Optional<T>> closestType( T hasTypes ); static Collector<T, ?, List<T>> matchingTypes( T hasTypes ); static Collector<T, ?, List<T>> closestTypes( T hasTypes ); static Collector<T, ?, Optional<T>> matchingType( Type type ); static Collector<T, ?, Optional<T>> closestType( Type type ); static Collector<T, ?, List<T>> matchingTypes( Type type ); static Collector<T, ?, List<T>> closestTypes( Type type );  }### Answer:
@Test public void selectClosestValueTypes() { List<ValueType> list = new ArrayList<ValueType>() {{ add( ValueType.of( String.class ) ); add( ValueType.of( Identity.class ) ); }}; List<ValueType> result = list.stream() .collect( HasTypesCollectors.closestTypes( StringIdentity.class ) ); assertThat( result.size(), is( 1 ) ); assertThat( result.get( 0 ), equalTo( ValueType.of( Identity.class ) ) ); }