You need to have a name for your enum
.
enum NodeType { // Name of the enum is NodeType
TEXT_NODE, ATTR_NODE
}
class Node {
NodeType nodeType; // A field of type NodeType
public Node(NodeType nodeType) {
this.nodeType = nodeType;
}
}
class CreateNode {
Node returnNode() {
return new Node(NodeType.TEXT_NODE); // return the TEXT_NODE
}
}
To be able to get a Node with this NodeType
set in some other class/method, you can do something like this
// In some class
// In some method
public void someMethod(){
Node nodeWithEnumType = new CreateNode().returnNode();
// Other stuffs
}