/** * Returns a transformed sorted set backed by the given set. * <p> * Each object is passed through the transformer as it is added to the * Set. It is important not to use the original set after invoking this * method, as it is a backdoor for adding untransformed objects. * * @param set the set to transform, must not be null * @param transformer the transformer for the set, must not be null * @return a transformed set backed by the given set * @throws IllegalArgumentException if the Set or Transformer is null */ public static SortedSet transformedSortedSet(SortedSet set, Transformer transformer) { return TransformedSortedSet.decorate(set, transformer); }
public SortedSet headSet(Object toElement) { SortedSet set = getSortedSet().headSet(toElement); return new TransformedSortedSet(set, transformer); }
public Object first() { return getSortedSet().first(); }
/** * Factory method to create a transforming sorted set. * <p> * If there are any elements already in the set being decorated, they * are NOT transformed. * * @param set the set to decorate, must not be null * @param transformer the transformer to use for conversion, must not be null * @throws IllegalArgumentException if set or transformer is null */ public static SortedSet decorate(SortedSet set, Transformer transformer) { return new TransformedSortedSet(set, transformer); }
public Object last() { return getSortedSet().last(); }
/** * Factory method to create a transforming sorted set. * <p> * If there are any elements already in the set being decorated, they * are NOT transformed. * * @param set the set to decorate, must not be null * @param transformer the transformer to use for conversion, must not be null * @throws IllegalArgumentException if set or transformer is null */ public static SortedSet decorate(SortedSet set, Transformer transformer) { return new TransformedSortedSet(set, transformer); }
public SortedSet tailSet(Object fromElement) { SortedSet set = getSortedSet().tailSet(fromElement); return new TransformedSortedSet(set, transformer); }
/** * Returns a transformed sorted set backed by the given set. * <p> * Each object is passed through the transformer as it is added to the * Set. It is important not to use the original set after invoking this * method, as it is a backdoor for adding untransformed objects. * * @param set the set to transform, must not be null * @param transformer the transformer for the set, must not be null * @return a transformed set backed by the given set * @throws IllegalArgumentException if the Set or Transformer is null */ public static SortedSet transformedSortedSet(SortedSet set, Transformer transformer) { return TransformedSortedSet.decorate(set, transformer); }
public Comparator comparator() { return getSortedSet().comparator(); }
/** * Factory method to create a transforming sorted set. * <p> * If there are any elements already in the set being decorated, they * are NOT transformed. * * @param set the set to decorate, must not be null * @param transformer the transformer to use for conversion, must not be null * @throws IllegalArgumentException if set or transformer is null */ public static SortedSet decorate(SortedSet set, Transformer transformer) { return new TransformedSortedSet(set, transformer); }
public SortedSet tailSet(Object fromElement) { SortedSet set = getSortedSet().tailSet(fromElement); return new TransformedSortedSet(set, transformer); }
public Set makeEmptySet() { return TransformedSortedSet.decorate(new TreeSet(), TestTransformedCollection.NOOP_TRANSFORMER); }
public Object first() { return getSortedSet().first(); }
/** * Factory method to create a transforming sorted set. * <p> * If there are any elements already in the set being decorated, they * are NOT transformed. * * @param set the set to decorate, must not be null * @param transformer the transformer to use for conversion, must not be null * @throws IllegalArgumentException if set or transformer is null */ public static SortedSet decorate(SortedSet set, Transformer transformer) { return new TransformedSortedSet(set, transformer); }
public SortedSet headSet(Object toElement) { SortedSet set = getSortedSet().headSet(toElement); return new TransformedSortedSet(set, transformer); }
public Set makeFullSet() { SortedSet set = new TreeSet(); set.addAll(Arrays.asList(getFullElements())); return TransformedSortedSet.decorate(set, TestTransformedCollection.NOOP_TRANSFORMER); }
public Comparator comparator() { return getSortedSet().comparator(); }
/** * Factory method to create a transforming sorted set. * <p> * If there are any elements already in the set being decorated, they * are NOT transformed. * * @param set the set to decorate, must not be null * @param transformer the transformer to use for conversion, must not be null * @throws IllegalArgumentException if set or transformer is null */ public static SortedSet decorate(SortedSet set, Transformer transformer) { return new TransformedSortedSet(set, transformer); }
public SortedSet subSet(Object fromElement, Object toElement) { SortedSet set = getSortedSet().subSet(fromElement, toElement); return new TransformedSortedSet(set, transformer); }
public void testTransformedSet() { Set set = TransformedSortedSet.decorate(new HashSet(), TestTransformedCollection.STRING_TO_INTEGER_TRANSFORMER); assertEquals(0, set.size()); Object[] els = new Object[] {"1", "3", "5", "7", "2", "4", "6"}; for (int i = 0; i < els.length; i++) { set.add(els[i]); assertEquals(i + 1, set.size()); assertEquals(true, set.contains(new Integer((String) els[i]))); assertEquals(false, set.contains(els[i])); } assertEquals(false, set.remove(els[0])); assertEquals(true, set.remove(new Integer((String) els[0]))); }