Schemas { @Nullable public static Schema getSubSchema(final Schema schema, final CharSequence path) { if (path.length() == 0) { return schema; } List<String> parsedPath; try { parsedPath = SCHEMA_PATH_CSV.readRow(CharSequences.reader(path)); } catch (IOException ex) { throw new RuntimeException(ex); } catch (CsvParseException ex) { throw new IllegalArgumentException("Invalid path " + path, ex); } Schema result = schema; for (String part : parsedPath) { result = getSegment(result, part); if (result == null) { return null; } } return result; } private  Schemas(); static void diff(final Schema s1, final Schema s2, final Consumer<SchemaDiff> diffs); @Nullable static Schema getFromUnion(final Schema what, final Schema unionSchema); static void deprecations(final Schema schema,
          final BiConsumer<String, String> toPut); @Nonnull static ImmutableSchema immutable(final Schema schema); @Nonnull static ImmutableSchema immutable(final Schema schema, final boolean withSerializationSignificatAttrsonly); static T visit(final Schema start, final SchemaVisitor<T> visitor); static boolean isNullableUnion(final Schema schema); @Nullable static Schema nullableUnionSchema(final Schema schema); @Nullable static Schema getSchemaFromUnionByName(final Schema unionSchema, final String name); @Nullable static Schema getSubSchema(final Schema schema, final CharSequence path); static Schema projectRecord(final Schema schema, final int[] projection); @Nullable static Schema project(final Schema schema, final CharSequence... paths); @Nullable static Schema project(final Schema schema, final List<? extends CharSequence> paths); static boolean isSameFields(final List<Schema.Field> f1s, final List<Schema.Field> f2s); @Nullable static IndexedRecord project(final Schema toSchema, final Schema fromSchema,
          @Nullable final IndexedRecord object); @Nullable @SuppressFBWarnings("URV_UNRELATED_RETURN_VALUES") static Object project(final Schema toSchema, final Schema fromSchema, @Nullable final Object object); @Nullable static Schema.Field getPos(final Schema.Field field, final Schema recordSchema); @Nullable static Schema.Field getField(final String name, final Iterable<Field> fields); static boolean isNamed(final String name, final Field field); static Schema dateString(); static Schema instantString(); static Schema temporalString();  }
@Test public void testSchemaPath() { Schema subSchema = Schemas.getSubSchema(DemoRecordInfo.SCHEMA$, "demoRecord.id"); Assert.assertEquals(Schema.Type.STRING, subSchema.getType()); }
@Test public void testSchemaPath2() { Schema subSchema = Schemas.getSubSchema(Schema.createArray(DemoRecordInfo.SCHEMA$), "[].demoRecord.id"); Assert.assertEquals(Schema.Type.STRING, subSchema.getType()); }
@Test public void testSchemaPath3() { Schema subSchema = Schemas.getSubSchema(TestRecord.getClassSchema(), "children.[]"); Assert.assertEquals(Schema.Type.RECORD, subSchema.getType()); }
@Test public void testSchemaPath4() { Schema subSchema = Schemas.getSubSchema(TestRecord2.getClassSchema(), "children.[].hash"); Assert.assertEquals(Schema.Type.FIXED, subSchema.getType()); }
@Test public void testSchemaPath5() { Schema subSchema = Schemas.getSubSchema(TestRecord.getClassSchema(), "children.[].hash"); Assert.assertNull(subSchema); }