Class TypeSet

java.lang.Object
net.okapia.osid.torrefacto.collect.TypeSet
All Implemented Interfaces:
Iterable<Type>, Types
Direct Known Subclasses:
TypeEnumSet

public class TypeSet extends Object implements Types
A Types collection that holds each type at most once. A type is uniquely identified by its namespace, authority, and identifier, so adding one that is already present is a no-op and a single remove drops it. Insertion order is preserved. This utility helps a provider manage type support. When support may be registered and withdrawn from several sources, use the reference-counted TypeRefSet instead. The backing set is synchronized.
  • Constructor Details

    • TypeSet

      public TypeSet()
      Creates a new TypeSet.
    • TypeSet

      public TypeSet(Collection<Type> types)
      Creates a new TypeSet for a given collection of types.
      Parameters:
      types - the initial types
      Throws:
      NullArgumentException - types is null
    • TypeSet

      public TypeSet(Type[] types)
      Creates a new TypeSet for a given array of types.
      Parameters:
      types - the initial types
      Throws:
      NullArgumentException - types is null
  • Method Details

    • add

      public void add(Type type)
      Tracks a supported type.
      Specified by:
      add in interface Types
      Parameters:
      type - the type
      Throws:
      NullArgumentException - type is null
    • remove

      public void remove(Type type)
      Removes a type.
      Specified by:
      remove in interface Types
      Parameters:
      type - the type
      Throws:
      NullArgumentException - type is null
    • contains

      public boolean contains(Type type)
      Tests for the existience of a type.
      Specified by:
      contains in interface Types
      Parameters:
      type - the type
      Returns:
      true if the type exists, false otherwise
      Throws:
      NullArgumentException - type is null
    • toCollection

      public Collection<Type> toCollection()
      Gets an iterable collection of the types.
      Specified by:
      toCollection in interface Types
      Returns:
      a collection
    • toArray

      public Type[] toArray()
      Gets an array of the types.
      Specified by:
      toArray in interface Types
      Returns:
      an array of types
    • clear

      public void clear()
      Removes all types.
      Specified by:
      clear in interface Types
    • iterator

      public Iterator<Type> iterator()
      Returns an iterator of Types.
      Specified by:
      iterator in interface Iterable<Type>
      Returns:
      an iterator