Skip to content

Commit

Permalink
sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
rishav-karanjit committed Jan 8, 2025
1 parent 97fb363 commit 7c7f8f2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ private void generateErrorSerializer(final GenerationContext context) {
final var errorShapes = awsNormalizedModel.getShapesWithTrait(
ErrorTrait.class
).stream()
.sorted(Comparator.comparing(shape -> shape.getId().getName())).collect(Collectors.toCollection(LinkedHashSet::new));
.sorted().collect(Collectors.toCollection(LinkedHashSet::new));

for (final var errorShape : errorShapes) {
if (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ void generateClient(GoWriter writer) {
.getNamespace()
.equals(service.getId().getNamespace())
)
.sorted()
.forEach(unionShape -> {
new UnionGenerator(model, symbolProvider, unionShape)
.generateUnion(writer1);
Expand Down Expand Up @@ -626,7 +627,7 @@ void generateShim() {

void shimErrors(GoWriter writer) {
for (final var error : model.getShapesWithTrait(ErrorTrait.class).stream()
.sorted(Comparator.comparing(shape -> shape.getId().getName())).collect(Collectors.toCollection(LinkedHashSet::new))) {
.sorted().collect(Collectors.toCollection(LinkedHashSet::new))) {
writer.write(
"""
case $L.$L:
Expand All @@ -645,7 +646,7 @@ void shimErrors(GoWriter writer) {

void resourceErrors(GoWriter writer) {
for (final var error : model.getShapesWithTrait(ErrorTrait.class).stream()
.sorted(Comparator.comparing(shape -> shape.getId().getName())).collect(Collectors.toCollection(LinkedHashSet::new))) {
.sorted().collect(Collectors.toCollection(LinkedHashSet::new))) {
writer.write(
"""
case $L:
Expand Down Expand Up @@ -715,7 +716,7 @@ void generateUnmodelledErrors(GenerationContext context) {

void generateReferencedResources(final GenerationContext context) {
final var refResources = model.getShapesWithTrait(ReferenceTrait.class).stream()
.sorted(Comparator.comparing(shape -> shape.getId().getName())).collect(Collectors.toCollection(LinkedHashSet::new));
.sorted().collect(Collectors.toCollection(LinkedHashSet::new));
for (final var refResource : refResources) {
if (!refResource.expectTrait(ReferenceTrait.class).isService()) {
final var resource = refResource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public void generateSerializers(final GenerationContext context) {
final var refResources = context
.model()
.getShapesWithTrait(ReferenceTrait.class).stream()
.sorted(Comparator.comparing(shape -> shape.getId().getName())).collect(Collectors.toCollection(LinkedHashSet::new));
.sorted().collect(Collectors.toCollection(LinkedHashSet::new));
for (final var refResource : refResources) {
final var resource = refResource
.expectTrait(ReferenceTrait.class)
Expand Down Expand Up @@ -588,7 +588,7 @@ public void generateDeserializers(final GenerationContext context) {
final var refResources = context
.model()
.getShapesWithTrait(ReferenceTrait.class).stream()
.sorted(Comparator.comparing(shape -> shape.getId().getName())).collect(Collectors.toCollection(LinkedHashSet::new));
.sorted().collect(Collectors.toCollection(LinkedHashSet::new));
for (final var refResource : refResources) {
final var resource = refResource
.expectTrait(ReferenceTrait.class)
Expand Down Expand Up @@ -989,7 +989,7 @@ private void generateErrorSerializer(final GenerationContext context) {
final var errorShapes = context
.model()
.getShapesWithTrait(ErrorTrait.class).stream()
.sorted(Comparator.comparing(shape -> shape.getId().getName())).collect(Collectors.toCollection(LinkedHashSet::new));
.sorted().collect(Collectors.toCollection(LinkedHashSet::new));

for (final var errorShape : errorShapes) {
if (
Expand Down Expand Up @@ -1089,6 +1089,7 @@ func OpaqueError_Input_ToDafny(nativeInput $L.OpaqueError)($L.Error) {
.filter(shape ->
ModelUtils.isInServiceNamespace(shape.getId(), serviceShape)
)
.sorted()
.collect(Collectors.toSet());

context
Expand Down Expand Up @@ -1346,7 +1347,7 @@ private void generateErrorDeserializer(final GenerationContext context) {
final var errorShapes = context
.model()
.getShapesWithTrait(ErrorTrait.class).stream()
.sorted(Comparator.comparing(shape -> shape.getId().getName())).collect(Collectors.toCollection(LinkedHashSet::new));
.sorted().collect(Collectors.toCollection(LinkedHashSet::new));
for (final var errorShape : errorShapes) {
if (
!errorShape
Expand Down Expand Up @@ -1471,6 +1472,7 @@ func OpaqueError_Output_FromDafny(dafnyOutput $L.Error)($L.OpaqueError) {
.filter(shape ->
ModelUtils.isInServiceNamespace(shape.getId(), serviceShape)
)
.sorted()
.collect(Collectors.toSet());

context
Expand Down

0 comments on commit 7c7f8f2

Please sign in to comment.