review feedback: code improvement
This commit is contained in:
parent
705735b9c0
commit
ccd983ab42
|
@ -7,6 +7,7 @@ import ca.uhn.fhir.rest.param.ReferenceParam;
|
||||||
import org.hl7.fhir.dstu3.model.Location;
|
import org.hl7.fhir.dstu3.model.Location;
|
||||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
@ -68,19 +69,17 @@ public class Dstu3DistanceHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static QuantityParam getNearDistanceParam(List<List<IQueryParameterType>> theParamAndList) {
|
private static QuantityParam getNearDistanceParam(List<List<IQueryParameterType>> theParamAndList) {
|
||||||
if (theParamAndList.isEmpty()) {
|
long sum = theParamAndList.stream().mapToLong(Collection::size).sum();
|
||||||
|
|
||||||
|
// No near-distance Param
|
||||||
|
if (sum == 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
// A single near-distance Param
|
||||||
if (theParamAndList.size() > 1) {
|
} else if (sum == 1) {
|
||||||
|
return (QuantityParam) theParamAndList.get(0).get(0);
|
||||||
|
// Too many near-distance params
|
||||||
|
} else {
|
||||||
throw new IllegalArgumentException("Only one " + Location.SP_NEAR_DISTANCE + " parameter may be present");
|
throw new IllegalArgumentException("Only one " + Location.SP_NEAR_DISTANCE + " parameter may be present");
|
||||||
}
|
}
|
||||||
List<IQueryParameterType> paramOrList = theParamAndList.get(0);
|
|
||||||
if (paramOrList.isEmpty()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (paramOrList.size() > 1) {
|
|
||||||
throw new IllegalArgumentException("Only one " + Location.SP_NEAR_DISTANCE + " parameter may be present");
|
|
||||||
}
|
|
||||||
return (QuantityParam) paramOrList.get(0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue