in entity-store/src/main/java/jetbrains/exodus/entitystore/iterate/PropertyRangeIterable.java [119:184]
protected EntityIterableHandle getHandleImpl() {
final int entityTypeId = getEntityTypeId();
final int propertyId = getPropertyId();
return new ConstantEntityIterableHandle(getStore(), getType()) {
@NotNull
@Override
public int[] getPropertyIds() {
return new int[]{propertyId};
}
@Override
public void toString(@NotNull final StringBuilder builder) {
super.toString(builder);
builder.append(entityTypeId);
builder.append('-');
builder.append(propertyId);
builder.append('-');
builder.append(min);
builder.append('-');
builder.append(max);
}
@Override
public void hashCode(@NotNull final EntityIterableHandleHash hash) {
hash.apply(entityTypeId);
hash.applyDelimiter();
hash.apply(propertyId);
hash.applyDelimiter();
hash.apply(min.toString());
hash.applyDelimiter();
hash.apply(max.toString());
}
@Override
public int getEntityTypeId() {
return entityTypeId;
}
@Override
public boolean isMatchedPropertyChanged(@NotNull final EntityId id,
final int propId,
@Nullable final Comparable oldValue,
@Nullable final Comparable newValue) {
return propertyId == propId && entityTypeId == id.getTypeId() && (isRangeAffected(oldValue) || isRangeAffected(newValue));
}
private boolean isRangeAffected(@Nullable final Comparable value) {
if (value == null) {
return false;
}
if (value instanceof ComparableSet) {
final ComparableSet set = (ComparableSet) value;
// not null set should be non-empty
return isRangeAffectedByPrimitiveValue(set.getMinimum()) ||
isRangeAffectedByPrimitiveValue(set.getMaximum());
}
return isRangeAffectedByPrimitiveValue(value);
}
private boolean isRangeAffectedByPrimitiveValue(@NotNull final Comparable value) {
final Comparable lowercaseValue = PropertyTypes.toLowerCase(value);
return min.compareTo(lowercaseValue) <= 0 && max.compareTo(lowercaseValue) >= 0;
}
};
}