return any.getBoolValue(); case NUMBER_VALUE: return any.getNumberValue(); case STRING_VALUE: return any.getStringValue();
private static Object valueToObject(Value value) { switch (value.getKindCase()) { case NULL_VALUE: return null; case NUMBER_VALUE: return value.getNumberValue(); case STRING_VALUE: return value.getStringValue(); case BOOL_VALUE: return value.getBoolValue(); case STRUCT_VALUE: return new StructMap(value.getStructValue()); case LIST_VALUE: return Lists.transform(value.getListValue().getValuesList(), VALUE_TO_OBJECT); default: throw new IllegalArgumentException(String.format("Unsupported protobuf value %s", value)); } }
hash = (37 * hash) + NUMBER_VALUE_FIELD_NUMBER; hash = (53 * hash) + com.google.protobuf.Internal.hashLong( java.lang.Double.doubleToLongBits(getNumberValue())); break; case 3:
case 2: result = result && ( java.lang.Double.doubleToLongBits(getNumberValue()) == java.lang.Double.doubleToLongBits( other.getNumberValue())); break; case 3:
private static double valueProtoToFloat64(com.google.protobuf.Value proto) { if (proto.getKindCase() == KindCase.STRING_VALUE) { switch (proto.getStringValue()) { case "-Infinity": return Double.NEGATIVE_INFINITY; case "Infinity": return Double.POSITIVE_INFINITY; case "NaN": return Double.NaN; default: // Fall-through to handling below to produce an error. } } if (proto.getKindCase() != KindCase.NUMBER_VALUE) { throw newSpannerException( ErrorCode.INTERNAL, "Invalid value for column type " + Type.float64() + " expected NUMBER_VALUE or STRING_VALUE with value one of" + " \"Infinity\", \"-Infinity\", or \"NaN\" but was " + proto.getKindCase() + (proto.getKindCase() == KindCase.STRING_VALUE ? " with value \"" + proto.getStringValue() + "\"" : "")); } return proto.getNumberValue(); }
setNumberValue(other.getNumberValue()); break;
/** * <pre> * Represents a double value. * </pre> * * <code>optional double number_value = 2;</code> */ public double getNumberValue() { return instance.getNumberValue(); } /**
private static Object parseObject(String key, Value in, VCFHeaderLineType type) { // Case on type switch (in.getKindCase()) { case NULL_VALUE: throw new IllegalStateException(String.format("field %s contained " + "a null value", key)); case NUMBER_VALUE: return getNumberValue(in.getNumberValue(), type); case STRING_VALUE: return in.getStringValue(); case BOOL_VALUE: return (Boolean) in.getBoolValue(); default: throw new IllegalStateException(String.format("field %s contained a %s type, which" + " is not supported by VariantToVcf", key, getKind(in.getKindCase()))); } }
@Override int getNumberOfMismatches(Reads.ReadAlignment alignment) { if (alignment.getInfo() != null) { ListValue values = alignment.getInfo().get("NM"); if (values != null && values.getValuesCount() == 1) { return (int) values.getValues(0).getNumberValue(); } } return 0; }
private static Object valueToObject(Value value) { switch (value.getKindCase()) { case NULL_VALUE: return null; case NUMBER_VALUE: return value.getNumberValue(); case STRING_VALUE: return value.getStringValue(); case BOOL_VALUE: return value.getBoolValue(); case STRUCT_VALUE: return new StructMap(value.getStructValue()); case LIST_VALUE: return Lists.transform(value.getListValue().getValuesList(), VALUE_TO_OBJECT); default: throw new IllegalArgumentException(String.format("Unsupported protobuf value %s", value)); } }
return any.getBoolValue(); case NUMBER_VALUE: return any.getNumberValue(); case STRING_VALUE: return any.getStringValue();
int i = 0; for (Value val : currValue) { intList[i++] = ((Double) val.getNumberValue()).intValue();
switch (val.getKindCase()) { case NUMBER_VALUE: res.append(":" + val.getNumberValue()); break; case STRING_VALUE:
private static JsonElement valueToJsonElement(Value value) { if (value.hasStructValue()) { return structToJsonObject(value.getStructValue()); } else if (value.hasListValue()) { JsonArray values = new JsonArray(); for (Value listElement : value.getListValue().getValuesList()) { values.add(valueToJsonElement(listElement)); } return values; } else if (value.getKindCase().equals(Value.KindCase.NULL_VALUE)) { return JsonNull.INSTANCE; } else if (value.getKindCase().equals(Value.KindCase.BOOL_VALUE)) { return new JsonPrimitive(value.getBoolValue()); } else if (value.getKindCase().equals(Value.KindCase.STRING_VALUE)) { return new JsonPrimitive(value.getStringValue()); } else if (value.getKindCase().equals(Value.KindCase.NUMBER_VALUE)) { return new JsonPrimitive(value.getNumberValue()); } else { throw new ClarifaiException("Unknown metadata Value field type."); } } }
@Test public void itReadsIntegralValue() throws IOException { String json = "{\"value\":1}"; HasValue valueWrapper = camelCase().readValue(json, HasValue.class); assertThat(valueWrapper.hasValue()).isTrue(); Value value = valueWrapper.getValue(); switch (value.getKindCase()) { case NUMBER_VALUE: assertThat(value.getNumberValue()).isEqualTo(1.0d); break; default: fail("Unexpected value kind: " + value.getKindCase()); } }
@Test public void itReadsFloatingPointValue() throws IOException { String json = "{\"value\":1.5}"; HasValue valueWrapper = camelCase().readValue(json, HasValue.class); assertThat(valueWrapper.hasValue()).isTrue(); Value value = valueWrapper.getValue(); switch (value.getKindCase()) { case NUMBER_VALUE: assertThat(value.getNumberValue()).isEqualTo(1.5d); break; default: fail("Unexpected value kind: " + value.getKindCase()); } }
private static double valueProtoToFloat64(com.google.protobuf.Value proto) { if (proto.getKindCase() == KindCase.STRING_VALUE) { switch (proto.getStringValue()) { case "-Infinity": return Double.NEGATIVE_INFINITY; case "Infinity": return Double.POSITIVE_INFINITY; case "NaN": return Double.NaN; default: // Fall-through to handling below to produce an error. } } if (proto.getKindCase() != KindCase.NUMBER_VALUE) { throw newSpannerException( ErrorCode.INTERNAL, "Invalid value for column type " + Type.float64() + " expected NUMBER_VALUE or STRING_VALUE with value one of" + " \"Infinity\", \"-Infinity\", or \"NaN\" but was " + proto.getKindCase() + (proto.getKindCase() == KindCase.STRING_VALUE ? " with value \"" + proto.getStringValue() + "\"" : "")); } return proto.getNumberValue(); }