Class CloudObject

java.lang.Object
java.util.AbstractMap<String,Object>
com.google.api.client.util.GenericData
com.google.api.client.json.GenericJson
org.apache.beam.runners.dataflow.util.CloudObject
All Implemented Interfaces:
Cloneable, Map<String,Object>

public final class CloudObject extends com.google.api.client.json.GenericJson implements Cloneable
A representation of an arbitrary Java object to be instantiated by Dataflow workers.

Typically, an object to be written by the SDK to the Dataflow service will implement a method (typically called asCloudObject()) that returns a CloudObject to represent the object in the protocol. Once the CloudObject is constructed, the method should explicitly add additional properties to be presented during deserialization, representing child objects by building additional CloudObjects.

  • Method Details

    • fromSpec

      public static CloudObject fromSpec(Map<String,Object> spec)
      Constructs a CloudObject by copying the supplied serialized object spec, which must represent an SDK object serialized for transport via the Dataflow API.

      The most common use of this method is during deserialization on the worker, where it's used as a binding type during instance construction.

      Parameters:
      spec - supplies the serialized form of the object as a nested map
      Throws:
      RuntimeException - if the supplied map does not represent an SDK object
    • forClass

      public static CloudObject forClass(Class<?> cls)
      Constructs a CloudObject to be used for serializing an instance of the supplied class for transport via the Dataflow API. The instance parameters to be serialized must be supplied explicitly after the CloudObject is created, by using GenericData.put(java.lang.String, java.lang.Object).
      Parameters:
      cls - the class to use when deserializing the object on the worker
    • forClassName

      public static CloudObject forClassName(String className)
      Constructs a CloudObject to be used for serializing data to be deserialized using the supplied class name the supplied class name for transport via the Dataflow API. The instance parameters to be serialized must be supplied explicitly after the CloudObject is created, by using GenericData.put(java.lang.String, java.lang.Object).
      Parameters:
      className - the class to use when deserializing the object on the worker
    • forString

      public static CloudObject forString(String value)
      Constructs a CloudObject representing the given value.
      Parameters:
      value - the scalar value to represent.
    • forBoolean

      public static CloudObject forBoolean(Boolean value)
      Constructs a CloudObject representing the given value.
      Parameters:
      value - the scalar value to represent.
    • forInteger

      public static CloudObject forInteger(Long value)
      Constructs a CloudObject representing the given value.
      Parameters:
      value - the scalar value to represent.
    • forInteger

      public static CloudObject forInteger(Integer value)
      Constructs a CloudObject representing the given value.
      Parameters:
      value - the scalar value to represent.
    • forFloat

      public static CloudObject forFloat(Float value)
      Constructs a CloudObject representing the given value.
      Parameters:
      value - the scalar value to represent.
    • forFloat

      public static CloudObject forFloat(Double value)
      Constructs a CloudObject representing the given value.
      Parameters:
      value - the scalar value to represent.
    • forKnownType

      public static CloudObject forKnownType(Object value)
      Constructs a CloudObject representing the given value of a well-known cloud object type.
      Parameters:
      value - the scalar value to represent.
      Throws:
      RuntimeException - if the value does not have a CloudKnownType mapping
    • getClassName

      public String getClassName()
      Gets the name of the Java class that this CloudObject represents.
    • clone

      public CloudObject clone()
      Overrides:
      clone in class com.google.api.client.json.GenericJson
    • equals

      public boolean equals(@Nullable Object otherObject)
      Specified by:
      equals in interface Map<String,Object>
      Overrides:
      equals in class com.google.api.client.util.GenericData
    • hashCode

      public int hashCode()
      Specified by:
      hashCode in interface Map<String,Object>
      Overrides:
      hashCode in class com.google.api.client.util.GenericData