Package software.amazon.awssdk.core
Class SdkField<TypeT>
java.lang.Object
software.amazon.awssdk.core.SdkField<TypeT>
- Type Parameters:
TypeT
- Java Type of member.
Metadata about a member in an
SdkPojo
. Contains information about how to marshall/unmarshall.-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <TypeT> SdkField.Builder
<TypeT> builder
(MarshallingType<? super TypeT> marshallingType) Creates a new instance ofSdkField.Builder
bound to the specified type.boolean
containsTrait
(Class<? extends Trait> clzz) Checks if a givenTrait
is present on the field.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>
TGets the trait of the specified class if available.getValueOrDefault
(Object pojo) Retrieves the current value of 'this' field from the given POJO.location()
MarshallingType
<? super TypeT> void
Sets the given value on the POJO via the setter passed into theSdkField.Builder
.
-
Method Details
-
memberName
-
marshallingType
- Returns:
- MarshallingType of member. Used primarily for marshaller/unmarshaller lookups.
-
location
- Returns:
- Location the member should be marshalled into (i.e. headers/query/path/payload).
-
locationName
- Returns:
- The location name to use when marshalling. I.E. the field name of the JSON document, or the header name, etc.
-
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.
-
constructor
-
getTrait
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
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
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
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
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
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.
-