Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
Expand Down Expand Up @@ -127,9 +128,9 @@ public AnnotationVisitor visitAnnotation(String descriptor,
}

/**
* Return all values of a repeated annotation parameter. For instance
* `getValues("value")` will return 'Bar' and 'Baz' when we have the
* following code:
* Return all values of a repeated annotation parameter in the occurrence
* order. For instance `getValues("value")` will return 'Bar' and 'Baz' when
* we have the following code:
*
* <pre>
* <code>
Expand All @@ -143,18 +144,20 @@ public AnnotationVisitor visitAnnotation(String descriptor,
*
* @param parameter
* the annotation parameter used for getting values
* @return a set of all values found
* @return an ordered set of all values found
*/
@SuppressWarnings("unchecked")
public <T> Set<T> getValues(String parameter) {
return (Set<T>) data.stream().filter(h -> h.containsKey(parameter))
.map(h -> h.get(parameter)).collect(Collectors.toSet());
.map(h -> h.get(parameter))
.collect(Collectors.toCollection(LinkedHashSet::new));
}

/**
* Return all parameter values of a repeated annotation when they share the
* same value for a key parameter. For example `getValuesForKey("value",
* "foo", "other")` will return 'aa' and 'bb' if we have the following code:
* same value for a key parameter in the occurrence order. For example
* `getValuesForKey("value", "foo", "other")` will return 'aa' and 'bb' when
* we have the following code:
*
* <pre>
* <code>
Expand All @@ -171,14 +174,15 @@ public <T> Set<T> getValues(String parameter) {
* the shared value
* @param property
* the parameter name of the value to return
* @return a set of all values found
* @return an ordered set of all values found
*/
@SuppressWarnings("unchecked")
public <T> Set<T> getValuesForKey(String key, String value,
String property) {
return (Set<T>) data.stream()
.filter(h -> h.containsKey(key) && h.get(key).equals(value))
.map(h -> h.get(property)).collect(Collectors.toSet());
.map(h -> h.get(property))
.collect(Collectors.toCollection(LinkedHashSet::new));
}

/**
Expand Down
Loading