Exemplo n.º 1
0
  @Override
  protected List<NormalizedNode<?, ?>> readWithContext(final DataSchemaNode schemaNode)
      throws IOException, ReadingException {
    final Optional<Class<? extends Reader<DataSchemaNode>>> customReaderClassOpt =
        tryGetCustomHandler(schemaNode);

    if (customReaderClassOpt.isPresent()) {
      // TODO resolve class cast of generic custom readers
      final Reader<DataSchemaNode> customReaderInstance =
          (Reader<DataSchemaNode>)
              argumentHandlerRegistry.getCustomReader(customReaderClassOpt.get());
      Preconditions.checkNotNull(
          customReaderInstance, "Unknown custom reader: %s", customReaderClassOpt.get());
      return customReaderInstance.read(schemaNode);
    } else {
      return readGeneric(schemaNode);
    }

    // TODO reuse instances
  }
Exemplo n.º 2
0
 private List<NormalizedNode<?, ?>> readInnerNode(final String pathString)
     throws ReadingException {
   final Optional<DataSchemaNode> schema = getCurrentNode(getSchemaContext(), pathString);
   Preconditions.checkState(schema.isPresent(), "Unable to find schema for %s", pathString);
   return commandArgHandlerRegistry.getGenericReader(getSchemaContext(), true).read(schema.get());
 }