Java Code Examples for com.google.protobuf.Value#getBoolValue()

The following examples show how to use com.google.protobuf.Value#getBoolValue() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StructUtil.java    From rejoiner with Apache License 2.0 6 votes vote down vote up
private static Object getScalarValue(Value value) {
  switch (value.getKindCase()) {
    case STRUCT_VALUE:
    case LIST_VALUE:
      throw new AssertionError("value should be scalar");
    case BOOL_VALUE:
      return value.getBoolValue();
    case NUMBER_VALUE:
      // Note: this assumes all numbers are doubles. Downstream code that have access to the
      // schema can convert this number to the correct number type.
      return value.getNumberValue();
    case STRING_VALUE:
      return value.getStringValue();
    default:
      break;
  }
  return value;
}
 
Example 2
Source File: VariantToVcf.java    From genomewarp with Apache License 2.0 5 votes vote down vote up
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())));
  }
}
 
Example 3
Source File: ValueUtils.java    From cloud-spanner-r2dbc with Apache License 2.0 4 votes vote down vote up
private static Boolean parseBoolean(Value input) {
  return input.getKindCase() == KindCase.NULL_VALUE ? null : input.getBoolValue();
}