コード例 #1
0
 /**
  * Factory method to create an unmodifiable set.
  *
  * @param set  the set to decorate, must not be null
  * @throws IllegalArgumentException if set is null
  */
 public static java.util.SortedSet <Object> decorate(java.util.SortedSet <Object> set)
 {
     if (set is Unmodifiable)
     {
         return(set);
     }
     return(new UnmodifiableSortedSet(set));
 }
 public java.util.SortedSet <Object> headSet(Object toElement)
 {
     lock (lockJ)
     {
         java.util.SortedSet <Object> set = getSortedSet().headSet(toElement);
         // the lock is passed into the constructor here to ensure that the
         // headset is synchronized on the same lock as the parent
         return(new SynchronizedSortedSet(set, lockJ));
     }
 }
 public java.util.SortedSet <Object> headSet(Object toElement)
 {
     java.util.SortedSet <Object> set = getSortedSet().headSet(toElement);
     return(new TransformedSortedSet(set, transformer));
 }
コード例 #4
0
        //-----------------------------------------------------------------------

        /**
         * Constructor that wraps (not copies).
         *
         * @param set  the set to decorate, must not be null
         * @throws IllegalArgumentException if set is null
         */
        private UnmodifiableSortedSet(java.util.SortedSet <Object> set)
            : base(set)
        {
        }
コード例 #5
0
 public override java.util.SortedSet <Object> tailSet(Object fromElement)
 {
     java.util.SortedSet <Object> sub = getSortedSet().tailSet(fromElement);
     return(new UnmodifiableSortedSet(sub));
 }
コード例 #6
0
 public override java.util.SortedSet <Object> headSet(Object toElement)
 {
     java.util.SortedSet <Object> sub = getSortedSet().headSet(toElement);
     return(new UnmodifiableSortedSet(sub));
 }
 //-----------------------------------------------------------------------
 public java.util.SortedSet <Object> subSet(Object fromElement, Object toElement)
 {
     java.util.SortedSet <Object> sub = getSortedSet().subSet(fromElement, toElement);
     return(new PredicatedSortedSet(sub, predicate));
 }
        //-----------------------------------------------------------------------

        /**
         * Constructor that wraps (not copies).
         * <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
         */
        protected TransformedSortedSet(java.util.SortedSet <Object> set, Transformer transformer)
            : base(set, transformer)
        {
        }
コード例 #9
0
 /**
  * Returns an unmodifiable sorted set backed by the given sorted set.
  * <p>
  * This method uses the implementation in the decorators subpackage.
  *
  * @param set  the sorted set to make unmodifiable, must not be null
  * @return an unmodifiable set backed by the given set
  * @throws IllegalArgumentException  if the set is null
  */
 public static java.util.SortedSet <Object> unmodifiableSortedSet(java.util.SortedSet <Object> set)
 {
     return(UnmodifiableSortedSet.decorate(set));
 }
コード例 #10
0
        //-----------------------------------------------------------------------

        /**
         * Returns a synchronized sorted set backed by the given sorted set.
         * <p>
         * You must manually synchronize on the returned buffer's iterator to
         * avoid non-deterministic behavior:
         *
         * <pre>
         * Set s = SetUtils.synchronizedSet(mySet);
         * synchronized (s) {
         *     Iterator i = s.iterator();
         *     while (i.hasNext()) {
         *         process (i.next());
         *     }
         * }
         * </pre>
         *
         * This method uses the implementation in the decorators subpackage.
         *
         * @param set  the sorted set to synchronize, must not be null
         * @return a synchronized set backed by the given set
         * @throws IllegalArgumentException  if the set is null
         */
        public static java.util.SortedSet <Object> synchronizedSortedSet(java.util.SortedSet <Object> set)
        {
            return(SynchronizedSortedSet.decorate(set));
        }
 /**
  * Constructor that wraps (not copies).
  *
  * @param set  the set to decorate, must not be null
  * @param lock  the lock object to use, must not be null
  * @throws IllegalArgumentException if set is null
  */
 protected SynchronizedSortedSet(java.util.SortedSet <Object> set, Object lockJ)
     : base(set, lockJ)
 {
 }
        //-----------------------------------------------------------------------

        /**
         * Constructor that wraps (not copies).
         *
         * @param set  the set to decorate, must not be null
         * @throws IllegalArgumentException if set is null
         */
        protected SynchronizedSortedSet(java.util.SortedSet <Object> set)
            : base(set)
        {
        }
 public java.util.SortedSet <Object> headSet(Object toElement)
 {
     java.util.SortedSet <Object> sub = getSortedSet().headSet(toElement);
     return(new PredicatedSortedSet(sub, predicate));
 }
 public java.util.SortedSet <Object> tailSet(Object fromElement)
 {
     java.util.SortedSet <Object> set = getSortedSet().tailSet(fromElement);
     return(new TransformedSortedSet(set, transformer));
 }
コード例 #15
0
 /**
  * Returns a predicated (validating) sorted set backed by the given sorted set.
  * <p>
  * Only objects that pass the test in the given predicate can be added to the set.
  * Trying to add an invalid object results in an IllegalArgumentException.
  * It is important not to use the original set after invoking this method,
  * as it is a backdoor for adding invalid objects.
  *
  * @param set  the sorted set to predicate, must not be null
  * @param predicate  the predicate for the sorted set, must not be null
  * @return a predicated sorted set backed by the given sorted set
  * @throws IllegalArgumentException  if the Set or Predicate is null
  */
 public static java.util.SortedSet <Object> predicatedSortedSet(java.util.SortedSet <Object> set, Predicate predicate)
 {
     return(PredicatedSortedSet.decorate(set, predicate));
 }
 /**
  * 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 java.util.SortedSet <Object> decorate(java.util.SortedSet <Object> set, Transformer transformer)
 {
     return(new TransformedSortedSet(set, transformer));
 }
コード例 #17
0
 /**
  * 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 java.util.SortedSet <Object> typedSortedSet(java.util.SortedSet <Object> set, java.lang.Class type)
 {
     return(TypedSortedSet.decorate(set, type));
 }
コード例 #18
0
 /**
  * Factory method to create a typed sorted set.
  * <p>
  * If there are any elements already in the set being decorated, they
  * are validated.
  *
  * @param set  the set to decorate, must not be null
  * @param type  the type to allow into the collection, must not be null
  * @throws IllegalArgumentException if set or type is null
  * @throws IllegalArgumentException if the set contains invalid elements
  */
 public static java.util.SortedSet <Object> decorate(java.util.SortedSet <Object> set, java.lang.Class type)
 {
     return(new PredicatedSortedSet(set, InstanceofPredicate.getInstance(type)));
 }
        //-----------------------------------------------------------------------

        /**
         * Constructor that wraps (not copies).
         * <p>
         * If there are any elements already in the set being decorated, they
         * are validated.
         *
         * @param set  the set to decorate, must not be null
         * @param predicate  the predicate to use for validation, must not be null
         * @throws IllegalArgumentException if set or predicate is null
         * @throws IllegalArgumentException if the set contains invalid elements
         */
        protected internal PredicatedSortedSet(java.util.SortedSet <Object> set, Predicate predicate)
            : base(set, predicate)
        {
        }