Fixes #911 - Adds support for :contains modifier

Adds support for the :contains modifier in StringClientParam.
This commit is contained in:
Clayton Bodendein 2018-03-30 23:49:06 -05:00
parent c5b286921e
commit ac8e412e49
3 changed files with 31 additions and 2 deletions

View File

@ -59,6 +59,13 @@ public class StringClientParam extends BaseClientParam implements IParam {
return new StringExactly();
}
/**
* The string contains given value
*/
public IStringMatch contains() {
return new StringContains();
}
public interface IStringMatch {
/**
@ -109,6 +116,28 @@ public class StringClientParam extends BaseClientParam implements IParam {
}
}
private class StringContains implements IStringMatch {
@Override
public ICriterion<StringClientParam> value(String theValue) {
return new StringCriterion<StringClientParam>(getParamName() + Constants.PARAMQUALIFIER_STRING_CONTAINS, theValue);
}
@Override
public ICriterion<StringClientParam> value(StringDt theValue) {
return new StringCriterion<StringClientParam>(getParamName() + Constants.PARAMQUALIFIER_STRING_CONTAINS, theValue.getValue());
}
@Override
public ICriterion<StringClientParam> values(List<String> theValue) {
return new StringCriterion<StringClientParam>(getParamName() + Constants.PARAMQUALIFIER_STRING_CONTAINS, theValue);
}
@Override
public ICriterion<?> values(String... theValues) {
return new StringCriterion<StringClientParam>(getParamName() + Constants.PARAMQUALIFIER_STRING_CONTAINS, Arrays.asList(theValues));
}
}
private class StringMatches implements IStringMatch {
@Override
public ICriterion<StringClientParam> value(String theValue) {

View File

@ -53,7 +53,7 @@ public class SearchParameter extends BaseQueryParameter {
ourParamTypes.put(StringParam.class, RestSearchParameterTypeEnum.STRING);
ourParamTypes.put(StringOrListParam.class, RestSearchParameterTypeEnum.STRING);
ourParamTypes.put(StringAndListParam.class, RestSearchParameterTypeEnum.STRING);
ourParamQualifiers.put(RestSearchParameterTypeEnum.STRING, CollectionUtil.newSet(Constants.PARAMQUALIFIER_STRING_EXACT, Constants.PARAMQUALIFIER_MISSING, EMPTY_STRING));
ourParamQualifiers.put(RestSearchParameterTypeEnum.STRING, CollectionUtil.newSet(Constants.PARAMQUALIFIER_STRING_EXACT, Constants.PARAMQUALIFIER_STRING_CONTAINS, Constants.PARAMQUALIFIER_MISSING, EMPTY_STRING));
ourParamTypes.put(UriParam.class, RestSearchParameterTypeEnum.URI);
ourParamTypes.put(UriOrListParam.class, RestSearchParameterTypeEnum.URI);

View File

@ -53,7 +53,7 @@ public class SearchParameter extends BaseQueryParameter {
ourParamTypes.put(StringParam.class, RestSearchParameterTypeEnum.STRING);
ourParamTypes.put(StringOrListParam.class, RestSearchParameterTypeEnum.STRING);
ourParamTypes.put(StringAndListParam.class, RestSearchParameterTypeEnum.STRING);
ourParamQualifiers.put(RestSearchParameterTypeEnum.STRING, CollectionUtil.newSet(Constants.PARAMQUALIFIER_STRING_EXACT, Constants.PARAMQUALIFIER_MISSING, EMPTY_STRING));
ourParamQualifiers.put(RestSearchParameterTypeEnum.STRING, CollectionUtil.newSet(Constants.PARAMQUALIFIER_STRING_EXACT, Constants.PARAMQUALIFIER_STRING_CONTAINS, Constants.PARAMQUALIFIER_MISSING, EMPTY_STRING));
ourParamTypes.put(UriParam.class, RestSearchParameterTypeEnum.URI);
ourParamTypes.put(UriOrListParam.class, RestSearchParameterTypeEnum.URI);