Model implements ToSmithyBuilder<Model> { public static Builder builder() { return new Builder(); } private  Model(Builder builder); static Builder builder(); static ModelAssembler assembler(); static ModelAssembler assembler(ClassLoader classLoader); Optional<Node> getMetadataProperty(String name); Map<String, Node> getMetadata(); Optional<TraitDefinition> getTraitDefinition(ToShapeId traitId); Set<Shape> getShapesWithTrait(ToShapeId trait); Set<ShapeId> getShapeIds(); Set<Shape> getShapesWithTrait(Class<? extends Trait> trait); Set<ShapeId> getAppliedTraits(); boolean isTraitApplied(Class<? extends Trait> trait); Optional<Shape> getShape(ShapeId id); Shape expectShape(ShapeId id); @SuppressWarnings("unchecked") T expectShape(ShapeId id, Class<T> type); Stream<Shape> shapes(); Stream<T> shapes(Class<T> shapeType); Set<Shape> toSet(); @Override boolean equals(Object other); @Override int hashCode(); @Override Builder toBuilder(); @Deprecated T getKnowledge(Class<T> type); @SuppressWarnings("unchecked") T getKnowledge(Class<T> type, Function<Model, T> constructor); static final String MODEL_VERSION; }
@Test public void modelEquality() { Model modelA = Model.builder() .putMetadataProperty("foo", Node.from("baz")) .addShape(StringShape.builder().id("ns.foo#baz").build()) .build(); Model modelB = Model.builder() .putMetadataProperty("foo", Node.from("baz")) .build(); assertThat(modelA, equalTo(modelA)); assertThat(modelA, not(equalTo(modelB))); assertThat(modelA, not(equalTo(null))); }
@Test public void comparesModel() { StringShape a = StringShape.builder().id("ns.foo#a").build(); StringShape b = StringShape.builder().id("ns.foo#b").build(); TimestampShape c = TimestampShape.builder().id("ns.foo#c").build(); Model modelA = Model.builder().addShapes(Arrays.asList(a, b, c)).build(); Model modelB = Model.builder().addShapes(modelA).build(); assertEquals(modelA, modelB); }