Class IterableCoder<T>

Type Parameters:
T - the type of the elements of the iterables being transcoded
All Implemented Interfaces:
Serializable

public class IterableCoder<T> extends IterableLikeCoder<T,Iterable<T>>
An IterableCoder encodes any Iterable in the format of IterableLikeCoder.
See Also:
  • Constructor Details

    • IterableCoder

      protected IterableCoder(Coder<T> elemCoder)
  • Method Details

    • of

      public static <T> IterableCoder<T> of(Coder<T> elemCoder)
    • structuralValue

      public Object structuralValue(Iterable<T> value)
      Description copied from class: Coder
      Returns an object with an Object.equals() method that represents structural equality on the argument.

      For any two values x and y of type T, if their encoded bytes are the same, then it must be the case that structuralValue(x).equals(structuralValue(y)).

      Most notably:

      • The structural value for an array coder should perform a structural comparison of the contents of the arrays, rather than the default behavior of comparing according to object identity.
      • The structural value for a coder accepting null should be a proper object with an equals() method, even if the input value is null.

      See also Coder.consistentWithEquals().

      By default, if this coder is Coder.consistentWithEquals(), and the value is not null, returns the provided object. Otherwise, encodes the value into a byte[], and returns an object that performs array equality on the encoded bytes.

      Overrides:
      structuralValue in class Coder<Iterable<T>>
    • decodeToIterable

      protected final Iterable<T> decodeToIterable(List<T> decodedElements)
      Description copied from class: IterableLikeCoder
      Builds an instance of IterableT, this coder's associated Iterable-like subtype, from a list of decoded elements.

      Override IterableLikeCoder.decodeToIterable(List, long, InputStream) if you need access to the terminator value and the InputStream.

      Specified by:
      decodeToIterable in class IterableLikeCoder<T,Iterable<T>>
    • getEncodedTypeDescriptor

      public TypeDescriptor<Iterable<T>> getEncodedTypeDescriptor()
      Description copied from class: Coder
      Returns the TypeDescriptor for the type encoded.
      Overrides:
      getEncodedTypeDescriptor in class Coder<Iterable<T>>