public final class OperationIndex extends java.lang.Object implements KnowledgeIndex
This index performs no validation that the input, output, and errors actually reference valid structures. Such operation inputs, outputs, and errors may be discarded as if they do not exist.
Constructor and Description |
---|
OperationIndex(Model model) |
Modifier and Type | Method and Description |
---|---|
StructureShape |
expectInputShape(ToShapeId operation)
Gets the input shape of an operation, and returns Smithy's Unit type
trait if the operation has no meaningful input.
|
StructureShape |
expectOutputShape(ToShapeId operation)
Gets the output shape of an operation, and returns Smithy's unit type
trait if the operation has no meaningful output.
|
java.util.List<StructureShape> |
getErrors(ToShapeId operation)
Gets the list of error structures defined on an operation.
|
java.util.List<StructureShape> |
getErrors(ToShapeId service,
ToShapeId operation)
Gets the list of error structures defined on an operation,
including any common errors inherited from a service shape.
|
java.util.Optional<StructureShape> |
getInput(ToShapeId operation)
Gets the optional input structure of an operation, and returns an
empty optional if the input targets
smithy.api#Unit . |
java.util.Map<java.lang.String,MemberShape> |
getInputMembers(ToShapeId operation)
Gets the input members of an operation as a map of member names
to
MemberShape . |
java.util.Optional<StructureShape> |
getInputShape(ToShapeId operation)
Gets the optional input structure of an operation.
|
java.util.Optional<StructureShape> |
getOutput(ToShapeId operation)
Gets the optional output structure of an operation, and returns an
empty optional if the output targets
smithy.api#Unit . |
java.util.Map<java.lang.String,MemberShape> |
getOutputMembers(ToShapeId operation)
Gets the output members of an operation as a map of member names
to
MemberShape . |
java.util.Optional<StructureShape> |
getOutputShape(ToShapeId operation)
Gets the optional output structure of an operation.
|
boolean |
isInputStructure(ToShapeId structureId)
Returns true if the given structure is used as input by any
operation in the model or is marked with the input trait.
|
boolean |
isOutputStructure(ToShapeId structureId)
Returns true if the given structure is used as output by any
operation in the model or is marked with the output trait.
|
static OperationIndex |
of(Model model) |
public OperationIndex(Model model)
public static OperationIndex of(Model model)
public java.util.Optional<StructureShape> getInput(ToShapeId operation)
smithy.api#Unit
.operation
- Operation to get the input structure of.public java.util.Optional<StructureShape> getInputShape(ToShapeId operation)
Operations in the model always have input. This operation will only return an empty optional if the given operation shape cannot be found in the model or if it is not an operation shape.
operation
- Operation to get the input structure of.public StructureShape expectInputShape(ToShapeId operation)
In general, this method should be used instead of
getInputShape(ToShapeId)
when getting the input of operations
that are known to exist.
operation
- Operation to get the input of.ExpectationNotMetException
- if the operation shape cannot be found.public java.util.Map<java.lang.String,MemberShape> getInputMembers(ToShapeId operation)
MemberShape
.
The return map is ordered using the same order defined in the model. If the operation has no input, an empty map is returned.
operation
- Operation to get the input members of.public boolean isInputStructure(ToShapeId structureId)
structureId
- Structure to check.public java.util.Optional<StructureShape> getOutput(ToShapeId operation)
smithy.api#Unit
.operation
- Operation to get the output structure of.public java.util.Optional<StructureShape> getOutputShape(ToShapeId operation)
Operations in the model always have output. This operation will only return an empty optional if the given operation shape cannot be found in the model or if it is not an operation shape.
operation
- Operation to get the output structure of.public StructureShape expectOutputShape(ToShapeId operation)
In general, this method should be used instead of
getOutputShape(ToShapeId)
when getting the output of operations
that are known to exist.
operation
- Operation to get the output of.ExpectationNotMetException
- if the operation shape cannot be found.public java.util.Map<java.lang.String,MemberShape> getOutputMembers(ToShapeId operation)
MemberShape
.
The return map is ordered using the same order defined in the model. If the operation has no output, an empty map is returned.
operation
- Operation to get the output members of.public boolean isOutputStructure(ToShapeId structureId)
structureId
- Structure to check.public java.util.List<StructureShape> getErrors(ToShapeId operation)
An empty list is returned if the operation is not found or has no errors.
operation
- Operation to get the errors of.to get errors that inherit from a service.
public java.util.List<StructureShape> getErrors(ToShapeId service, ToShapeId operation)
An empty list is returned if the operation is not found or has no errors.
service
- Service shape to inherit common errors from.operation
- Operation to get the errors of.