@Test public void readBigQuerySchemaCanThrowIllegalAccessException() { Json.SCHEMA_FROM_PB.setAccessible(false); try { RuntimeException thrown = assertThrows(RuntimeException.class, () -> Json.readBigQuerySchema("[]".getBytes(StandardCharsets.UTF_8))); assertTrue(thrown.getCause() instanceof IllegalAccessException); } finally { Json.SCHEMA_FROM_PB.setAccessible(true); } }
public static Schema readBigQuerySchema(byte[] data) throws IOException { List<TableFieldSchema> fieldsList = (List<TableFieldSchema>) JSON_FACTORY .createJsonParser(new String(data, Charsets.UTF_8)) .parseArray(ArrayList.class, TableFieldSchema.class); TableSchema tableSchema = new TableSchema().setFields(fieldsList); try { return (Schema) SCHEMA_FROM_PB.invoke(null, tableSchema); } catch (IllegalAccessException | InvocationTargetException e) { throw new RuntimeException(e); } }
Json { public static Schema readBigQuerySchema(byte[] data) throws IOException { List<TableFieldSchema> fieldsList = (List<TableFieldSchema>) JSON_FACTORY .createJsonParser(new String(data, Charsets.UTF_8)) .parseArray(ArrayList.class, TableFieldSchema.class); TableSchema tableSchema = new TableSchema().setFields(fieldsList); try { return (Schema) SCHEMA_FROM_PB.invoke(null, tableSchema); } catch (IllegalAccessException | InvocationTargetException e) { throw new RuntimeException(e); } } }
Json { public static Schema readBigQuerySchema(byte[] data) throws IOException { List<TableFieldSchema> fieldsList = (List<TableFieldSchema>) JSON_FACTORY .createJsonParser(new String(data, Charsets.UTF_8)) .parseArray(ArrayList.class, TableFieldSchema.class); TableSchema tableSchema = new TableSchema().setFields(fieldsList); try { return (Schema) SCHEMA_FROM_PB.invoke(null, tableSchema); } catch (IllegalAccessException | InvocationTargetException e) { throw new RuntimeException(e); } }  }
Json { public static Schema readBigQuerySchema(byte[] data) throws IOException { List<TableFieldSchema> fieldsList = (List<TableFieldSchema>) JSON_FACTORY .createJsonParser(new String(data, Charsets.UTF_8)) .parseArray(ArrayList.class, TableFieldSchema.class); TableSchema tableSchema = new TableSchema().setFields(fieldsList); try { return (Schema) SCHEMA_FROM_PB.invoke(null, tableSchema); } catch (IllegalAccessException | InvocationTargetException e) { throw new RuntimeException(e); } }  static String asString(JsonNode data); static String asString(Object data); static byte[] asBytes(JsonNode data); static byte[] asBytes(Object data); static ObjectNode asObjectNode(Map<String, ?> map); static Map<String, Object> asMap(ObjectNode objectNode); static T convertValue(TreeNode root, Class<T> klass); @VisibleForTesting static T convertValue(TreeNode root, TypeReference<T> typeReference); static Schema readBigQuerySchema(byte[] data); static T readValue(byte[] data, Class<T> klass); static ObjectNode readObjectNode(byte[] data); static ObjectNode readObjectNode(String data); static ArrayNode readArrayNode(byte[] data); static Map<String, Object> readMap(String data); static ObjectNode createObjectNode(); static ArrayNode createArrayNode(); static boolean isNullOrEmpty(ObjectNode node); static boolean isNullOrEmpty(JsonNode node); }
Json { public static Schema readBigQuerySchema(byte[] data) throws IOException { List<TableFieldSchema> fieldsList = (List<TableFieldSchema>) JSON_FACTORY .createJsonParser(new String(data, Charsets.UTF_8)) .parseArray(ArrayList.class, TableFieldSchema.class); TableSchema tableSchema = new TableSchema().setFields(fieldsList); try { return (Schema) SCHEMA_FROM_PB.invoke(null, tableSchema); } catch (IllegalAccessException | InvocationTargetException e) { throw new RuntimeException(e); } }  static String asString(JsonNode data); static String asString(Object data); static byte[] asBytes(JsonNode data); static byte[] asBytes(Object data); static ObjectNode asObjectNode(Map<String, ?> map); static Map<String, Object> asMap(ObjectNode objectNode); static T convertValue(TreeNode root, Class<T> klass); @VisibleForTesting static T convertValue(TreeNode root, TypeReference<T> typeReference); static Schema readBigQuerySchema(byte[] data); static T readValue(byte[] data, Class<T> klass); static ObjectNode readObjectNode(byte[] data); static ObjectNode readObjectNode(String data); static ArrayNode readArrayNode(byte[] data); static Map<String, Object> readMap(String data); static ObjectNode createObjectNode(); static ArrayNode createArrayNode(); static boolean isNullOrEmpty(ObjectNode node); static boolean isNullOrEmpty(JsonNode node);  }