Пример #1
0
  @SuppressWarnings("unchecked")
  public static Class<UpdatableRecord<?>> getRecordClass(SchemaFactory factory, Class<?> clz) {
    if (UpdatableRecord.class.isAssignableFrom(clz)) {
      return (Class<UpdatableRecord<?>>) clz;
    }

    if (factory != null) {
      Schema schema = factory.getSchema(clz);
      Class<?> testClz = factory.getSchemaClass(schema.getId());
      if (clz.isAssignableFrom(testClz)) {
        if (!UpdatableRecord.class.isAssignableFrom(testClz)) {
          throw new IllegalArgumentException(
              "Class [" + testClz + "] is not an instanceof UpdatableRecord");
        }
        return (Class<UpdatableRecord<?>>) testClz;
      }
    }

    throw new IllegalArgumentException("Failed to find UpdatableRecord class for [" + clz + "]");
  }
Пример #2
0
 @Override
 public Schema getSchema(String type) {
   Schema parentSchema = schemaFactory.getSchema(type);
   return parentSchema == null ? null : schemaMap.get(parentSchema.getId());
 }