Skip to content

Add Attributes.containsAttribute() shorthand method#2004

Merged
jodastephen merged 3 commits intomasterfrom
has_attribute
Jun 19, 2019
Merged

Add Attributes.containsAttribute() shorthand method#2004
jodastephen merged 3 commits intomasterfrom
has_attribute

Conversation

@ashleyheath
Copy link
Copy Markdown
Contributor

@ashleyheath ashleyheath commented Jun 19, 2019

Add a simple helper method to Attributes - thing.hasAttribute(foo) reads more clearly than thing.findAttribute(foo).isPresent() and is also nicer to use in functional code.

@ashleyheath ashleyheath requested a review from jodastephen June 19, 2019 13:03
* @param type the type to find
* @return true if a matching attribute is present
*/
public default <T> boolean hasAttribute(AttributeType<T> type) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking around, we tend to use containsXxx() for methods like this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

@jodastephen jodastephen merged commit a060ce8 into master Jun 19, 2019
@delete-merged-branch delete-merged-branch bot deleted the has_attribute branch June 19, 2019 14:08
@jodastephen jodastephen changed the title Add Attributes.hasAttribute() shorthand method Add Attributes.containsAttribute() shorthand method Jun 28, 2019
@jodastephen jodastephen added this to the v2.5 milestone Jun 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants