Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move getType of shape to subclass method #1028

Merged
merged 1 commit into from
Dec 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ public Optional<BigDecimalShape> asBigDecimalShape() {
return Optional.of(this);
}

@Override
public ShapeType getType() {
return ShapeType.BIG_DECIMAL;
}

/**
* Builder used to create a {@link BigDecimalShape}.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ public Optional<BigIntegerShape> asBigIntegerShape() {
return Optional.of(this);
}

@Override
public ShapeType getType() {
return ShapeType.BIG_INTEGER;
}

/**
* Builder used to create a {@link BigIntegerShape}.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ public Optional<BlobShape> asBlobShape() {
return Optional.of(this);
}

@Override
public ShapeType getType() {
return ShapeType.BLOB;
}

/**
* Builder used to create a {@link BlobShape}.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ public Optional<BooleanShape> asBooleanShape() {
return Optional.of(this);
}

@Override
public ShapeType getType() {
return ShapeType.BOOLEAN;
}

/**
* Builder used to create a {@link BooleanShape}.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ public Optional<ByteShape> asByteShape() {
return Optional.of(this);
}

@Override
public ShapeType getType() {
return ShapeType.BYTE;
}

/**
* Builder used to create a {@link ByteShape}.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ public Optional<DocumentShape> asDocumentShape() {
return Optional.of(this);
}

@Override
public ShapeType getType() {
return ShapeType.DOCUMENT;
}

/**
* Builder used to create a {@link DocumentShape}.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ public Optional<DoubleShape> asDoubleShape() {
return Optional.of(this);
}

@Override
public ShapeType getType() {
return ShapeType.DOUBLE;
}

/**
* Builder used to create a {@link DoubleShape}.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ public Optional<FloatShape> asFloatShape() {
return Optional.of(this);
}

@Override
public ShapeType getType() {
return ShapeType.FLOAT;
}

/**
* Builder used to create a {@link FloatShape}.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ public Optional<IntegerShape> asIntegerShape() {
return Optional.of(this);
}

@Override
public ShapeType getType() {
return ShapeType.INTEGER;
}

/**
* Builder used to create a {@link IntegerShape}.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ public Optional<ListShape> asListShape() {
return Optional.of(this);
}

@Override
public ShapeType getType() {
return ShapeType.LIST;
}

/**
* Builder used to create a {@link ListShape}.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ public Optional<LongShape> asLongShape() {
return Optional.of(this);
}

@Override
public ShapeType getType() {
return ShapeType.LONG;
}

/**
* Builder used to create a {@link LongShape}.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ public Optional<MapShape> asMapShape() {
return Optional.of(this);
}

@Override
public ShapeType getType() {
return ShapeType.MAP;
}

/**
* Get the value member shape of the map.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ public Optional<MemberShape> asMemberShape() {
return Optional.of(this);
}

@Override
public ShapeType getType() {
return ShapeType.MEMBER;
}

/**
* Get the targeted member shape ID.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ public Optional<OperationShape> asOperationShape() {
return Optional.of(this);
}

@Override
public ShapeType getType() {
return ShapeType.OPERATION;
}

/**
* <p>Gets the optional shape ID of the input of the operation.</p>
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ public Set<ShapeId> getAllOperations() {
return Collections.unmodifiableSet(allOperations);
}

@Override
public ShapeType getType() {
return ShapeType.RESOURCE;
}

/**
* Gets the operations bound through the "collectionOperations" property.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ public boolean equals(Object other) {
&& errors.equals(o.errors);
}

@Override
public ShapeType getType() {
return ShapeType.SERVICE;
}

/**
* Get the version of the service. An empty string is returned
* if the version is undefined.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ public Optional<SetShape> asSetShape() {
return Optional.of(this);
}

@Override
public ShapeType getType() {
return ShapeType.SET;
}

/**
* Builder used to create a {@link SetShape}.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public abstract class Shape implements FromSourceLocation, Tagged, ToShapeId, Co
private final ShapeId id;
private final Map<ShapeId, Trait> traits;
private final transient SourceLocation source;
private final transient ShapeType type;

/**
* This class is package-private, which means that all subclasses of this
Expand All @@ -58,7 +57,6 @@ public abstract class Shape implements FromSourceLocation, Tagged, ToShapeId, Co
*/
@SuppressWarnings("unchecked")
Shape(AbstractShapeBuilder builder, boolean expectMemberSegments) {
type = builder.getShapeType();
source = builder.getSourceLocation();
id = SmithyBuilder.requiredState("id", builder.getId());
traits = builder.copyTraits();
Expand Down Expand Up @@ -103,9 +101,7 @@ public static <B extends AbstractShapeBuilder<B, S>, S extends Shape> B shapeToB
*
* @return Returns the type;
*/
public final ShapeType getType() {
return type;
}
public abstract ShapeType getType();

/**
* Dispatches the shape to the appropriate {@link ShapeVisitor} method.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ public Optional<ShortShape> asShortShape() {
return Optional.of(this);
}

@Override
public ShapeType getType() {
return ShapeType.SHORT;
}

/**
* Builder used to create a {@link ShortShape}.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ public Optional<StringShape> asStringShape() {
return Optional.of(this);
}

@Override
public ShapeType getType() {
return ShapeType.STRING;
}

/**
* Builder used to create a {@link StringShape}.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ public Optional<StructureShape> asStructureShape() {
return Optional.of(this);
}

@Override
public ShapeType getType() {
return ShapeType.STRUCTURE;
}

/**
* Builder used to create a {@link StructureShape}.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ public Optional<TimestampShape> asTimestampShape() {
return Optional.of(this);
}

@Override
public ShapeType getType() {
return ShapeType.TIMESTAMP;
}

/**
* Builder used to create a {@link TimestampShape}.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ public Optional<UnionShape> asUnionShape() {
return Optional.of(this);
}

@Override
public ShapeType getType() {
return ShapeType.UNION;
}

/**
* Builder used to create a {@link UnionShape}.
*/
Expand Down