/** * <p> * Answer a {@link Predicate} that will accept any object that is an element of * iterator i. As a side-effect, i will be evaluated and closed. * </p> * * @param i A closable iterator * @return A Predicate that will accept any object in iterator i. */ public static <T> Predicate<T> ifIn( final ClosableIterator<T> i ) { final Set<T> allow = IteratorCollection.iteratorToSet( i ); return allow::contains; }
/** * <p> * Answer a {@link Predicate} that will accept any object that is an element of * iterator i. As a side-effect, i will be evaluated and closed. * </p> * * @param i A closable iterator * @return A Predicate that will accept any object in iterator i. */ public static <T> Predicate<T> ifIn( final ClosableIterator<T> i ) { final Set<T> allow = IteratorCollection.iteratorToSet( i ); return allow::contains; }
/** * <p> * Answer a {@link Predicate} that will reject any element that is a member of iterator i. * As a side-effect, i will be closed. * </p> * * @param i A closable iterator * @return A Predicate that will accept any object not a member of i. */ public static <T> Predicate<T> reject( final ClosableIterator<? extends T> i ) { final Set< ? extends T> suppress = IteratorCollection.iteratorToSet( i ); return o -> !suppress.contains( o ); }
/** * <p> * Answer a {@link Predicate} that will reject any element that is a member of iterator i. * As a side-effect, i will be closed. * </p> * * @param i A closable iterator * @return A Predicate that will accept any object not a member of i. */ public static <T> Predicate<T> reject( final ClosableIterator<? extends T> i ) { final Set< ? extends T> suppress = IteratorCollection.iteratorToSet( i ); return o -> !suppress.contains( o ); }
/** Answer a set containing the elements from the iterator <code>it</code>; a shorthand for <code>IteratorCollection.iteratorToSet(it)</code>, which see. */ public static <T> Set<T> iteratorToSet( Iterator<? extends T> it ) { return IteratorCollection.iteratorToSet( it ); }
/** * Answer a set containing the elements from the iterator <code>it</code>; a * shorthand for <code>IteratorCollection.iteratorToSet(it)</code>, which * see. */ public static <T> Set<T> iteratorToSet(Iterator<? extends T> it) { return IteratorCollection.iteratorToSet(it); }
/** Answer a set containing the elements from the iterator <code>it</code>; a shorthand for <code>IteratorCollection.iteratorToSet(it)</code>, which see. */ public static <T> Set<T> iteratorToSet( Iterator<? extends T> it ) { return IteratorCollection.iteratorToSet( it ); }
/** * Answer a set containing the elements from the iterator <code>it</code>; a * shorthand for <code>IteratorCollection.iteratorToSet(it)</code>, which * see. */ public static <T> Set<T> iteratorToSet(Iterator<? extends T> it) { return IteratorCollection.iteratorToSet(it); }
public void testLotsToSet() { Object [] elements = new Object[] {"now", "is", "the", "time"}; Iterator<Object> it = Arrays.asList( elements ).iterator(); assertEquals( setLots( elements ), IteratorCollection.iteratorToSet( it ) ); }
public void testLotsToSet() { Object [] elements = new Object[] {"now", "is", "the", "time"}; Iterator<Object> it = Arrays.asList( elements ).iterator(); assertEquals( setLots( elements ), IteratorCollection.iteratorToSet( it ) ); }
public void testEmptyToEmptySet() { assertEquals( CollectionFactory.createHashedSet(), IteratorCollection.iteratorToSet( NullIterator.instance() ) ); }
public void testEmptyToEmptySet() { assertEquals( CollectionFactory.createHashedSet(), IteratorCollection.iteratorToSet( NullIterator.instance() ) ); }
private void assertEqualMaps( LocationMapper expected, LocationMapper got ) { Set<String> eAltEntryKeys = IteratorCollection.iteratorToSet( expected.listAltEntries() ); Set<String> gAltEntryKeys = IteratorCollection.iteratorToSet( got.listAltEntries() ); Set<String> eAltPrefixKeys = IteratorCollection.iteratorToSet( expected.listAltPrefixes() ); Set<String> gAltPrefixKeys = IteratorCollection.iteratorToSet( got.listAltPrefixes() ); assertEquals( "altEntry keys dhould be equal", eAltEntryKeys, gAltEntryKeys ); assertEquals( "prefixEntry keys should be equal", eAltPrefixKeys, gAltPrefixKeys ); for ( String key : eAltEntryKeys ) { assertEquals( "alt entrys should be equal", expected.getAltEntry( key ), got.getAltEntry( key ) ); } for ( String key : eAltPrefixKeys ) { assertEquals( "prefix entiries should be equal", expected.getAltPrefix( key ), got.getAltPrefix( key ) ); } } }
private void assertEqualMaps( LocationMapper expected, LocationMapper got ) { Set<String> eAltEntryKeys = IteratorCollection.iteratorToSet( expected.listAltEntries() ); Set<String> gAltEntryKeys = IteratorCollection.iteratorToSet( got.listAltEntries() ); Set<String> eAltPrefixKeys = IteratorCollection.iteratorToSet( expected.listAltPrefixes() ); Set<String> gAltPrefixKeys = IteratorCollection.iteratorToSet( got.listAltPrefixes() ); assertEquals( "altEntry keys dhould be equal", eAltEntryKeys, gAltEntryKeys ); assertEquals( "prefixEntry keys should be equal", eAltPrefixKeys, gAltPrefixKeys ); for ( String key : eAltEntryKeys ) { assertEquals( "alt entrys should be equal", expected.getAltEntry( key ), got.getAltEntry( key ) ); } for ( String key : eAltPrefixKeys ) { assertEquals( "prefix entiries should be equal", expected.getAltPrefix( key ), got.getAltPrefix( key ) ); } } }