@Override protected Object createEnum(String symbol, Schema schema) { try { Class c = ClassUtils.forName(SpecificData.getClassName(schema)); if (c == null) return super.createEnum(symbol, schema); // punt to generic return Enum.valueOf(c, symbol); } catch (Exception e) { throw new AvroRuntimeException(e); } }
@Override public Object newRecord(Object old, Schema schema) { try { Class c = ClassUtils.forName(SpecificData.getClassName(schema)); if (c == null) return newRecord(old, schema); // punt to generic if (c.isInstance(old)) return old; // reuse instance return c.getMethod("newBuilder").invoke(null); } catch (Exception e) { throw new RuntimeException(e); } }
@Override public Object newRecord(Object old, Schema schema) { try { Class c = ClassUtils.forName(SpecificData.getClassName(schema)); if (c == null) return newRecord(old, schema); // punt to generic if (c.isInstance(old)) return old; // reuse instance return c.newInstance(); // create new instance } catch (Exception e) { throw new RuntimeException(e); } }
@Override protected Object createEnum(String symbol, Schema schema) { try { Class c = ClassUtils.forName(SpecificData.getClassName(schema)); if (c == null) return super.createEnum(symbol, schema); // punt to generic return ((ProtocolMessageEnum)Enum.valueOf(c, symbol)).getValueDescriptor(); } catch (Exception e) { throw new RuntimeException(e); } }
/** * For RECORD type schemas, this method returns the SpecificData instance of the class associated with the schema, * in order to get the right conversions for any logical types used. * * @param reader the reader schema * @return the SpecificData associated with the schema's class, or the default instance. */ public static SpecificData getForSchema(Schema reader) { if (reader.getType() == Type.RECORD) { final String className = getClassName(reader); if (className != null) { final Class<?> clazz; try { clazz = Class.forName(className); return getForClass(clazz); } catch (ClassNotFoundException e) { return SpecificData.get(); } } } return SpecificData.get(); }
if (c == null) { try { c = ClassUtils.forName(getClassLoader(), getClassName(schema)); } catch (ClassNotFoundException e) { c = NO_CLASS;
if (c == null) { try { c = ClassUtils.forName(getClassLoader(), getClassName(schema)); } catch (ClassNotFoundException e) { try { // nested class?
schema = (Schema)(c.getDeclaredField("SCHEMA$").get(null)); if (!fullName.equals(getClassName(schema)))
schema = (Schema)(c.getDeclaredField("SCHEMA$").get(null)); if (!fullName.equals(getClassName(schema)))
@Override public Object newRecord(Object old, Schema schema) { try { Class c = ClassUtils.forName(SpecificData.getClassName(schema)); if (c == null) return newRecord(old, schema); // punt to generic if (c.isInstance(old)) return old; // reuse instance return c.getMethod("newBuilder").invoke(null); } catch (Exception e) { throw new RuntimeException(e); } }
@Override protected Object createEnum(String symbol, Schema schema) { try { Class c = ClassUtils.forName(SpecificData.getClassName(schema)); if (c == null) return super.createEnum(symbol, schema); // punt to generic return ((ProtocolMessageEnum)Enum.valueOf(c, symbol)).getValueDescriptor(); } catch (Exception e) { throw new RuntimeException(e); } }
if (c == null) { try { c = Class.forName(getClassName(schema)); classCache.put(name, c); } catch (ClassNotFoundException e) {
if (c == null) { try { c = Class.forName(getClassName(schema)); } catch (ClassNotFoundException e) { c = NO_CLASS;
if (c == null) { try { c = getClassLoader().loadClass(getClassName(schema)); } catch (ClassNotFoundException e) { c = NO_CLASS;
if (c == null) { try { c = ClassUtils.forName(getClassLoader(), getClassName(schema)); } catch (ClassNotFoundException e) { c = NO_CLASS;
schema = (Schema)(c.getDeclaredField("SCHEMA$").get(null)); if (!fullName.equals(getClassName(schema)))
schema = (Schema)(c.getDeclaredField("SCHEMA$").get(null)); if (!fullName.equals(getClassName(schema)))