[New] Added getParametersByInterpretation()

This commit is contained in:
Robert von Burg 2017-09-06 18:51:34 +02:00
parent 96108a4c4e
commit e128d42365
2 changed files with 36 additions and 0 deletions

View File

@ -140,6 +140,24 @@ public abstract class GroupedParameterizedElement extends AbstractStrolchElement
return parameter;
}
/**
* Returns a list of all the {@link Parameter Parameters} with the given interpretation
*
* @param bagKey
* the key of the {@link ParameterBag} from which the {@link Parameter} is to be returned
* @param interpretation
* the interpretation for which the parameters are to be returned
*
* @return the parameters with the given interpretation
*/
public List<Parameter<?>> getParametersByInterpretation(String bagKey, String interpretation) {
ParameterBag bag = getParameterBag(bagKey);
if (bag == null)
return Collections.emptyList();
return bag.getParametersByInterpretation(interpretation);
}
/**
* Adds a new {@link Parameter} to the {@link ParameterBag} with the given key
*

View File

@ -23,6 +23,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import li.strolch.exception.StrolchException;
import li.strolch.exception.StrolchModelException;
@ -172,6 +173,23 @@ public abstract class ParameterizedElement extends AbstractStrolchElement {
return new ArrayList<>(this.parameterMap.values());
}
/**
* Returns a list of all the {@link Parameter Parameters} with the given interpretation
*
* @param interpretation
* the interpretation for which the parameters are to be returned
*
* @return the parameters with the given interpretation
*/
public List<Parameter<?>> getParametersByInterpretation(String interpretation) {
if (this.parameterMap == null) {
return Collections.emptyList();
}
return this.parameterMap.values().stream().filter(p -> p.getInterpretation().equals(interpretation))
.collect(Collectors.toList());
}
/**
* Returns true, if the this {@link ParameterizedElement} has any {@link Parameter Parameters}, false otherwise
*