All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.exasol.adapter.document.documentnode.objectwrapper.ListWrapperNode Maven / Gradle / Ivy

The newest version!
package com.exasol.adapter.document.documentnode.objectwrapper;

import java.util.List;
import java.util.stream.Collectors;

import com.exasol.adapter.document.documentnode.DocumentArray;
import com.exasol.adapter.document.documentnode.DocumentNode;

/**
 * This class wraps list of java objects as {@link DocumentNode}.
 */
class ListWrapperNode implements DocumentArray {
    /** @serial */
    private final List values;

    ListWrapperNode(final List values) {
        this.values = values;
    }

    @Override
    public List getValuesList() {
        return this.values.stream().map(ObjectWrapperDocumentNodeFactory::getNodeFor).collect(Collectors.toList());
    }

    @Override
    public DocumentNode getValue(final int index) {
        return ObjectWrapperDocumentNodeFactory.getNodeFor(this.values.get(index));
    }

    @Override
    public int size() {
        return this.values.size();
    }
}