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

org.vertexium.sql.SqlGraphMetadataStore Maven / Gradle / Ivy

There is a newer version: 3.2.3
Show newest version
package org.vertexium.sql;

import org.vertexium.GraphMetadataEntry;
import org.vertexium.GraphMetadataStore;
import org.vertexium.sql.collections.SqlMap;
import org.vertexium.util.ConvertingIterable;

import java.util.Map;

public class SqlGraphMetadataStore extends GraphMetadataStore {
    private final SqlMap metadata;

    public SqlGraphMetadataStore(SqlMap metadata) {
        this.metadata = metadata;
    }

    @Override
    public Object getMetadata(String key) {
        return metadata.get(key);
    }

    @Override
    public Iterable getMetadata() {
        return new ConvertingIterable, GraphMetadataEntry>(metadata.entrySet()) {
            @Override
            protected GraphMetadataEntry convert(Map.Entry o) {
                return new GraphMetadataEntry(o.getKey(), o.getValue());
            }
        };
    }

    @Override
    public void setMetadata(String key, Object value) {
        metadata.put(key, value);
    }
}