Esempio n. 1
0
  private <T> Optional<Class<? extends T>> tryGetCustomHandler(
      final DataSchemaNode dataSchemaNode) {

    for (final UnknownSchemaNode unknownSchemaNode : dataSchemaNode.getUnknownSchemaNodes()) {

      if (isExtenstionForCustomHandler(unknownSchemaNode)) {
        final String argumentHandlerClassName = unknownSchemaNode.getNodeParameter();
        try {
          final Class<?> argumentClass = Class.forName(argumentHandlerClassName);
          // TODO add check before cast
          return Optional.<Class<? extends T>>of((Class<? extends T>) argumentClass);
        } catch (final ClassNotFoundException e) {
          throw new IllegalArgumentException(
              "Unknown custom reader class "
                  + argumentHandlerClassName
                  + " for: "
                  + dataSchemaNode.getQName());
        }
      }
    }

    return Optional.absent();
  }
Esempio n. 2
0
 private boolean isExtenstionForCustomHandler(final UnknownSchemaNode unknownSchemaNode) {
   final QName qName = unknownSchemaNode.getExtensionDefinition().getQName();
   return qName.equals(CommandConstants.ARG_HANDLER_EXT_QNAME);
 }