List of usage examples for java.lang Number getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:org.polymap.core.runtime.recordstore.lucene.NumericValueCoder.java
public Query searchQuery(QueryExpression exp) { // EQUALS//from ww w . j a v a 2s . c o m if (exp instanceof QueryExpression.Equal) { Equal equalExp = (QueryExpression.Equal) exp; if (equalExp.value instanceof Number) { String key = equalExp.key; Number value = (Number) equalExp.value; if (equalExp.value instanceof Integer) { return NumericRangeQuery.newIntRange(key, value.intValue(), value.intValue(), true, true); } else if (equalExp.value instanceof Long) { return NumericRangeQuery.newLongRange(key, value.longValue(), value.longValue(), true, true); } else if (equalExp.value instanceof Float) { return NumericRangeQuery.newFloatRange(key, value.floatValue(), value.floatValue(), true, true); } else if (equalExp.value instanceof Double) { return NumericRangeQuery.newDoubleRange(key, value.doubleValue(), value.doubleValue(), true, true); } else { throw new RuntimeException("Unknown Number type: " + value.getClass()); } } } // GREATER else if (exp instanceof QueryExpression.Greater) { Greater greaterExp = (QueryExpression.Greater) exp; if (greaterExp.value instanceof Number) { String key = greaterExp.key; Number value = (Number) greaterExp.value; if (greaterExp.value instanceof Integer) { return NumericRangeQuery.newIntRange(key, value.intValue(), null, false, false); } else if (greaterExp.value instanceof Long) { return NumericRangeQuery.newLongRange(key, value.longValue(), null, false, false); } else if (greaterExp.value instanceof Float) { return NumericRangeQuery.newFloatRange(key, value.floatValue(), null, false, false); } else if (greaterExp.value instanceof Double) { return NumericRangeQuery.newDoubleRange(key, value.doubleValue(), null, false, false); } else { throw new RuntimeException("Unknown Number type: " + value.getClass()); } } } // GREATER OR EQUAL else if (exp instanceof QueryExpression.GreaterOrEqual) { GreaterOrEqual greaterExp = (QueryExpression.GreaterOrEqual) exp; if (greaterExp.value instanceof Number) { String key = greaterExp.key; Number value = (Number) greaterExp.value; if (greaterExp.value instanceof Integer) { return NumericRangeQuery.newIntRange(key, value.intValue(), null, true, false); } else if (greaterExp.value instanceof Long) { return NumericRangeQuery.newLongRange(key, value.longValue(), null, true, false); } else if (greaterExp.value instanceof Float) { return NumericRangeQuery.newFloatRange(key, value.floatValue(), null, true, false); } else if (greaterExp.value instanceof Double) { return NumericRangeQuery.newDoubleRange(key, value.doubleValue(), null, true, false); } else { throw new RuntimeException("Unknown Number type: " + value.getClass()); } } } // LESS else if (exp instanceof QueryExpression.Less) { Less lessExp = (QueryExpression.Less) exp; if (lessExp.value instanceof Number) { String key = lessExp.key; Number value = (Number) lessExp.value; if (lessExp.value instanceof Integer) { return NumericRangeQuery.newIntRange(key, null, value.intValue(), false, false); } else if (lessExp.value instanceof Long) { return NumericRangeQuery.newLongRange(key, null, value.longValue(), false, false); } else if (lessExp.value instanceof Float) { return NumericRangeQuery.newFloatRange(key, null, value.floatValue(), false, false); } else if (lessExp.value instanceof Double) { return NumericRangeQuery.newDoubleRange(key, null, value.doubleValue(), false, false); } else { throw new RuntimeException("Unknown Number type: " + value.getClass()); } } } // LESS or equal else if (exp instanceof QueryExpression.LessOrEqual) { LessOrEqual lessExp = (QueryExpression.LessOrEqual) exp; if (lessExp.value instanceof Number) { String key = lessExp.key; Number value = (Number) lessExp.value; if (lessExp.value instanceof Integer) { return NumericRangeQuery.newIntRange(key, null, value.intValue(), false, true); } else if (lessExp.value instanceof Long) { return NumericRangeQuery.newLongRange(key, null, value.longValue(), false, true); } else if (lessExp.value instanceof Float) { return NumericRangeQuery.newFloatRange(key, null, value.floatValue(), false, true); } else if (lessExp.value instanceof Double) { return NumericRangeQuery.newDoubleRange(key, null, value.doubleValue(), false, true); } else { throw new RuntimeException("Unknown Number type: " + value.getClass()); } } } // MATCHES else if (exp instanceof QueryExpression.Match) { Match matchExp = (Match) exp; if (matchExp.value instanceof Number) { throw new UnsupportedOperationException("MATCHES not supported for Number values."); } } return null; }