Class NullableIndex
- java.lang.Object
-
- software.amazon.smithy.model.knowledge.NullableIndex
-
- All Implemented Interfaces:
KnowledgeIndex
- Direct Known Subclasses:
BoxIndex
public class NullableIndex extends java.lang.Object implements KnowledgeIndex
An index that checks if a member is nullable.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classNullableIndex.CheckModeDefines the type of model consumer to assume when determining if a member should be considered nullable or always present.
-
Constructor Summary
Constructors Constructor Description NullableIndex(Model model)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleanisMemberNullable(MemberShape member)Checks if a member is nullable usingNullableIndex.CheckMode.CLIENT.booleanisMemberNullable(MemberShape member, NullableIndex.CheckMode checkMode)Checks if a member is nullable using v2 nullability rules.booleanisNullable(ToShapeId shapeId)Deprecated.static NullableIndexof(Model model)
-
-
-
Constructor Detail
-
NullableIndex
public NullableIndex(Model model)
-
-
Method Detail
-
of
public static NullableIndex of(Model model)
-
isMemberNullable
public boolean isMemberNullable(MemberShape member)
Checks if a member is nullable usingNullableIndex.CheckMode.CLIENT.- Parameters:
member- Member to check.- Returns:
- Returns true if the member is optional in non-authoritative consumers of the model like clients.
- See Also:
isMemberNullable(MemberShape, CheckMode)
-
isMemberNullable
public boolean isMemberNullable(MemberShape member, NullableIndex.CheckMode checkMode)
Checks if a member is nullable using v2 nullability rules.A
checkModeparameter 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 theInputTraitorClientOptionalTrait, while non-authoritative consumers like clients must honor these traits.- Parameters:
member- Member to check.checkMode- The mode used when checking if the member is considered nullable.- Returns:
- Returns true if the member is optional.
-
isNullable
@Deprecated public final boolean isNullable(ToShapeId shapeId)
Deprecated.Checks if the given shape is optional using Smithy IDL 1.0 semantics.This means that the default trait is ignored, the required trait is ignored, and only the box trait and sparse traits are used.
Use
isMemberNullable(MemberShape)to check using Smithy IDL 2.0 semantics that take required, default, and other traits into account. That method also accurately returns the nullability of 1.0 members as long as the model it's checking was sent through a ModelAssembler.- Parameters:
shapeId- Shape or shape ID to check.- Returns:
- Returns true if the shape is nullable.
-
-