@Override public Boolean apply(com.google.protobuf.Value input) { return input.getKindCase() == KindCase.NULL_VALUE ? null : input.getBoolValue(); } });
return null; case BOOL_VALUE: return any.getBoolValue(); case NUMBER_VALUE: return any.getNumberValue();
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) + BOOL_VALUE_FIELD_NUMBER; hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( getBoolValue()); break; case 5:
break; case 4: result = result && (getBoolValue() == other.getBoolValue()); break; case 5:
case BOOL: checkType(fieldType, proto, KindCase.BOOL_VALUE); return proto.getBoolValue(); case INT64: checkType(fieldType, proto, KindCase.STRING_VALUE);
setBoolValue(other.getBoolValue()); break;
/** * <pre> * Represents a boolean value. * </pre> * * <code>optional bool bool_value = 4;</code> */ public boolean getBoolValue() { return instance.getBoolValue(); } /**
@Override public Boolean apply(com.google.protobuf.Value input) { return input.getKindCase() == KindCase.NULL_VALUE ? null : input.getBoolValue(); } });
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()))); } }
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 null; case BOOL_VALUE: return any.getBoolValue(); case NUMBER_VALUE: return any.getNumberValue();
@Test public void itReadsBooleanValue() throws IOException { String json = "{\"value\":true}"; HasValue valueWrapper = camelCase().readValue(json, HasValue.class); assertThat(valueWrapper.hasValue()).isTrue(); Value value = valueWrapper.getValue(); switch (value.getKindCase()) { case BOOL_VALUE: assertThat(value.getBoolValue()).isTrue(); break; default: fail("Unexpected value kind: " + value.getKindCase()); } }
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."); } } }
case BOOL: checkType(fieldType, proto, KindCase.BOOL_VALUE); return proto.getBoolValue(); case INT64: checkType(fieldType, proto, KindCase.STRING_VALUE);