Class CollectionsUtil

java.lang.Object
org.eclipse.nebula.widgets.xviewer.core.util.CollectionsUtil

public class CollectionsUtil
extends java.lang.Object
  • Nested Class Summary

    Nested Classes 
    Modifier and Type Class Description
    static class  CollectionsUtil.CastOption  
  • Constructor Summary

    Constructors 
    Constructor Description
    CollectionsUtil()  
  • Method Summary

    Modifier and Type Method Description
    static <A> java.util.List<A> castAll​(java.lang.Class<A> clazz, java.util.Collection<? extends java.lang.Object> objects)
    Unchecked cast objects to clazz; CastClassException will occur when object sent in does not match clazz

    Use when all objects are expected to be of type class and exception is desired if not
    static <A> java.util.List<A> castAll​(java.util.Collection<?> objects)
    Cast objects to clazz
    static <A> java.util.List<A> castMatching​(java.lang.Class<A> clazz, java.util.Collection<? extends java.lang.Object> objects)
    Cast objects matching class, ignore rest; no ClassCastException will occur

    Use when objects may contain classes that are not desired
    static java.util.Collection<java.lang.String> fromString​(java.lang.String string, java.lang.String seperator)  
    static <T> java.util.List<T> getAggregate​(T... objects)
    Convert an aggregate list of objects into a List
    static java.util.List<java.lang.Object> getAggregateTree​(java.util.List<java.lang.Object> items, int maxPerList)  
    static <T> boolean isEqual​(java.util.Collection<T> listA, java.util.Collection<T> listB)
    Return true if same objects exist in listA and listB
    static <T> java.util.List<T> setComplement​(java.util.Collection<T> superSet, java.util.Collection<T> subList)
    The resultant set is those elements in superSet which are not in the subSet
    static <T> java.util.List<T> setIntersection​(java.util.Collection<T> listA, java.util.Collection<T> listB)  
    static <T> java.util.Set<T> setUnion​(java.util.Collection<T>... lists)
    Returns the unique union of the given lists
    static java.lang.String toString​(java.lang.String separator, java.lang.Object... objects)  
    static java.lang.String toString​(java.lang.String separator, java.util.Collection c)  
    static java.lang.String toString​(java.util.Collection c, java.lang.String start, java.lang.String separator, java.lang.String end)
    An flexible alternative for converting a Collection to a String.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • fromString

      public static java.util.Collection<java.lang.String> fromString​(java.lang.String string, java.lang.String seperator)
    • toString

      public static java.lang.String toString​(java.util.Collection c, java.lang.String start, java.lang.String separator, java.lang.String end)
      An flexible alternative for converting a Collection to a String.
      Parameters:
      c - The Collection to convert to a String
      start - The String to place at the beginning of the returned String
      separator - The String to place in between elements of the Collection c.
      end - The String to place at the end of the returned String
      Returns:
      A String which starts with 'start', followed by the elements in the Collection c separated by 'separator', ending with 'end'.
    • toString

      public static java.lang.String toString​(java.lang.String separator, java.lang.Object... objects)
    • toString

      public static java.lang.String toString​(java.lang.String separator, java.util.Collection c)
    • setComplement

      public static <T> java.util.List<T> setComplement​(java.util.Collection<T> superSet, java.util.Collection<T> subList)
      The resultant set is those elements in superSet which are not in the subSet
    • setIntersection

      public static <T> java.util.List<T> setIntersection​(java.util.Collection<T> listA, java.util.Collection<T> listB)
      Returns:
      The intersection of two sets A and B is the set of elements common to A and B
    • setUnion

      @SafeVarargs public static <T> java.util.Set<T> setUnion​(java.util.Collection<T>... lists)
      Returns the unique union of the given lists
    • isEqual

      public static <T> boolean isEqual​(java.util.Collection<T> listA, java.util.Collection<T> listB)
      Return true if same objects exist in listA and listB
    • getAggregate

      @SafeVarargs public static <T> java.util.List<T> getAggregate​(T... objects)
      Convert an aggregate list of objects into a List
    • getAggregateTree

      public static java.util.List<java.lang.Object> getAggregateTree​(java.util.List<java.lang.Object> items, int maxPerList)
    • castAll

      public static <A> java.util.List<A> castAll​(java.util.Collection<?> objects)
      Cast objects to clazz
    • castAll

      public static <A> java.util.List<A> castAll​(java.lang.Class<A> clazz, java.util.Collection<? extends java.lang.Object> objects)
      Unchecked cast objects to clazz; CastClassException will occur when object sent in does not match clazz

      Use when all objects are expected to be of type class and exception is desired if not
    • castMatching

      public static <A> java.util.List<A> castMatching​(java.lang.Class<A> clazz, java.util.Collection<? extends java.lang.Object> objects)
      Cast objects matching class, ignore rest; no ClassCastException will occur

      Use when objects may contain classes that are not desired