60 lines
1.1 KiB
Java
60 lines
1.1 KiB
Java
package eu.lixko.ext.forraceexpander.components;
|
|
|
|
import java.io.Serializable;
|
|
import java.util.HashMap;
|
|
|
|
public abstract class Node implements Cloneable {
|
|
|
|
protected Parent parent = null;
|
|
protected String name = "";
|
|
protected HashMap<String, Serializable> properties = new HashMap<>();
|
|
|
|
public Node(Parent parent, String name) {
|
|
this.parent = parent;
|
|
this.name = name;
|
|
}
|
|
|
|
public Node(String name) {
|
|
this.name = name;
|
|
}
|
|
|
|
public Parent parent() {
|
|
return this.parent;
|
|
}
|
|
|
|
public String name() {
|
|
return this.name;
|
|
}
|
|
|
|
public void name(String name) {
|
|
this.name = name;
|
|
}
|
|
|
|
public HashMap<String, Serializable> getProperties() {
|
|
return this.properties;
|
|
}
|
|
|
|
public Node attr(String name, Serializable value) {
|
|
properties.put(name, value);
|
|
return this;
|
|
}
|
|
|
|
public Serializable attr(String name) {
|
|
return properties.get(name);
|
|
}
|
|
|
|
public boolean hasAttr(String name) {
|
|
return properties.containsKey(name);
|
|
}
|
|
|
|
@Override
|
|
public Node clone() throws CloneNotSupportedException {
|
|
Node n = (Node) super.clone();
|
|
n.name = this.name;
|
|
n.parent = this.parent;
|
|
n.properties = new HashMap<>(this.properties);
|
|
return n;
|
|
}
|
|
|
|
}
|