Skip to content

Commit

Permalink
Return Builders instead of SmithyBuilders
Browse files Browse the repository at this point in the history
This commit updates all instances where a generic SmithyBuilder<> was
returned to return the specific implementing Builder. This means users
of these methods can easily use the Builder's functionality without
using a cast.
  • Loading branch information
kstich committed Oct 30, 2024
1 parent 34d2396 commit 2fa7c05
Show file tree
Hide file tree
Showing 23 changed files with 23 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import software.amazon.smithy.model.traits.AbstractTraitBuilder;
import software.amazon.smithy.model.traits.Trait;
import software.amazon.smithy.utils.ListUtils;
import software.amazon.smithy.utils.SmithyBuilder;
import software.amazon.smithy.utils.ToSmithyBuilder;

/**
Expand Down Expand Up @@ -75,7 +74,7 @@ protected Node createNode() {
}

@Override
public SmithyBuilder<CfnResourceTrait> toBuilder() {
public Builder toBuilder() {
return builder().sourceLocation(getSourceLocation()).name(name).additionalSchemas(additionalSchemas);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public Node toNode() {
}

@Override
public SmithyBuilder<Handler> toBuilder() {
public Builder toBuilder() {
return builder()
.permissions(permissions);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public Node toNode() {
}

@Override
public SmithyBuilder<Property> toBuilder() {
public Builder toBuilder() {
return builder()
.insertionOrder(insertionOrder)
.dependencies(dependencies)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import software.amazon.smithy.rulesengine.language.RulesComponentBuilder;
import software.amazon.smithy.utils.BuilderRef;
import software.amazon.smithy.utils.ListUtils;
import software.amazon.smithy.utils.SmithyBuilder;
import software.amazon.smithy.utils.SmithyUnstableApi;
import software.amazon.smithy.utils.ToSmithyBuilder;

Expand Down Expand Up @@ -117,7 +116,7 @@ public SourceLocation getSourceLocation() {
}

@Override
public SmithyBuilder<Partition> toBuilder() {
public Builder toBuilder() {
return new Builder(getSourceLocation())
.id(id)
.regionRegex(regionRegex)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import software.amazon.smithy.model.node.ToNode;
import software.amazon.smithy.rulesengine.language.RulesComponentBuilder;
import software.amazon.smithy.utils.ListUtils;
import software.amazon.smithy.utils.SmithyBuilder;
import software.amazon.smithy.utils.SmithyUnstableApi;
import software.amazon.smithy.utils.ToSmithyBuilder;

Expand Down Expand Up @@ -142,7 +141,7 @@ public SourceLocation getSourceLocation() {
}

@Override
public SmithyBuilder<PartitionOutputs> toBuilder() {
public Builder toBuilder() {
return new Builder(getSourceLocation())
.name(name)
.dnsSuffix(dnsSuffix)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import software.amazon.smithy.model.node.Node;
import software.amazon.smithy.model.node.ToNode;
import software.amazon.smithy.rulesengine.language.RulesComponentBuilder;
import software.amazon.smithy.utils.SmithyBuilder;
import software.amazon.smithy.utils.SmithyUnstableApi;
import software.amazon.smithy.utils.ToSmithyBuilder;

Expand Down Expand Up @@ -54,7 +53,7 @@ public SourceLocation getSourceLocation() {
}

@Override
public SmithyBuilder<RegionOverride> toBuilder() {
public Builder toBuilder() {
return new Builder(getSourceLocation());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public Node toNode() {
}

@Override
public SmithyBuilder<PartitionEndpointSpecialCase> toBuilder() {
public Builder toBuilder() {
return new Builder()
.endpoint(endpoint)
.region(region)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public Node toNode() {
}

@Override
public SmithyBuilder<PartitionSpecialCase> toBuilder() {
public Builder toBuilder() {
return new Builder()
.dualStack(dualStack)
.endpoint(endpoint)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public Node toNode() {
}

@Override
public SmithyBuilder<RegionSpecialCase> toBuilder() {
public Builder toBuilder() {
return new Builder()
.dualStack(dualStack)
.endpoint(endpoint)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import software.amazon.smithy.model.traits.AbstractTraitBuilder;
import software.amazon.smithy.model.traits.Trait;
import software.amazon.smithy.utils.BuilderRef;
import software.amazon.smithy.utils.SmithyBuilder;
import software.amazon.smithy.utils.ToSmithyBuilder;

/**
Expand Down Expand Up @@ -78,7 +77,7 @@ protected Node createNode() {
}

@Override
public SmithyBuilder<StandardPartitionalEndpointsTrait> toBuilder() {
public Builder toBuilder() {
return new Builder()
.partitionEndpointSpecialCases(partitionEndpointSpecialCases)
.endpointPatternType(endpointPatternType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import software.amazon.smithy.model.traits.AbstractTraitBuilder;
import software.amazon.smithy.model.traits.Trait;
import software.amazon.smithy.utils.BuilderRef;
import software.amazon.smithy.utils.SmithyBuilder;
import software.amazon.smithy.utils.ToSmithyBuilder;

/**
Expand Down Expand Up @@ -84,7 +83,7 @@ protected Node createNode() {
}

@Override
public SmithyBuilder<StandardRegionalEndpointsTrait> toBuilder() {
public Builder toBuilder() {
return new Builder()
.partitionSpecialCases(partitionSpecialCases)
.regionSpecialCases(regionSpecialCases);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import software.amazon.smithy.model.traits.Trait;
import software.amazon.smithy.utils.BuilderRef;
import software.amazon.smithy.utils.ListUtils;
import software.amazon.smithy.utils.SmithyBuilder;
import software.amazon.smithy.utils.SmithyUnstableApi;
import software.amazon.smithy.utils.ToSmithyBuilder;

Expand Down Expand Up @@ -66,7 +65,7 @@ public static Builder builder() {
}

@Override
public SmithyBuilder<HttpChecksumTrait> toBuilder() {
public Builder toBuilder() {
return new Builder()
.sourceLocation(getSourceLocation())
.requestChecksumRequired(requestChecksumRequired)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import software.amazon.smithy.model.shapes.ShapeId;
import software.amazon.smithy.model.traits.AbstractTrait;
import software.amazon.smithy.model.traits.AbstractTraitBuilder;
import software.amazon.smithy.utils.SmithyBuilder;
import software.amazon.smithy.utils.ToSmithyBuilder;

/**
Expand Down Expand Up @@ -63,7 +62,7 @@ protected Node createNode() {
}

@Override
public SmithyBuilder<ClientDiscoveredEndpointTrait> toBuilder() {
public Builder toBuilder() {
return builder().sourceLocation(getSourceLocation()).required(required);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ protected Node createNode() {
}

@Override
public SmithyBuilder<AwsQueryErrorTrait> toBuilder() {
public Builder toBuilder() {
return builder().code(code).httpResponseCode(httpResponseCode).sourceLocation(getSourceLocation());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public static Builder builder() {
}

@Override
public SmithyBuilder<ArrayNode> toBuilder() {
public Builder toBuilder() {
return new Builder().sourceLocation(getSourceLocation()).merge(this);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import software.amazon.smithy.model.node.NumberNode;
import software.amazon.smithy.model.node.StringNode;
import software.amazon.smithy.model.shapes.ShapeId;
import software.amazon.smithy.utils.SmithyBuilder;
import software.amazon.smithy.utils.ToSmithyBuilder;

/**
Expand Down Expand Up @@ -101,7 +100,7 @@ protected Node createNode() {
}

@Override
public SmithyBuilder<EnumValueTrait> toBuilder() {
public Builder toBuilder() {
Builder builder = builder().sourceLocation(getSourceLocation());
builder.value = value;
return builder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ public Node toNode() {
}

@Override
public SmithyBuilder<ErrorExample> toBuilder() {
public Builder toBuilder() {
return builder().content(content).shapeId(shapeId);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import software.amazon.smithy.model.shapes.ShapeId;
import software.amazon.smithy.utils.BuilderRef;
import software.amazon.smithy.utils.SetUtils;
import software.amazon.smithy.utils.SmithyBuilder;
import software.amazon.smithy.utils.ToSmithyBuilder;

/**
Expand Down Expand Up @@ -85,7 +84,7 @@ public static Builder builder() {
}

@Override
public SmithyBuilder<RequestCompressionTrait> toBuilder() {
public Builder toBuilder() {
return new Builder()
.sourceLocation(getSourceLocation())
.encodings(encodings);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1351,7 +1351,7 @@ protected Node createNode() {
}

@Override
public SmithyBuilder<SourceLocationBearerTrait> toBuilder() {
public Builder toBuilder() {
return new Builder().sourceLocation(getSourceLocation());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public int hashCode() {
}

@Override
public SmithyBuilder<EndpointTestOperationInput> toBuilder() {
public Builder toBuilder() {
return builder()
.sourceLocation(sourceLocation)
.operationName(operationName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public SourceLocation getSourceLocation() {
}

@Override
public SmithyBuilder<ExpectedEndpoint> toBuilder() {
public Builder toBuilder() {
return builder()
.sourceLocation(sourceLocation)
.url(url)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import software.amazon.smithy.model.traits.Trait;
import software.amazon.smithy.model.traits.TraitService;
import software.amazon.smithy.utils.BuilderRef;
import software.amazon.smithy.utils.SmithyBuilder;
import software.amazon.smithy.utils.ToSmithyBuilder;

/**
Expand All @@ -47,7 +46,7 @@ public static Builder builder() {
}

@Override
public SmithyBuilder<WaitableTrait> toBuilder() {
public Builder toBuilder() {
return new Builder().sourceLocation(getSourceLocation()).replace(waiters);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public static Builder builder() {
}

@Override
public SmithyBuilder<Waiter> toBuilder() {
public Builder toBuilder() {
return builder()
.documentation(getDocumentation().orElse(null))
.acceptors(getAcceptors())
Expand Down

0 comments on commit 2fa7c05

Please sign in to comment.