/** * Factory method to create an ordered set. * <p> * An <code>ArrayList</code> is used to retain order. * * @param set the set to decorate, must not be null * @throws IllegalArgumentException if set is null */ public static ListOrderedSet decorate(Set set) { return new ListOrderedSet(set); }
/** * Factory method to create a set from a map. * * @param map the map to decorate, must not be null * @throws IllegalArgumentException if set is null */ public static Set decorate(Map map) { return decorate(map, null); }
/** * Gets an unmodifiable view as a Set. * * @return an unmodifiable set view */ public Set asSet() { return UnmodifiableSet.decorate(set); }
public void testContains() { CompositeSet set = new CompositeSet(new Set[]{buildOne(), buildTwo()}); assertTrue(set.contains("1")); }
/** * Returns a typed sorted set backed by the given set. * <p> * Only objects of the specified type can be added to the set. * * @param set the set to limit to a specific type, must not be null * @param type the type of objects which may be added to the set * @return a typed set backed by the specified set */ public static SortedSet typedSortedSet(SortedSet set, Class type) { return TypedSortedSet.decorate(set, type); }
/** * Add an array of sets to this composite * @param comps * @throws IllegalArgumentException if any of the collections in comps do not implement Set */ public synchronized void addComposited(Collection[] comps) { for (int i = comps.length - 1; i >= 0; --i) { this.addComposited(comps[i]); } }
/** * Gets the set being decorated. * * @return the decorated set */ protected Set getSet() { return (Set) getCollection(); }
/** * Gets the sorted set being decorated. * * @return the decorated set */ protected SortedSet getSortedSet() { return (SortedSet) getCollection(); }
/** * Factory method to create a synchronized set. * * @param set the set to decorate, must not be null * @throws IllegalArgumentException if set is null */ public static SortedSet decorate(SortedSet set) { return new SynchronizedSortedSet(set); }
/** * Gets the set being decorated. * * @return the decorated set */ protected Set getSet() { return (Set) getCollection(); }
public void testComparator() { setupSet(); Comparator c = set.comparator(); assertTrue("natural order, so comparator should be null", c == null); }
public void testGetSet() { Set set = makeTestSet(); assertTrue("returned set should not be null", ((PredicatedSet) set).getSet() != null); }
public void testGetSet() { SortedSet set = makeTestSet(); assertTrue("returned set should not be null", ((PredicatedSortedSet) set).getSet() != null); }
/** * Bulk test {@link SortedSet#tailSet(Object)}. This method runs through all of * the tests in {@link AbstractTestSortedSet}. * After modification operations, {@link #verify()} is invoked to ensure * that the set and the other collection views are still valid. * * @return a {@link AbstractTestSet} instance for testing a tailset. */ public BulkTest bulkTestSortedSetTailSet() { int length = getFullElements().length; int lobound = length / 3; return new TestSortedSetSubSet(lobound, false); }
public Set makeFullSet() { SortedSet s = (SortedSet) AbstractTestSortedSet.this.makeFullCollection(); return getSubSet(s); }
public Set makeEmptySet() { SortedSet s = (SortedSet) AbstractTestSortedSet.this.makeEmptySet(); return getSubSet(s); }
/** * Makes an empty collection by invoking {@link #makeEmptySet()}. * * @return an empty collection */ public final Collection makeCollection() { return makeEmptySet(); }
/** * Makes a full collection by invoking {@link #makeFullSet()}. * * @return a full collection */ public final Collection makeFullCollection() { return makeFullSet(); }
/** * Bulk test {@link SortedSet#headSet(Object)}. This method runs through all of * the tests in {@link AbstractTestSortedSet}. * After modification operations, {@link #verify()} is invoked to ensure * that the set and the other collection views are still valid. * * @return a {@link AbstractTestSet} instance for testing a headset. */ public BulkTest bulkTestSortedSetHeadSet() { int length = getFullElements().length; int lobound = length / 3; int hibound = lobound * 2; return new TestSortedSetSubSet(hibound, true); }
/** * Bulk test {@link SortedSet#subSet(Object, Object)}. This method runs through all of * the tests in {@link AbstractTestSortedSet}. * After modification operations, {@link #verify()} is invoked to ensure * that the set and the other collection views are still valid. * * @return a {@link AbstractTestSet} instance for testing a subset. */ public BulkTest bulkTestSortedSetSubSet() { int length = getFullElements().length; int lobound = length / 3; int hibound = lobound * 2; return new TestSortedSetSubSet(lobound, hibound); }