com.google.cloud.dataflow.sdk.coders

## Class InstantCoder

- java.lang.Object
- - com.google.cloud.dataflow.sdk.coders.StandardCoder<T>
  - - com.google.cloud.dataflow.sdk.coders.DeterministicStandardCoder<T>
    - - com.google.cloud.dataflow.sdk.coders.AtomicCoder<Instant>
      - - com.google.cloud.dataflow.sdk.coders.InstantCoder

All Implemented Interfaces:
  Coder<Instant>, Serializable

    public class InstantCoder
    extends AtomicCoder<Instant>

A `Coder` for joda `Instant` that encodes it as a big endian `Long` shifted such that lexicographic ordering of the bytes corresponds to chronological order.

See Also:
  Serialized Form

### Nested Class Summary

### Nested classes/interfaces inherited from interface com.google.cloud.dataflow.sdk.coders.Coder

`Coder.Context, Coder.NonDeterministicException`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`boolean` `consistentWithEquals()` Returns `true` if this `Coder` is injective with respect to `Object.equals(java.lang.Object)`.
`Instant` `decode(InputStream inStream, Coder.Context context)` Decodes a value of type `T` from the given input stream in the given context.
`void` `encode(Instant value, OutputStream outStream, Coder.Context context)` Encodes the given value of type `T` onto the given output stream in the given context.

`boolean`

`isRegisterByteSizeObserverCheap(Instant value, Coder.Context context)`
Returns whether `Coder.registerByteSizeObserver(T, com.google.cloud.dataflow.sdk.util.common.ElementByteSizeObserver, com.google.cloud.dataflow.sdk.coders.Coder.Context)` cheap enough to call for every element, that is, if this `Coder` can calculate the byte size of the element to be coded in roughly constant time (or lazily).

`static InstantCoder` `of()`
`void` `registerByteSizeObserver(Instant value, com.google.cloud.dataflow.sdk.util.common.ElementByteSizeObserver observer, Coder.Context context)` Notifies the `ElementByteSizeObserver` about the byte size of the encoded value using this `Coder`.

### Methods inherited from class com.google.cloud.dataflow.sdk.coders.AtomicCoder

`getCoderArguments, getInstanceComponents`

### Methods inherited from class com.google.cloud.dataflow.sdk.coders.DeterministicStandardCoder

`verifyDeterministic`

### Methods inherited from class com.google.cloud.dataflow.sdk.coders.StandardCoder

`asCloudObject, equals, getAllowedEncodings, getComponents, getEncodedElementByteSize, getEncodingId, hashCode, structuralValue, toString, verifyDeterministic, verifyDeterministic`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

### Method Detail

#### of

    public static InstantCoder of()

#### encode

    public void encode(Instant value,
                       OutputStream outStream,
                       Coder.Context context)
                throws CoderException,
                       IOException

Description copied from interface: `Coder`
Encodes the given value of type `T` onto the given output stream in the given context.

Throws:
  `CoderException` - if the value could not be encoded for some reason
  `IOException` - if writing to the `OutputStream` fails for some reason

#### decode

    public Instant decode(InputStream inStream,
                          Coder.Context context)
                   throws CoderException,
                          IOException

Description copied from interface: `Coder`
Decodes a value of type `T` from the given input stream in the given context. Returns the decoded value.

Throws:
  `CoderException` - if the value could not be decoded for some reason
  `IOException` - if reading from the `InputStream` fails for some reason

#### consistentWithEquals

    public boolean consistentWithEquals()

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.

Specified by:
  `consistentWithEquals` in interface `Coder<Instant>`
Overrides:
  `consistentWithEquals` in class `StandardCoder<Instant>`
Returns:
  `true`. This coder is injective.

#### isRegisterByteSizeObserverCheap

    public boolean isRegisterByteSizeObserverCheap(Instant value,
                                                   Coder.Context context)

Returns whether `Coder.registerByteSizeObserver(T, com.google.cloud.dataflow.sdk.util.common.ElementByteSizeObserver, com.google.cloud.dataflow.sdk.coders.Coder.Context)` cheap enough to call for every element, that is, if this `Coder` can calculate the byte size of the element to be coded in roughly constant time (or lazily).

Not intended to be called by user code, but instead by `PipelineRunner` implementations.

Specified by:
  `isRegisterByteSizeObserverCheap` in interface `Coder<Instant>`
Overrides:
  `isRegisterByteSizeObserverCheap` in class `StandardCoder<Instant>`
Returns:
  `true`. The byte size for a big endian long is a constant.

#### registerByteSizeObserver

    public void registerByteSizeObserver(Instant value,
                                         com.google.cloud.dataflow.sdk.util.common.ElementByteSizeObserver observer,
                                         Coder.Context context)
                                  throws Exception

Description copied from class: `StandardCoder`
Notifies the `ElementByteSizeObserver` about the byte size of the encoded value using this `Coder`.

Not intended to be called by user code, but instead by `PipelineRunner` implementations.

For `StandardCoder` subclasses, this notifies `observer` about the byte size of the encoded value using this coder as returned by `StandardCoder.getEncodedElementByteSize(T, com.google.cloud.dataflow.sdk.coders.Coder.Context)`.

Specified by:
  `registerByteSizeObserver` in interface `Coder<Instant>`
Overrides:
  `registerByteSizeObserver` in class `StandardCoder<Instant>`
Throws:
  `Exception`