@Override NumberParam newInstance() { return new NumberParam(); }
@Override public String toString() { ToStringBuilder b = new ToStringBuilder(this, ToStringStyle.SIMPLE_STYLE); b.append("prefix", getPrefix()); b.append("value", myQuantity); return b.build(); }
@Override public boolean matches(IQueryParameterType theParam) { if (!(theParam instanceof NumberParam)) { return false; } NumberParam number = (NumberParam) theParam; return getValue().equals(number.getValue()); }
/** * Returns a new param containing the same value as this param, but with the type copnverted * to {@link NumberParam}. This is useful if you are using reference parameters and want to handle * chained parameters of different types in a single method. * <p> * See <a href="http://jamesagnew.github.io/hapi-fhir/doc_rest_operations.html#dynamic_chains">Dynamic Chains</a> * in the HAPI FHIR documentation for an example of how to use this method. * </p> */ public NumberParam toNumberParam(FhirContext theContext) { NumberParam retVal = new NumberParam(); retVal.setValueAsQueryToken(theContext, null, null, getValueAsQueryToken(theContext)); return retVal; }
private void addPredicateNumber(String theResourceName, String theParamName, List<? extends IQueryParameterType> theList) { Join<ResourceTable, ResourceIndexedSearchParamNumber> join = createOrReuseJoin(JoinEnum.NUMBER, theParamName); if (theList.get(0).getMissing() != null) { addPredicateParamMissing(theResourceName, theParamName, theList.get(0).getMissing(), join); return; } List<Predicate> codePredicates = new ArrayList<>(); for (IQueryParameterType nextOr : theList) { if (nextOr instanceof NumberParam) { NumberParam param = (NumberParam) nextOr; BigDecimal value = param.getValue(); if (value == null) { continue; } final Expression<BigDecimal> fromObj = join.get("myValue"); ParamPrefixEnum prefix = ObjectUtils.defaultIfNull(param.getPrefix(), ParamPrefixEnum.EQUAL); String invalidMessageName = "invalidNumberPrefix"; Predicate predicateNumeric = createPredicateNumeric(theResourceName, theParamName, join, myBuilder, nextOr, prefix, value, fromObj, invalidMessageName); Predicate predicateOuter = combineParamIndexPredicateWithParamNamePredicate(theResourceName, theParamName, join, predicateNumeric); codePredicates.add(predicateOuter); } else { throw new IllegalArgumentException("Invalid token type: " + nextOr.getClass()); } } myPredicates.add(myBuilder.or(toArray(codePredicates))); }
@Override void doSetValueAsQueryToken(FhirContext theContext, String theParamName, String theQualifier, String theValue) { if (getMissing() != null && isBlank(theValue)) { return; } String value = super.extractPrefixAndReturnRest(theValue); myQuantity = null; if (isNotBlank(value)) { myQuantity = new BigDecimal(value); } }
/** * Constructor * * @param theValue * A value, e.g. "10" */ public NumberParam(int theValue) { setValue(new BigDecimal(theValue)); }
/** * Constructor * * @param theValue * A string value, e.g. ">5.0" */ public NumberParam(String theValue) { setValueAsQueryToken(null, null, null, theValue); }
NumberParam number = (NumberParam) theParameter; system = null; code = number.getValueAsQueryToken(myContext); } else { throw new IllegalArgumentException("Invalid token type: " + theParameter.getClass());
/** * Returns a new param containing the same value as this param, but with the type copnverted * to {@link NumberParam}. This is useful if you are using reference parameters and want to handle * chained parameters of different types in a single method. * <p> * See <a href="http://jamesagnew.github.io/hapi-fhir/doc_rest_operations.html#dynamic_chains">Dynamic Chains</a> * in the HAPI FHIR documentation for an example of how to use this method. * </p> */ public NumberParam toNumberParam(FhirContext theContext) { NumberParam retVal = new NumberParam(); retVal.setValueAsQueryToken(theContext, null, null, getValueAsQueryToken(theContext)); return retVal; }
private void addPredicateNumber(String theResourceName, String theParamName, List<? extends IQueryParameterType> theList) { Join<ResourceTable, ResourceIndexedSearchParamNumber> join = createOrReuseJoin(JoinEnum.NUMBER, theParamName); if (theList.get(0).getMissing() != null) { addPredicateParamMissing(theResourceName, theParamName, theList.get(0).getMissing(), join); return; } List<Predicate> codePredicates = new ArrayList<>(); for (IQueryParameterType nextOr : theList) { if (nextOr instanceof NumberParam) { NumberParam param = (NumberParam) nextOr; BigDecimal value = param.getValue(); if (value == null) { continue; } final Expression<BigDecimal> fromObj = join.get("myValue"); ParamPrefixEnum prefix = ObjectUtils.defaultIfNull(param.getPrefix(), ParamPrefixEnum.EQUAL); String invalidMessageName = "invalidNumberPrefix"; Predicate predicateNumeric = createPredicateNumeric(theResourceName, theParamName, join, myBuilder, nextOr, prefix, value, fromObj, invalidMessageName); Predicate predicateOuter = combineParamIndexPredicateWithParamNamePredicate(theResourceName, theParamName, join, predicateNumeric); codePredicates.add(predicateOuter); } else { throw new IllegalArgumentException("Invalid token type: " + nextOr.getClass()); } } myPredicates.add(myBuilder.or(toArray(codePredicates))); }
@Override void doSetValueAsQueryToken(FhirContext theContext, String theParamName, String theQualifier, String theValue) { if (getMissing() != null && isBlank(theValue)) { return; } String value = super.extractPrefixAndReturnRest(theValue); myQuantity = null; if (isNotBlank(value)) { myQuantity = new BigDecimal(value); } }
/** * Constructor * * @param theValue * A value, e.g. "10" */ public NumberParam(int theValue) { setValue(new BigDecimal(theValue)); }
/** * Constructor * * @param theValue * A string value, e.g. ">5.0" */ public NumberParam(String theValue) { setValueAsQueryToken(null, null, null, theValue); }
NumberParam number = (NumberParam) theParameter; system = null; code = number.getValueAsQueryToken(myContext); } else { throw new IllegalArgumentException("Invalid token type: " + theParameter.getClass());
@Override public IQueryParameterType toQueryParameterType() { return new NumberParam(myValue.toPlainString()); }
break; case NUMBER: qp = new NumberParam(); break; case QUANTITY:
@Override public String toString() { ToStringBuilder b = new ToStringBuilder(this, ToStringStyle.SIMPLE_STYLE); b.append("prefix", getPrefix()); b.append("value", myQuantity); return b.build(); }
@Override NumberParam newInstance() { return new NumberParam(); }