public TreeSortedMap(Pair<K, V>... pairs) { this.treeMap = new TreeMap<>(); ArrayIterate.forEach(pairs, new MapCollectProcedure<Pair<K, V>, K, V>( this.treeMap, Functions.firstOfPair(), Functions.secondOfPair())); }
public UnifiedMap(Pair<K, V>... pairs) { this(Math.max(pairs.length, DEFAULT_INITIAL_CAPACITY), DEFAULT_LOAD_FACTOR); ArrayIterate.forEach(pairs, new MapCollectProcedure<Pair<K, V>, K, V>( this, Functions.firstOfPair(), Functions.secondOfPair())); }
public UnifiedMapWithHashingStrategy(HashingStrategy<? super K> hashingStrategy, Pair<K, V>... pairs) { this(hashingStrategy, Math.max(pairs.length, DEFAULT_INITIAL_CAPACITY), DEFAULT_LOAD_FACTOR); ArrayIterate.forEach(pairs, new MapCollectProcedure<Pair<K, V>, K, V>( this, Functions.firstOfPair(), Functions.secondOfPair())); }
public UnifiedMapWithHashingStrategy(HashingStrategy<? super K> hashingStrategy, Pair<K, V>... pairs) { this(hashingStrategy, Math.max(pairs.length, DEFAULT_INITIAL_CAPACITY), DEFAULT_LOAD_FACTOR); ArrayIterate.forEach(pairs, new MapCollectProcedure<Pair<K, V>, K, V>( this, Functions.firstOfPair(), Functions.secondOfPair())); }
public TreeSortedMap(Pair<K, V>... pairs) { this.treeMap = new TreeMap<>(); ArrayIterate.forEach(pairs, new MapCollectProcedure<Pair<K, V>, K, V>( this.treeMap, Functions.firstOfPair(), Functions.secondOfPair())); }
public UnifiedMap(Pair<K, V>... pairs) { this(Math.max(pairs.length, DEFAULT_INITIAL_CAPACITY), DEFAULT_LOAD_FACTOR); ArrayIterate.forEach(pairs, new MapCollectProcedure<Pair<K, V>, K, V>( this, Functions.firstOfPair(), Functions.secondOfPair())); }
@Override public MutableSortedMap<K, V> with(Pair<K, V>... pairs) { ArrayIterate.forEach(pairs, new MapCollectProcedure<Pair<K, V>, K, V>(this, Functions.firstOfPair(), Functions.secondOfPair())); return this; }
@Override public TreeSortedMap<K, V> with(Pair<K, V>... pairs) { ArrayIterate.forEach(pairs, new MapCollectProcedure<Pair<K, V>, K, V>(this, Functions.firstOfPair(), Functions.secondOfPair())); return this; }
@Override public MutableSortedMap<K, V> with(Pair<K, V>... pairs) { ArrayIterate.forEach(pairs, new MapCollectProcedure<Pair<K, V>, K, V>(this, Functions.firstOfPair(), Functions.secondOfPair())); return this; }
@Override public TreeSortedMap<K, V> with(Pair<K, V>... pairs) { ArrayIterate.forEach(pairs, new MapCollectProcedure<Pair<K, V>, K, V>(this, Functions.firstOfPair(), Functions.secondOfPair())); return this; }
@Override public ImmutableSortedSet<Pair<T, Integer>> zipWithIndex() { Comparator<? super T> comparator = this.comparator() == null ? Comparators.naturalOrder() : this.comparator(); TreeSortedSet<Pair<T, Integer>> pairs = TreeSortedSet.newSet( Comparators.<Pair<T, Integer>>chain( Comparators.byFunction(Functions.firstOfPair(), comparator), Comparators.byFunction(Functions.secondOfPair()))); return Iterate.zipWithIndex(this, pairs).toImmutable(); }
@Override public ImmutableSortedSet<Pair<T, Integer>> zipWithIndex() { Comparator<? super T> comparator = this.comparator() == null ? Comparators.naturalOrder() : this.comparator(); TreeSortedSet<Pair<T, Integer>> pairs = TreeSortedSet.newSet( Comparators.<Pair<T, Integer>>chain( Comparators.byFunction(Functions.firstOfPair(), comparator), Comparators.byFunction(Functions.secondOfPair()))); return Iterate.zipWithIndex(this, pairs).toImmutable(); }
public TreeSortedMap(Pair<K, V>... pairs) { this.treeMap = new TreeMap<>(); ArrayIterate.forEach(pairs, new MapCollectProcedure<Pair<K, V>, K, V>( this.treeMap, Functions.firstOfPair(), Functions.secondOfPair())); }
public UnifiedMap(Pair<K, V>... pairs) { this(Math.max(pairs.length, DEFAULT_INITIAL_CAPACITY), DEFAULT_LOAD_FACTOR); ArrayIterate.forEach(pairs, new MapCollectProcedure<Pair<K, V>, K, V>( this, Functions.firstOfPair(), Functions.secondOfPair())); }
public UnifiedMapWithHashingStrategy(HashingStrategy<? super K> hashingStrategy, Pair<K, V>... pairs) { this(hashingStrategy, Math.max(pairs.length, DEFAULT_INITIAL_CAPACITY), DEFAULT_LOAD_FACTOR); ArrayIterate.forEach(pairs, new MapCollectProcedure<Pair<K, V>, K, V>( this, Functions.firstOfPair(), Functions.secondOfPair())); }
@Override public MutableSortedMap<K, V> with(Pair<K, V>... pairs) { ArrayIterate.forEach(pairs, new MapCollectProcedure<Pair<K, V>, K, V>(this, Functions.firstOfPair(), Functions.secondOfPair())); return this; }
@Override public TreeSortedMap<K, V> with(Pair<K, V>... pairs) { ArrayIterate.forEach(pairs, new MapCollectProcedure<Pair<K, V>, K, V>(this, Functions.firstOfPair(), Functions.secondOfPair())); return this; }
@Override public ImmutableSortedSet<Pair<T, Integer>> zipWithIndex() { Comparator<? super T> comparator = this.comparator() == null ? Comparators.naturalOrder() : this.comparator(); TreeSortedSet<Pair<T, Integer>> pairs = TreeSortedSet.newSet( Comparators.<Pair<T, Integer>>chain( Comparators.byFunction(Functions.firstOfPair(), comparator), Comparators.byFunction(Functions.secondOfPair()))); return Iterate.zipWithIndex(this, pairs).toImmutable(); }
@Test public void testStringParsing() { ObjectTypeAndNamePredicateBuilder parse = ObjectTypeAndNamePredicateBuilder.parse("TABLE~tab1,tab2;-VIEW~view1", null); Predicates<? super Pair<String, String>> predicate = parse.build(Functions.<String>firstOfPair(), (Function<Pair<String, String>, String>) (Function) Functions.<String>secondOfPair()); assertTrue(predicate.accept(Tuples.pair("OTHER", "otherInclude"))); assertTrue(predicate.accept(Tuples.pair("TABLE", "tab1"))); assertTrue(predicate.accept(Tuples.pair("TABLE", "tab2"))); assertFalse(predicate.accept(Tuples.pair("TABLE", "tabNo"))); assertFalse(predicate.accept(Tuples.pair("VIEW", "view1"))); assertTrue(predicate.accept(Tuples.pair("VIEW", "viewInclude"))); }
@Test public void testStringParsingWithExclusionDefault() { ObjectTypeAndNamePredicateBuilder parse = ObjectTypeAndNamePredicateBuilder.parse("TABLE~tab1,tab2;VIEW~view1", ObjectTypeAndNamePredicateBuilder.FilterType.EXCLUDE); Predicates<? super Pair<String, String>> predicate = parse.build(Functions.<String>firstOfPair(), (Function<Pair<String, String>, String>) (Function) Functions.<String>secondOfPair()); assertTrue(predicate.accept(Tuples.pair("OTHER", "otherInclude"))); assertFalse(predicate.accept(Tuples.pair("TABLE", "tab1"))); assertFalse(predicate.accept(Tuples.pair("TABLE", "tab2"))); assertTrue(predicate.accept(Tuples.pair("TABLE", "tabNo"))); assertFalse(predicate.accept(Tuples.pair("VIEW", "view1"))); assertTrue(predicate.accept(Tuples.pair("VIEW", "viewInclude"))); } }