Class CollectionsUtil


  • public class CollectionsUtil
    extends java.lang.Object
    Author:
    Neil Matatall (neil.matatall .at. gmail.com) Are these necessary? Are there any libraries or java.lang classes to take care of the conversions? FIXME: we can convert to using this, but it requires that the array be of Character, not char new HashSet(Arrays.asList(array))
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.Set<java.lang.Character> arrayToSet​(char... array)
      Converts an array of chars to a Set of Characters.
      static java.util.Set<java.lang.Character> arrayToUnmodifiableSet​(char... array)
      Convert a char array to a unmodifiable Set.
      static char[] strToChars​(java.lang.String str)
      Convert a String to a char array
      static java.util.Set<java.lang.Character> strToSet​(java.lang.String str)
      Convert a String to a set of characters.
      static java.util.Set<java.lang.Character> strToUnmodifiableSet​(java.lang.String str)
      Convert a String to a unmodifiable set of characters.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • arrayToSet

        public static java.util.Set<java.lang.Character> arrayToSet​(char... array)
        Converts an array of chars to a Set of Characters.
        Parameters:
        array - the contents of the new Set
        Returns:
        a Set containing the elements in the array
      • arrayToUnmodifiableSet

        public static java.util.Set<java.lang.Character> arrayToUnmodifiableSet​(char... array)
        Convert a char array to a unmodifiable Set.
        Parameters:
        array - the contents of the new Set
        Returns:
        a unmodifiable Set containing the elements in the array.
      • strToChars

        public static char[] strToChars​(java.lang.String str)
        Convert a String to a char array
        Parameters:
        str - The string to convert
        Returns:
        character array containing the characters in str. An empty array is returned if str is null.
      • strToSet

        public static java.util.Set<java.lang.Character> strToSet​(java.lang.String str)
        Convert a String to a set of characters.
        Parameters:
        str - The string to convert
        Returns:
        A set containing the characters in str. A empty set is returned if str is null.
      • strToUnmodifiableSet

        public static java.util.Set<java.lang.Character> strToUnmodifiableSet​(java.lang.String str)
        Convert a String to a unmodifiable set of characters.
        Parameters:
        str - The string to convert
        Returns:
        A set containing the characters in str. A empty set is returned if str is null.