relax parameter domain check for sub-parameters

This commit is contained in:
Jörg Prante 2023-08-01 11:13:02 +02:00
parent abd1df903b
commit a2dab0623c

View file

@ -200,12 +200,12 @@ public class Parameter implements Iterable<Pair<String, Object>>, Comparable<Par
}
public Parameter get(Domain domain) throws ParameterException {
if (getDomain() == Domain.UNDEFINED) {
throw new ParameterException("undefined domain");
}
if (builder.parameterMap.containsKey(domain)) {
return builder.parameterMap.get(domain);
}
if (getDomain() == Domain.UNDEFINED) {
throw new ParameterException("undefined domain");
}
if (getDomain().equals(domain)) {
return this;
}
@ -213,9 +213,6 @@ public class Parameter implements Iterable<Pair<String, Object>>, Comparable<Par
}
public List<Object> getAll(String key, Domain domain) throws Exception {
if (getDomain() == Domain.UNDEFINED) {
throw new ParameterException("undefined domain");
}
Parameter parameter = null;
if (builder.parameterMap.containsKey(domain)) {
parameter = builder.parameterMap.get(domain);
@ -223,6 +220,9 @@ public class Parameter implements Iterable<Pair<String, Object>>, Comparable<Par
if (parameter != null) {
return parameter.getAll(key, domain);
}
if (getDomain() == Domain.UNDEFINED) {
throw new ParameterException("undefined domain");
}
if (getDomain().equals(domain)) {
return list.stream()
.filter(p -> p.getKey().equals(key))
@ -248,9 +248,6 @@ public class Parameter implements Iterable<Pair<String, Object>>, Comparable<Par
}
public Object get(String key, Domain domain) throws ParameterException {
if (getDomain() == Domain.UNDEFINED) {
throw new ParameterException("undefined domain");
}
Parameter parameter = null;
if (builder.parameterMap.containsKey(domain)) {
parameter = builder.parameterMap.get(domain);
@ -258,6 +255,9 @@ public class Parameter implements Iterable<Pair<String, Object>>, Comparable<Par
if (parameter != null) {
return parameter.get(key, domain);
}
if (getDomain() == Domain.UNDEFINED) {
throw new ParameterException("undefined domain, please specify domain for parameter " + this);
}
if (getDomain().equals(domain)) {
Optional<Object> optional = list.stream()
.filter(p -> key.equals(p.getKey()))