Class FieldWithDefault<T>
java.lang.Object
software.amazon.awssdk.services.s3.internal.FieldWithDefault<T>
A helper class for setting a field's value to a default if it isn't specified, while still keeping track of whether the value
was from the default or from the field.
For example, a "profile name" field-with-default might be set to "null" with a default of "foo".
value() returns
"foo", while isDefault() can be used to keep track of the fact that the value was from the default.-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> FieldWithDefault<T> create(T field, T defaultValue) Create aFieldWithDefaultusing the provided field and its default value.static <T> FieldWithDefault<T> createLazy(T field, Supplier<T> defaultValue) Create aFieldWithDefaultusing the provided field and its default value.abstract booleanTrue, if the value returned byvalue()is the default value (i.e.abstract Tvalue()Retrieve the value of this field.abstract TReturn the field exactly as it was specified when the field-with-default was created.
-
Method Details
-
create
Create aFieldWithDefaultusing the provided field and its default value. If the field is null, the default value will be returned byvalue()andisDefault()will return true. If the field is not null, the field value will be returned byvalue()andisDefault()will return false.- See Also:
-
createLazy
Create aFieldWithDefaultusing the provided field and its default value. If the field is null, the default value will be returned byvalue()andisDefault()will return true. If the field is not null, the field value will be returned byvalue()andisDefault()will return false.This differs from
create(Object, Object)in that the default value won't be resolved if the provided field is not null. The default value also won't be resolved until the firstvalue()call. This is useful for delaying expensive calculations until right before they're needed. -
value
Retrieve the value of this field. -
isDefault
public abstract boolean isDefault()True, if the value returned byvalue()is the default value (i.e. the field is null). False otherwise. -
valueOrNullIfDefault
Return the field exactly as it was specified when the field-with-default was created. If the field was null, this will return null. This will not resolve the default if this is a field fromcreateLazy(Object, Supplier).
-