@Test public void testGetSchemaFullName() { String namespace = "com.linkedin.avro.fastserde"; Assert.assertEquals("STRING", SchemaAssistant.getSchemaFullName(Schema.create(Schema.Type.STRING))); Assert.assertEquals("BYTES", SchemaAssistant.getSchemaFullName(Schema.create(Schema.Type.BYTES))); Assert.assertEquals("INT", SchemaAssistant.getSchemaFullName(Schema.create(Schema.Type.INT))); Assert.assertEquals("LONG", SchemaAssistant.getSchemaFullName(Schema.create(Schema.Type.LONG))); Assert.assertEquals("FLOAT", SchemaAssistant.getSchemaFullName(Schema.create(Schema.Type.FLOAT))); Assert.assertEquals("DOUBLE", SchemaAssistant.getSchemaFullName(Schema.create(Schema.Type.DOUBLE))); Assert.assertEquals("BOOLEAN", SchemaAssistant.getSchemaFullName(Schema.create(Schema.Type.BOOLEAN))); Assert.assertEquals("NULL", SchemaAssistant.getSchemaFullName(Schema.create(Schema.Type.NULL))); Assert.assertEquals("com.linkedin.avro.fastserde.TestRecord", SchemaAssistant.getSchemaFullName(Schema.createRecord("TestRecord", "", namespace, false))); Assert.assertEquals("com.linkedin.avro.fastserde.TestFixed", SchemaAssistant.getSchemaFullName(Schema.createFixed("TestFixed", "", namespace, 16))); Assert.assertEquals("com.linkedin.avro.fastserde.TestEnum", SchemaAssistant.getSchemaFullName(Schema.createEnum("TestEnum", "", namespace, Collections .emptyList()))); }
public static String getSchemaFullName(Schema schema) { Schema.Type type = schema.getType(); boolean isNamedType = type.equals(Schema.Type.ENUM) || type.equals(Schema.Type.FIXED) || type.equals(Schema.Type.RECORD); return isNamedType ? schema.getFullName() : type.name(); }
SchemaAssistant { public static String getSchemaFullName(Schema schema) { Schema.Type type = schema.getType(); boolean isNamedType = type.equals(Schema.Type.ENUM) || type.equals(Schema.Type.FIXED) || type.equals(Schema.Type.RECORD); return isNamedType ? schema.getFullName() : type.name(); } }
SchemaAssistant { public static String getSchemaFullName(Schema schema) { Schema.Type type = schema.getType(); boolean isNamedType = type.equals(Schema.Type.ENUM) || type.equals(Schema.Type.FIXED) || type.equals(Schema.Type.RECORD); return isNamedType ? schema.getFullName() : type.name(); } SchemaAssistant(JCodeModel codeModel, boolean useGenericTypes, Class defaultStringClass, boolean isForSerializer); }
SchemaAssistant { public static String getSchemaFullName(Schema schema) { Schema.Type type = schema.getType(); boolean isNamedType = type.equals(Schema.Type.ENUM) || type.equals(Schema.Type.FIXED) || type.equals(Schema.Type.RECORD); return isNamedType ? schema.getFullName() : type.name(); } SchemaAssistant(JCodeModel codeModel, boolean useGenericTypes, Class defaultStringClass, boolean isForSerializer); static boolean isComplexType(Schema schema); static boolean isPrimitive(Schema schema); static boolean isCapableOfReuse(Schema schema); static String getSchemaFullName(Schema schema); static boolean isNamedTypeWithSchema(Schema schema); static boolean isNamedType(Schema schema); static boolean isStringable(Schema schema); static boolean hasStringableKey(Schema schema); static String getTypeName(Schema schema); void resetExceptionsFromStringable(); Set<Class<? extends Exception>> getExceptionsFromStringable(); void setExceptionsFromStringable(Set<Class<? extends Exception>> exceptionsFromStringable); JClass classFromSchema(Schema schema); JClass classFromSchema(Schema schema, boolean abstractType); JClass classFromSchema(Schema schema, boolean abstractType, boolean rawType); JClass classFromSchema(Schema schema, boolean abstractType, boolean rawType, boolean primitiveList); JClass findStringClass(Schema schema); JExpression getEnumValueByName(Schema enumSchema, JExpression nameExpr, JExpression getSchemaExpr); JExpression getEnumValueByIndex(Schema enumSchema, JExpression indexExpr, JExpression getSchemaExpr); JExpression getFixedValue(Schema schema, JExpression fixedBytesExpr, JInvocation getSchemaExpr); JExpression getStringableValue(Schema schema, JExpression stringExpr); }
SchemaAssistant { public static String getSchemaFullName(Schema schema) { Schema.Type type = schema.getType(); boolean isNamedType = type.equals(Schema.Type.ENUM) || type.equals(Schema.Type.FIXED) || type.equals(Schema.Type.RECORD); return isNamedType ? schema.getFullName() : type.name(); } SchemaAssistant(JCodeModel codeModel, boolean useGenericTypes, Class defaultStringClass, boolean isForSerializer); static boolean isComplexType(Schema schema); static boolean isPrimitive(Schema schema); static boolean isCapableOfReuse(Schema schema); static String getSchemaFullName(Schema schema); static boolean isNamedTypeWithSchema(Schema schema); static boolean isNamedType(Schema schema); static boolean isStringable(Schema schema); static boolean hasStringableKey(Schema schema); static String getTypeName(Schema schema); void resetExceptionsFromStringable(); Set<Class<? extends Exception>> getExceptionsFromStringable(); void setExceptionsFromStringable(Set<Class<? extends Exception>> exceptionsFromStringable); JClass classFromSchema(Schema schema); JClass classFromSchema(Schema schema, boolean abstractType); JClass classFromSchema(Schema schema, boolean abstractType, boolean rawType); JClass classFromSchema(Schema schema, boolean abstractType, boolean rawType, boolean primitiveList); JClass findStringClass(Schema schema); JExpression getEnumValueByName(Schema enumSchema, JExpression nameExpr, JExpression getSchemaExpr); JExpression getEnumValueByIndex(Schema enumSchema, JExpression indexExpr, JExpression getSchemaExpr); JExpression getFixedValue(Schema schema, JExpression fixedBytesExpr, JInvocation getSchemaExpr); JExpression getStringableValue(Schema schema, JExpression stringExpr); static final String CLASS_PROP; static final String KEY_CLASS_PROP; static final String STRING_PROP; static final String STRING_TYPE_STRING; }