com.cherokeesoft.db.utils.graph.DataJoinLayerGraphNode Maven / Gradle / Ivy
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 extends String, ? extends String> getAlias() {
Map res = new HashMap<>();
Map extends String, ? extends String> 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();
}
}