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

com.cherokeesoft.db.utils.graph.DataJoinLayerGraphNode Maven / Gradle / Ivy

There is a newer version: 1.8.29
Show newest version
package com.cherokeesoft.db.utils.graph;

import com.cherokeesoft.db.utils.graph.type.GraphNode;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class DataJoinLayerGraphNode implements GraphNode {
    private final @Getter
    DataGraph graph;
    private final @Getter
    String fieldName;

    public DataJoinLayerGraphNode(String fieldName, DataGraph graph) {
        this.fieldName = fieldName;
        this.graph = graph;
    }

    @Override
    public Map getAlias() {
        Map res = new HashMap<>();
        Map alias = graph.aliases();
        for(String key: alias.keySet()) {
            res.put(key, fieldName + '.' + alias.get(key));
        }
        return res;
    }

    @Override
    public String getAliasName(String field) {
        Set> entries = graph.aliases().entrySet();
        for(Map.Entry entry: entries) {
            String key = entry.getKey();
            String value = entry.getValue();
            if(value.equals(field)) {
                return key;
            }
        }
        return null;
    }

    @Override
    public String[] keys() {
        return graph.keys();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy