-
Notifications
You must be signed in to change notification settings - Fork 226
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
Add methods to get shapes by type and trait #806
Conversation
720f4f3
to
f9e5c29
Compare
public Set<BigDecimalShape> getBigDecimalShapesWithTrait(Class<? extends Trait> trait) { | ||
return new ShapeTypeFilteredSet<>(getShapesWithTrait(trait), BigDecimalShape.class); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not really a huge fan of having methods for each shape type, but this would head-off fat-fingering and it's a bit easier to understand for people less experienced with java.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is also much more usable than having two Class
params generally.
smithy-model/src/main/java/software/amazon/smithy/model/ShapeTypeFilteredSet.java
Show resolved
Hide resolved
smithy-model/src/main/java/software/amazon/smithy/model/ShapeTypeFilteredSet.java
Outdated
Show resolved
Hide resolved
smithy-model/src/main/java/software/amazon/smithy/model/Model.java
Outdated
Show resolved
Hide resolved
public Set<BigDecimalShape> getBigDecimalShapesWithTrait(Class<? extends Trait> trait) { | ||
return new ShapeTypeFilteredSet<>(getShapesWithTrait(trait), BigDecimalShape.class); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is also much more usable than having two Class
params generally.
Model now contains methods for every shape type to get a Set of shapes or that type or a set of shapes of a type that have a specific trait. These methods are simpler to use than `shapes(Class)` and `toSet(Class)`, and they hopefully encourage the use of the caches that Model uses. These methods also eliminated a lot of boilerplat that getShapesWithTrait previously required when only shapes of a certain type were needed.
f9e5c29
to
9126135
Compare
Model now contains methods for every shape type to get a Set of shapes
or that type or a set of shapes of a type that have a specific trait.
These methods are simpler to use than
shapes(Class)
andtoSet(Class)
, and they hopefully encourage the use of the caches thatModel uses. These methods also eliminated a lot of boilerplat that
getShapesWithTrait previously required when only shapes of a certain
type were needed.
Issue #, if available:
Description of changes:
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.