Beispiel #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 + "]");
  }
Beispiel #2
0
 @Override
 public Class<?> getSchemaClass(String type) {
   Schema schema = getSchema(type);
   return schema == null ? null : schemaFactory.getSchemaClass(type);
 }