SchemaFactory { static Fields newFields(StructTypeInfo structTypeInfo) { List<String> existingNames = structTypeInfo.getAllStructFieldNames(); List<String> namesList = new ArrayList<>(existingNames.size()); namesList.addAll(existingNames); String[] names = namesList.toArray(new String[namesList.size()]); List<TypeInfo> typeInfos = structTypeInfo.getAllStructFieldTypeInfos(); Class<?>[] types = new Class[typeInfos.size()]; for (int i = 0; i < types.length; i++) { Class<?> type = PRIMITIVES.get(typeInfos.get(i)); if (type == null) { type = Object.class; } types[i] = type; } return new Fields(names, types); } private  SchemaFactory();   }
@Test public void createFields() { StructTypeInfo typeInfo = new StructTypeInfoBuilder() .add("a", TypeInfoFactory.stringTypeInfo) .add("b", TypeInfoFactory.binaryTypeInfo) .add("c", TypeInfoFactory.getCharTypeInfo(1)) .add("d", TypeInfoFactory.getVarcharTypeInfo(1)) .add("e", TypeInfoFactory.getDecimalTypeInfo(1, 0)) .add("f", TypeInfoFactory.getListTypeInfo(TypeInfoFactory.stringTypeInfo)) .add("g", TypeInfoFactory.getMapTypeInfo(TypeInfoFactory.stringTypeInfo, TypeInfoFactory.stringTypeInfo)) .add("h", TypeInfoFactory .getUnionTypeInfo(Arrays.asList((TypeInfo) TypeInfoFactory.stringTypeInfo, TypeInfoFactory.intTypeInfo))) .add("i", new StructTypeInfoBuilder().add("x", TypeInfoFactory.stringTypeInfo).build()) .build(); Fields fields = SchemaFactory.newFields(typeInfo); Class<?>[] types = fields.getTypesClasses(); assertThat(types[0], is((Object) String.class)); assertThat(types[1], is((Object) byte[].class)); assertThat(types[2], is((Object) Object.class)); assertThat(types[3], is((Object) Object.class)); assertThat(types[4], is((Object) Object.class)); assertThat(types[5], is((Object) Object.class)); assertThat(types[6], is((Object) Object.class)); assertThat(types[7], is((Object) Object.class)); assertThat(types[8], is((Object) Object.class)); }