public synchronized MetadataRegistry registerClass(Class<? extends Element> clazz){
  if (Element.class == clazz) {
    return this;
  }
  try {
    Method registerMethod=clazz.getDeclaredMethod("registerMetadata",MetadataRegistry.class);
    if (!Modifier.isStatic(registerMethod.getModifiers())) {
      throw new IllegalArgumentException("Class " + clazz + " had a non-static registerMetadata(MetadataRegistry) method.");
    }
    registerMethod.invoke(null,this);
    return this;
  }
 catch (  SecurityException e) {
    throw new IllegalArgumentException(e);
  }
catch (  NoSuchMethodException e) {
    throw new IllegalArgumentException("Class " + clazz + " doesn't support metadata registration.",e);
  }
catch (  IllegalAccessException e) {
    throw new IllegalArgumentException(e);
  }
catch (  InvocationTargetException e) {
    throw new IllegalArgumentException(e.getCause());
  }
}

public synchronized MetadataRegistry registerClass ( Class < ? extends Element > clazz ) { if ( Element . class == clazz ) { return this ; } try { Method registerMethod = clazz . getDeclaredMethod ( "registerMetadata" , MetadataRegistry . class ) ; if ( ! Modifier . isStatic ( registerMethod . getModifiers ( ) ) ) { throw new IllegalArgumentException ( "Class " + clazz + " had a non-static registerMetadata(MetadataRegistry) method." ) ; } registerMethod . invoke ( null , this ) ; return this ; } catch ( SecurityException e ) { throw new IllegalArgumentException ( e ) ; } catch ( NoSuchMethodException e ) { throw new IllegalArgumentException ( "Class " + clazz + " doesn't support metadata registration." , e ) ; } catch ( IllegalAccessException e ) { throw new IllegalArgumentException ( e ) ; } catch ( InvocationTargetException e ) { throw new IllegalArgumentException ( e . getCause ( ) ) ; } }
registers the metadata from an element subclass using its " registermetadata " method through reflection .
