ca.uhn.fhir.rest.gclient.NumberClientParam Maven / Gradle / Ivy
/*
* #%L
* HAPI FHIR - Core Library
* %%
* Copyright (C) 2014 - 2024 Smile CDR, Inc.
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package ca.uhn.fhir.rest.gclient;
import ca.uhn.fhir.rest.param.ParamPrefixEnum;
/**
* Token parameter type for use in fluent client interfaces
*/
public class NumberClientParam extends BaseClientParam implements IParam {
private final String myParamName;
public NumberClientParam(String theParamName) {
myParamName = theParamName;
}
public IMatches> exactly() {
return new IMatches>() {
@Override
public ICriterion number(long theNumber) {
return new StringCriterion<>(getParamName(), Long.toString(theNumber));
}
@Override
public ICriterion number(String theNumber) {
return new StringCriterion<>(getParamName(), (theNumber));
}
};
}
@Override
public String getParamName() {
return myParamName;
}
public IMatches> greaterThan() {
return new IMatches>() {
@Override
public ICriterion number(long theNumber) {
return new StringCriterion<>(getParamName(), ParamPrefixEnum.GREATERTHAN, Long.toString(theNumber));
}
@Override
public ICriterion number(String theNumber) {
return new StringCriterion<>(getParamName(), ParamPrefixEnum.GREATERTHAN, (theNumber));
}
};
}
public IMatches> greaterThanOrEqual() {
return new IMatches>() {
@Override
public ICriterion number(long theNumber) {
return new StringCriterion<>(
getParamName(), ParamPrefixEnum.GREATERTHAN_OR_EQUALS, Long.toString(theNumber));
}
@Override
public ICriterion number(String theNumber) {
return new StringCriterion<>(getParamName(), ParamPrefixEnum.GREATERTHAN_OR_EQUALS, (theNumber));
}
};
}
public IMatches> lessThan() {
return new IMatches>() {
@Override
public ICriterion number(long theNumber) {
return new StringCriterion<>(getParamName(), ParamPrefixEnum.LESSTHAN, Long.toString(theNumber));
}
@Override
public ICriterion number(String theNumber) {
return new StringCriterion<>(getParamName(), ParamPrefixEnum.LESSTHAN, (theNumber));
}
};
}
public IMatches> lessThanOrEqual() {
return new IMatches>() {
@Override
public ICriterion number(long theNumber) {
return new StringCriterion<>(
getParamName(), ParamPrefixEnum.LESSTHAN_OR_EQUALS, Long.toString(theNumber));
}
@Override
public ICriterion number(String theNumber) {
return new StringCriterion<>(getParamName(), ParamPrefixEnum.LESSTHAN_OR_EQUALS, (theNumber));
}
};
}
public IMatches> withPrefix(final ParamPrefixEnum thePrefix) {
return new IMatches>() {
@Override
public ICriterion number(long theNumber) {
return new StringCriterion<>(getParamName(), thePrefix, Long.toString(theNumber));
}
@Override
public ICriterion number(String theNumber) {
return new StringCriterion<>(getParamName(), thePrefix, (theNumber));
}
};
}
public interface IMatches {
/**
* Creates a search criterion that matches against the given number
*
* @param theNumber
* The number
* @return A criterion
*/
T number(long theNumber);
/**
* Creates a search criterion that matches against the given number
*
* @param theNumber
* The number
* @return A criterion
*/
T number(String theNumber);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy