Class SdkField<TypeT>

  • Type Parameters:
    TypeT - Java Type of member.

    public final class SdkField<TypeT>
    extends Object
    Metadata about a member in an SdkPojo. Contains information about how to marshall/unmarshall.
    • Method Detail

      • memberName

        public String memberName()
      • marshallingType

        public MarshallingType<? super TypeT> marshallingType()
        Returns:
        MarshallingType of member. Used primarily for marshaller/unmarshaller lookups.
      • location

        public MarshallLocation location()
        Returns:
        Location the member should be marshalled into (i.e. headers/query/path/payload).
      • locationName

        public String locationName()
        Returns:
        The location name to use when marshalling. I.E. the field name of the JSON document, or the header name, etc.
      • unmarshallLocationName

        public String unmarshallLocationName()
        Returns:
        The location name to use when unmarshalling. This is only needed for AWS/Query or EC2 services. All other services should use locationName for both marshalling and unmarshalling.
      • getTrait

        public <T extends Trait> T getTrait​(Class<T> clzz)
        Gets the trait of the specified class if available.
        Type Parameters:
        T - Type of trait.
        Parameters:
        clzz - Trait class to get.
        Returns:
        Trait instance or null if trait is not present.
      • getOptionalTrait

        public <T extends TraitOptional<T> getOptionalTrait​(Class<T> clzz)
        Gets the trait of the specified class if available.
        Type Parameters:
        T - Type of trait.
        Parameters:
        clzz - Trait class to get.
        Returns:
        Optional of trait instance.
      • containsTrait

        public boolean containsTrait​(Class<? extends Trait> clzz)
        Checks if a given Trait is present on the field.
        Parameters:
        clzz - Trait class to check.
        Returns:
        True if trait is present, false if not.
      • getValueOrDefault

        public TypeT getValueOrDefault​(Object pojo)
        Retrieves the current value of 'this' field from the given POJO. Uses the getter passed into the SdkField.Builder. If the current value is null this method will look for the DefaultValueTrait on the field and attempt to resolve a default value. If the DefaultValueTrait is not present this just returns null.
        Parameters:
        pojo - POJO to retrieve value from.
        Returns:
        Current value of 'this' field in the POJO or default value if current value is null.
      • set

        public void set​(Object pojo,
                        Object val)
        Sets the given value on the POJO via the setter passed into the SdkField.Builder.
        Parameters:
        pojo - POJO containing field to set.
        val - Value of field.
      • builder

        public static <TypeT> SdkField.Builder<TypeT> builder​(MarshallingType<? super TypeT> marshallingType)
        Creates a new instance of SdkField.Builder bound to the specified type.
        Type Parameters:
        TypeT - Type of field. Must be a subtype of the MarshallingType type param.
        Parameters:
        marshallingType - Type of field.
        Returns:
        New builder instance.