public static enum ThriftField.Requiredness extends Enum<ThriftField.Requiredness>
| Enum Constant and Description |
|---|
NONE
This behavior is equivalent to leaving out 'optional' and 'required' in thrift IDL
syntax.
|
OPTIONAL
This behavior indicates that it is always ok if the field is
null when serializing,
and that it is always ok to not read a value (and the field will be set to null
when this happens). |
REQUIRED
This behavior indicates that the field will always be serialized (and it is an error if the
value is
null), and must always be deserialized (and it is an error if a value
is not read). |
UNSPECIFIED
This is the default (unset) value for
ThriftField.requiredness(). |
| Modifier and Type | Method and Description |
|---|---|
static ThriftField.Requiredness |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static ThriftField.Requiredness[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final ThriftField.Requiredness UNSPECIFIED
ThriftField.requiredness(). It will not
conflict with other explicit settings of NONE, REQUIRED, or OPTIONAL. If all of the ThriftField annotations for
a field are left UNSPECIFIED, it will default to NONE.public static final ThriftField.Requiredness NONE
OPTIONAL or REQUIRED for the same
field.
The serialization behavior is that null values will not be serialized, but
if the field is non-nullable (i.e. it's type is primitive) it will be serialized, even
if the field was not explicitly set.
The deserialization behavior is similar: When no value is read, the field will be set
to null if the type of the field is nullable, but for primitive types the
field will be left untouched (so it will hold the default value for the type).
public static final ThriftField.Requiredness REQUIRED
null), and must always be deserialized (and it is an error if a value
is not read).public static final ThriftField.Requiredness OPTIONAL
null when serializing,
and that it is always ok to not read a value (and the field will be set to null
when this happens). As such, primitive types should be replaced with boxed types, so that
null is always a possibility.public static ThriftField.Requiredness[] values()
for (ThriftField.Requiredness c : ThriftField.Requiredness.values()) System.out.println(c);
public static ThriftField.Requiredness valueOf(String name)
name - the name of the enum constant to be returned.IllegalArgumentException - if this enum type has no constant with the specified nameNullPointerException - if the argument is nullCopyright © 2012–2023. All rights reserved.