Package software.amazon.awssdk.core
Class SdkField<TypeT>
- java.lang.Object
-
- software.amazon.awssdk.core.SdkField<TypeT>
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SdkField.Builder<TypeT>
Builder forSdkField
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <TypeT> SdkField.Builder<TypeT>
builder(MarshallingType<? super TypeT> marshallingType)
Creates a new instance ofSdkField.Builder
bound to the specified type.Supplier<SdkPojo>
constructor()
boolean
containsTrait(Class<? extends Trait> clzz)
Checks if a givenTrait
is present on the field.<T extends Trait>
Optional<T>getOptionalTrait(Class<T> clzz)
Gets the trait of the specified class if available.<T extends Trait>
TgetRequiredTrait(Class<T> clzz)
Gets the trait of the specified class, or throwIllegalStateException
if not available.<T extends Trait>
TgetTrait(Class<T> clzz)
Gets the trait of the specified class if available.TypeT
getValueOrDefault(Object pojo)
Retrieves the current value of 'this' field from the given POJO.MarshallLocation
location()
String
locationName()
MarshallingType<? super TypeT>
marshallingType()
String
memberName()
void
set(Object pojo, Object val)
Sets the given value on the POJO via the setter passed into theSdkField.Builder
.String
unmarshallLocationName()
-
-
-
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 Trait> Optional<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.
-
getRequiredTrait
public <T extends Trait> T getRequiredTrait(Class<T> clzz) throws IllegalStateException
Gets the trait of the specified class, or throwIllegalStateException
if not available.- Type Parameters:
T
- Type of trait.- Parameters:
clzz
- Trait class to get.- Returns:
- Trait instance.
- Throws:
IllegalStateException
- if trait is not present.
-
containsTrait
public boolean containsTrait(Class<? extends Trait> clzz)
Checks if a givenTrait
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 theSdkField.Builder
. If the current value is null this method will look for theDefaultValueTrait
on the field and attempt to resolve a default value. If theDefaultValueTrait
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 theSdkField.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 ofSdkField.Builder
bound to the specified type.- Type Parameters:
TypeT
- Type of field. Must be a subtype of theMarshallingType
type param.- Parameters:
marshallingType
- Type of field.- Returns:
- New builder instance.
-
-