org.drools.impl.adapters.NodeAdapter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of knowledge-api Show documentation
Show all versions of knowledge-api Show documentation
The Drools and jBPM public API which is backwards compatible between releases.
package org.drools.impl.adapters;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.drools.definition.process.Connection;
import org.drools.definition.process.NodeContainer;
import org.kie.api.definition.process.Node;
public class NodeAdapter implements org.drools.definition.process.Node {
public Node delegate;
public NodeAdapter(Node delegate) {
this.delegate = delegate;
}
public Node getDelegate() {
return delegate;
}
public long getId() {
return delegate.getId();
}
public String getName() {
return delegate.getName();
}
public Map> getIncomingConnections() {
return adaptConnectionMap(delegate.getIncomingConnections());
}
public Map> getOutgoingConnections() {
return adaptConnectionMap(delegate.getOutgoingConnections());
}
public List getIncomingConnections(String type) {
return adaptConnectionList(delegate.getIncomingConnections(type));
}
public List getOutgoingConnections(String type) {
return adaptConnectionList(delegate.getOutgoingConnections(type));
}
public NodeContainer getNodeContainer() {
return new NodeContainerAdapter(delegate.getNodeContainer());
}
public Map getMetaData() {
return delegate.getMetaData();
}
public Object getMetaData(String name) {
return delegate.getMetaData().get(name);
}
private Map> adaptConnectionMap(Map> connections) {
if (connections == null) {
return null;
}
Map> result = new HashMap>();
for (Map.Entry> entry: connections.entrySet()) {
result.put(entry.getKey(), adaptConnectionList(entry.getValue()));
}
return result;
}
private List adaptConnectionList(List connections) {
if (connections == null) {
return null;
}
List result = new ArrayList(connections.size());
for (org.kie.api.definition.process.Connection connection: connections) {
result.add(new ConnectionAdapter(connection));
}
return result;
}
@Override
public int hashCode() {
return delegate.hashCode();
}
@Override
public boolean equals(Object obj) {
return obj instanceof NodeAdapter && delegate.equals(((NodeAdapter)obj).delegate);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy