private Schema getSchema(Class<?> clazz) { ClassIntrospector introspector = new ClassIntrospector(clazz); Config config = introspector.getAnnotation(Config.class); if (config == null) { throw CFG102_NOT_CONFIGURABLE(clazz); } String schemaName = config.name(); if (schemaName == null || "".equals(schemaName)) { schemaName = clazz.getName(); } return schemaManager.getSchema(schemaName); } }
@Override public Schema convert(Class<?> source, Class<? extends Schema> specificType) { ClassIntrospector introspector = new ClassIntrospector(source); Config config = introspector.getAnnotation(Config.class); if (config == null) { throw CFG102_NOT_CONFIGURABLE(source); } SchemaId schemaId = getId(introspector); String schemaName = config.name(); if (schemaName == null || "".equals(schemaName)) { schemaName = source.getName(); } Schema schema = Schema.create(schemaId, introspector.getName(), schemaName, config.desc()); Collection<Object> fields = new ArrayList<Object>(); fields.addAll(introspector.getFieldList(Config.class)); Collection<AbstractSchemaProperty> props = conversion.convert(fields, AbstractSchemaProperty.class); for (AbstractSchemaProperty abstractProp : props) { schema.add(abstractProp); } return schema; }
private Schema getSchema(Class<?> clazz) { Schema schema = schemas.get(clazz); if(schema != null) { return schema; } ClassIntrospector introspector = new ClassIntrospector(clazz); Config config = introspector.getAnnotation(Config.class); if (config == null) { throw CFG102_NOT_CONFIGURABLE(clazz); } String schemaName = config.name(); if (schemaName == null || "".equals(schemaName)) { schemaName = clazz.getName(); } schema = conversion.convert(clazz, Schema.class); for (Class<?> cls : schema.getReferenceSchemaTypes()) { if (schemas.get(clazz) != null) { getSchema(cls); } } properties.registerSchema(schema); schemas.put(schema.getName(), schema); schemaManager.registerSchema(schema); core.putIndex(schema); return schema; } }
@Override public Schema convert(Class<?> source, Class<? extends Schema> specificType) { ClassIntrospector introspector = new ClassIntrospector(source); Config config = introspector.getAnnotation(Config.class); if (config == null) { throw CFG102_NOT_CONFIGURABLE(source); } SchemaId schemaId = getId(introspector); if (schemaId == null) { // get instance does not have @Id annotations so we create // it from the @Config annotation schemaId = SchemaId.create(config.name(), config.desc(), true); } String schemaName = config.name(); if (schemaName == null || "".equals(schemaName)) { schemaName = source.getName(); } Schema schema = Schema.create(schemaId, introspector.getName(), schemaName, config.desc()); Collection<Object> fields = new ArrayList<>(); fields.addAll(introspector.getNonStaticFieldList()); Collection<AbstractSchemaProperty> props = conversion.convert(fields, AbstractSchemaProperty.class); for (AbstractSchemaProperty abstractProp : props) { schema.add(abstractProp); } return schema; }