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

Add methods to get shapes by type and trait #806

Merged
merged 1 commit into from
May 18, 2021
Merged

Conversation

mtdowling
Copy link
Member

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.

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.

@mtdowling mtdowling force-pushed the add-typed-model-methods branch 2 times, most recently from 720f4f3 to f9e5c29 Compare May 18, 2021 07:43
Comment on lines +231 to +233
public Set<BigDecimalShape> getBigDecimalShapesWithTrait(Class<? extends Trait> trait) {
return new ShapeTypeFilteredSet<>(getShapesWithTrait(trait), BigDecimalShape.class);
}
Copy link
Contributor

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.

Copy link
Contributor

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.

Comment on lines +231 to +233
public Set<BigDecimalShape> getBigDecimalShapesWithTrait(Class<? extends Trait> trait) {
return new ShapeTypeFilteredSet<>(getShapesWithTrait(trait), BigDecimalShape.class);
}
Copy link
Contributor

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.
@mtdowling mtdowling force-pushed the add-typed-model-methods branch from f9e5c29 to 9126135 Compare May 18, 2021 18:34
@mtdowling mtdowling requested a review from kstich May 18, 2021 18:34
@mtdowling mtdowling merged commit b457062 into perf May 18, 2021
@mtdowling mtdowling deleted the add-typed-model-methods branch May 21, 2021 20:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants