Renamed classes

This commit is contained in:
Luca Frosini 2023-02-06 11:07:52 +01:00
parent a346762e59
commit 7a3a98549f
4 changed files with 19 additions and 16 deletions

View File

@ -4,10 +4,13 @@ import java.util.LinkedHashSet;
import java.util.Set;
import org.gcube.informationsystem.base.reference.Element;
import org.gcube.informationsystem.tree.NodeElementInformation;
import org.gcube.informationsystem.tree.NodeInformation;
import org.gcube.informationsystem.types.TypeMapper;
public class ClassElementInformation implements NodeElementInformation<Class<Element>> {
/**
* @author Luca Frosini (ISTI - CNR)
*/
public class ClassInformation implements NodeInformation<Class<Element>> {
@Override
public String getIdentifier(Class<Element> clz) {

View File

@ -71,7 +71,7 @@ public class Node<T> implements Comparable<Node<T>> {
for (int i = 0; i < level; ++i) {
stringBuffer.append(Node.INDENTATION);
}
stringBuffer.append(tree.getNodeElementInformation().getIdentifier(t));
stringBuffer.append(tree.getNodeInformation().getIdentifier(t));
for (Node<T> child : children) {
stringBuffer.append("\n");
stringBuffer.append(child.createTree(level+1));
@ -91,9 +91,9 @@ public class Node<T> implements Comparable<Node<T>> {
return -1;
}
NodeElementInformation<T> nei = tree.getNodeElementInformation();
NodeInformation<T> ni = tree.getNodeInformation();
return nei.getIdentifier(t).compareTo(nei.getIdentifier(other.t));
return ni.getIdentifier(t).compareTo(ni.getIdentifier(other.t));
}

View File

@ -2,7 +2,7 @@ package org.gcube.informationsystem.tree;
import java.util.Set;
public interface NodeElementInformation<T> {
public interface NodeInformation<T> {
public abstract String getIdentifier(T t);

View File

@ -12,12 +12,12 @@ public class Tree<T> {
private boolean allowMultipleInheritance;
private Node<T> root;
private NodeElementInformation<T> nei;
private NodeInformation<T> ni;
private Map<String, Node<T>> locate;
public Tree(T t, NodeElementInformation<T> nei) throws Exception {
this.allowMultipleInheritance = false;
this.nei = nei;
public Tree(T t, NodeInformation<T> ni) throws Exception {
this.allowMultipleInheritance = true;
this.ni = ni;
this.locate = new HashMap<>();
this.root = addNode(t);
@ -27,20 +27,20 @@ public class Tree<T> {
this.allowMultipleInheritance = allowMultipleInheritance;
}
public NodeElementInformation<T> getNodeElementInformation() {
return nei;
public NodeInformation<T> getNodeInformation() {
return ni;
}
public Node<T> addNode(T t) {
String identifier = nei.getIdentifier(t);
String identifier = ni.getIdentifier(t);
if(locate.containsKey(identifier)) {
// Has been already added
// has been already added
return locate.get(identifier);
}
Node<T> node = new Node<>(t);
Set<String> parentIdentifiers = nei.getParentIdentifiers(root.getNodeElement(), t);
Set<String> parentIdentifiers = ni.getParentIdentifiers(root.getNodeElement(), t);
for(String parentIdentifier : parentIdentifiers) {
Node<T> parentNode = locate.get(parentIdentifier);
if(parentNode==null) {
@ -55,7 +55,7 @@ public class Tree<T> {
}
this.locate.put(identifier, node);
this.nei.extraElaboration(t);
this.ni.extraElaboration(t);
return node;
}