Class ConverterSet

java.lang.Object
org.joda.time.convert.ConverterSet

class ConverterSet extends Object
A set of converters, which allows exact converters to be quickly selected. This class is threadsafe because it is (essentially) immutable.
Since:
1.0
  • Field Details

  • Constructor Details

    • ConverterSet

      ConverterSet(Converter[] converters)
  • Method Details

    • select

      Converter select(Class<?> type) throws IllegalStateException
      Returns the closest matching converter for the given type, or null if none found.
      Parameters:
      type - type to select, which may be null
      Throws:
      IllegalStateException - if multiple converters match the type equally well
    • size

      int size()
      Returns the amount of converters in the set.
    • copyInto

      void copyInto(Converter[] converters)
      Copies all the converters in the set to the given array.
    • add

      ConverterSet add(Converter converter, Converter[] removed)
      Returns a copy of this set, with the given converter added. If a matching converter is already in the set, the given converter replaces it. If the converter is exactly the same as one already in the set, the original set is returned.
      Parameters:
      converter - converter to add, must not be null
      removed - if not null, element 0 is set to the removed converter
      Throws:
      NullPointerException - if converter is null
    • remove

      ConverterSet remove(Converter converter, Converter[] removed)
      Returns a copy of this set, with the given converter removed. If the converter was not in the set, the original set is returned.
      Parameters:
      converter - converter to remove, must not be null
      removed - if not null, element 0 is set to the removed converter
      Throws:
      NullPointerException - if converter is null
    • remove

      ConverterSet remove(int index, Converter[] removed)
      Returns a copy of this set, with the converter at the given index removed.
      Parameters:
      index - index of converter to remove
      removed - if not null, element 0 is set to the removed converter
      Throws:
      IndexOutOfBoundsException - if the index is invalid
    • selectSlow

      private static Converter selectSlow(ConverterSet set, Class<?> type)
      Returns the closest matching converter for the given type, but not very efficiently.