Interface KnowledgeIndex

All Known Implementing Classes:
ArnIndex, AuthorizerIndex, AwsTagIndex, BottomUpIndex, BoxIndex, CfnResourceIndex, ClientEndpointDiscoveryIndex, ConditionKeysIndex, ContextIndex, EventStreamIndex, HttpBindingIndex, IdentifierBindingIndex, IntegrationTraitIndex, NeighborProviderIndex, NullableIndex, OperationIndex, PaginatedIndex, PlaneIndex, PropertyBindingIndex, ResolvedTopicIndex, ServiceIndex, TextIndex, TopDownIndex, TopologicalIndex

public interface KnowledgeIndex
A marker interface used to indicate that a class contains an index of computed knowledge about a Model.

The purpose of a KnowledgeIndex is to reduce code duplication and complexity of extracting and computing information about a model. A KnowledgeIndex is often a mapping of ShapeId to some kind of interesting computed information. For example, in order to resolve the input/output/error structures referenced by an OperationShape, you need a Model, to ensure that the reference from the operation to the structure is resolvable in the model, that the shape it references is a structure, and then to cast the shape to a StructureShape. Because this process can be complex and is required by a large number of validators and tools, Smithy provides an OperationIndex to compute it automatically.

By convention, each KnowledgeIndex should provide a public static method named of that accepts a Model and returns an instance of the KnowledgeIndex. The of method should invoke the Model.getKnowledge(Class, Function) method to ensure that the index is only computed once per model. Because they are cached and can be used across threads, a KnowledgeIndex must be thread safe.

The following example demonstrates a standard KnowledgeIndex implementation:


 public final class MyIndex implements KnowledgeIndex {
     public MyIndex(Model model) {
         // implement the code used to create the index.
     }

     public static MyIndex of(Model model) {
         return model.getKnowledge(MyIndex.class, MyIndex::new);
     }

     // Implement methods used to query the knowledge index.
 }