public boolean isNumber() { return isInteger() || isDouble(); }
public BigDecimal getAsBigDecimal() { if (isString()) { return new BigDecimal(getAsString()); } else if (isDouble()) { return BigDecimal.valueOf(getAsDouble()); } else { throw new VPackValueTypeException(ValueType.STRING, ValueType.DOUBLE); } }
return source.getAsBigInteger(); else if (BigDecimal.class.isAssignableFrom(type) && source.isDouble()) { return source.getAsBigDecimal();
/** * Construct a GeoResult from the given object * * @param object * object representing one document in the result * @return GeoResult object */ private GeoResult<?> buildGeoResult(final Object object) { if (object == null || !(object instanceof VPackSlice)) { return null; } final VPackSlice slice = (VPackSlice) object; final VPackSlice distSlice = slice.get("_distance"); final Double distanceInMeters = distSlice.isDouble() ? distSlice.getAsDouble() : null; if (distanceInMeters == null) { return null; } final Object entity = operations.getConverter().read(domainClass, slice); final Distance distance = new Distance(distanceInMeters / 1000, Metrics.KILOMETERS); return new GeoResult<>(entity, distance); }
return source.getAsBigInteger(); else if (BigDecimal.class.isAssignableFrom(type) && source.isDouble()) { return source.getAsBigDecimal();
/** * Construct a GeoResult from the given object * * @param object * object representing one document in the result * @return GeoResult object */ private GeoResult<?> buildGeoResult(final Object object) { if (object == null || !(object instanceof VPackSlice)) { return null; } final VPackSlice slice = (VPackSlice) object; final VPackSlice distSlice = slice.get("_distance"); final Double distanceInMeters = distSlice.isDouble() ? distSlice.getAsDouble() : null; if (distanceInMeters == null) { return null; } final Object entity = operations.getConverter().read(domainClass, slice); final Distance distance = new Distance(distanceInMeters / 1000, Metrics.KILOMETERS); return new GeoResult<>(entity, distance); }
public Number getAsNumber() { final Number result; if (isSmallInt()) { result = getSmallInt(); } else if (isInt()) { result = getInt(); } else if (isUInt()) { result = getUInt(); } else if (isDouble()) { result = getAsDoubleUnchecked(); } else { throw new VPackValueTypeException(ValueType.INT, ValueType.UINT, ValueType.SMALLINT); } return result; }
} else if (value.isString()) { json.append(toJSONString(value.getAsString())); } else if (value.isDouble()) { json.append(value.getAsDouble()); } else if (value.isInt()) {
private Type getType(final VPackSlice vpack) { final Type type; if (vpack.isObject()) { type = Map.class; } else if (vpack.isString()) { type = String.class; } else if (vpack.isBoolean()) { type = Boolean.class; } else if (vpack.isArray()) { type = Collection.class; } else if (vpack.isDate()) { type = Date.class; } else if (vpack.isDouble()) { type = Double.class; } else if (vpack.isNumber()) { type = Number.class; } else if (vpack.isCustom()) { type = String.class; } else { type = null; } return type; }
/** * Build a GeoResult from the given ArangoCursor * * @param cursor * query result from driver * @return GeoResult object */ private GeoResult<?> buildGeoResult(final ArangoCursor<?> cursor) { GeoResult<?> geoResult = null; while (cursor.hasNext() && geoResult == null) { final Object object = cursor.next(); if (!(object instanceof VPackSlice)) { continue; } final VPackSlice slice = (VPackSlice) object; final VPackSlice distSlice = slice.get("_distance"); final Double distanceInMeters = distSlice.isDouble() ? distSlice.getAsDouble() : null; if (distanceInMeters == null) { continue; } final Object entity = operations.getConverter().read(domainClass, slice); final Distance distance = new Distance(distanceInMeters / 1000, Metrics.KILOMETERS); geoResult = new GeoResult<>(entity, distance); } return geoResult; }
/** * Build a GeoResult from the given ArangoCursor * * @param cursor * query result from driver * @return GeoResult object */ private GeoResult<?> buildGeoResult(final ArangoCursor<?> cursor) { GeoResult<?> geoResult = null; while (cursor.hasNext() && geoResult == null) { final Object object = cursor.next(); if (!(object instanceof VPackSlice)) { continue; } final VPackSlice slice = (VPackSlice) object; final VPackSlice distSlice = slice.get("_distance"); final Double distanceInMeters = distSlice.isDouble() ? distSlice.getAsDouble() : null; if (distanceInMeters == null) { continue; } final Object entity = operations.getConverter().read(domainClass, slice); final Distance distance = new Distance(distanceInMeters / 1000, Metrics.KILOMETERS); geoResult = new GeoResult<>(entity, distance); } return geoResult; }