Skip to content

Instantly share code, notes, and snippets.

@debop
Created May 2, 2013 15:09
Show Gist options
  • Select an option

  • Save debop/5502873 to your computer and use it in GitHub Desktop.

Select an option

Save debop/5502873 to your computer and use it in GitHub Desktop.
InRange
/** 지정한 값이 두 속성 값 사이에 존재하는지 여부 */
public static Criterion getIsInRangeCriterion(final String loPropertyName,
final String hiPropertyName,
Object value,
boolean includeLo,
boolean includeHi) {
Guard.shouldNotBeNull(value, "value");
Criterion loCriteria = (includeLo) ? le(loPropertyName, value)
: lt(loPropertyName, value);
Criterion hiCritiera = (includeHi) ? ge(hiPropertyName, value)
: gt(hiPropertyName, value);
return conjunction()
.add(disjunction()
.add(isNull(loPropertyName))
.add(loCriteria))
.add(disjunction()
.add(isNull(hiPropertyName))
.add(hiCritiera));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment