Class ListCoder<T>

  • Type Parameters:
    T - the type of the elements of the Lists being transcoded
    All Implemented Interfaces:
    java.io.Serializable

    public class ListCoder<T>
    extends IterableLikeCoder<T,​java.util.List<T>>
    A Coder for List, using the format of IterableLikeCoder.
    See Also:
    Serialized Form
    • Constructor Detail

      • ListCoder

        protected ListCoder​(Coder<T> elemCoder)
    • Method Detail

      • consistentWithEquals

        public boolean consistentWithEquals()
        Description copied from class: Coder
        Returns true if this Coder is injective with respect to Object.equals(java.lang.Object).

        Whenever the encoded bytes of two values are equal, then the original values are equal according to Objects.equals(). Note that this is well-defined for null.

        This condition is most notably false for arrays. More generally, this condition is false whenever equals() compares object identity, rather than performing a semantic/structural comparison.

        By default, returns false.

        Overrides:
        consistentWithEquals in class Coder<java.util.List<T>>
      • structuralValue

        public java.lang.Object structuralValue​(java.util.List<T> values)
        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<java.util.List<T>>
      • verifyDeterministic

        public void verifyDeterministic()
                                 throws Coder.NonDeterministicException
        List sizes are always known, so ListIterable may be deterministic while the general IterableLikeCoder is not.
        Overrides:
        verifyDeterministic in class IterableLikeCoder<T,​java.util.List<T>>
        Throws:
        Coder.NonDeterministicException - always. Encoding is not deterministic for the general Iterable case, as it depends upon the type of iterable. This may allow two objects to compare as equal while the encoding differs.