public class NullableIndex extends java.lang.Object implements KnowledgeIndex
| Modifier and Type | Class and Description |
|---|---|
static class |
NullableIndex.CheckMode
Defines the type of model consumer to assume when determining if
a member should be considered nullable or always present.
|
| Constructor and Description |
|---|
NullableIndex(Model model) |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
isDefaultZeroValueOfTypeInV1(Node defaultValue,
ShapeType targetType)
Detects if the given node value equals the default value of the given shape type
based on Smithy 1.0 semantics.
|
boolean |
isMemberNullable(MemberShape member)
Checks if a member is nullable using
NullableIndex.CheckMode.CLIENT. |
boolean |
isMemberNullable(MemberShape member,
NullableIndex.CheckMode checkMode)
Checks if a member is nullable using v2 nullability rules.
|
boolean |
isNullable(ToShapeId shapeId)
Deprecated.
|
static boolean |
isShapeSetToDefaultZeroValueInV1(MemberShape member,
Shape target)
Detects if the given member is configured to use the zero value for the target shape
using Smithy 1.0 semantics (that is, it targets a number shape other than bigInteger
or bigDecimal and set to 0; or it targets a boolean shape and is set to false).
|
static NullableIndex |
of(Model model) |
public NullableIndex(Model model)
public static NullableIndex of(Model model)
public boolean isMemberNullable(MemberShape member)
NullableIndex.CheckMode.CLIENT.member - Member to check.isMemberNullable(MemberShape, CheckMode)public boolean isMemberNullable(MemberShape member, NullableIndex.CheckMode checkMode)
A checkMode parameter is required to declare what kind of
model consumer is checking if the member is optional. The authoritative
consumers like servers do not need to honor the InputTrait or
ClientOptionalTrait, while non-authoritative consumers like clients
must honor these traits.
member - Member to check.checkMode - The mode used when checking if the member is considered nullable.@Deprecated public final boolean isNullable(ToShapeId shapeId)
This method does not return the same values that are returned by
isMemberNullable(MemberShape). This method uses 1.0 model
semantics and attempts to detect when a model has been passed though
model assembler upgrades to provide the most accurate v1 nullability
result.
Use isMemberNullable(MemberShape) to check using Smithy
IDL 2.0 semantics that take required, default, and other traits
into account with no special 1.0 handling.
shapeId - Shape or shape ID to check.public static boolean isShapeSetToDefaultZeroValueInV1(MemberShape member, Shape target)
member - Member to check.target - Shape target to check.public static boolean isDefaultZeroValueOfTypeInV1(Node defaultValue, ShapeType targetType)
defaultValue - Value to check.targetType - Shape type to check against.