package edu.teco.dnd.blocks;

import java.util.Collections;
import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.apache.bcel.classfile.JavaClass;

public class FunctionBlockClass {
	public static final Pattern SIMPLE_CLASS_NAME_PATTERN = Pattern.compile("^(?:.*\\.)([^.]*)$");
	
	private final JavaClass cls;
	
	private final Map<String, JavaClass> inputs;
	
	private final Map<String, JavaClass> outputs;
	
	private final Set<String> options;
	
	public FunctionBlockClass(final JavaClass cls, final Map<String, JavaClass> inputs, final Map<String, JavaClass> outputs, final Set<String> options) {
		this.cls = cls;
		this.inputs = Collections.unmodifiableMap(inputs);
		this.outputs = Collections.unmodifiableMap(outputs);
		this.options = Collections.unmodifiableSet(options);
	}
	
	public Map<String, JavaClass> getOutputs() {
		return this.outputs;
	}
	
	public Map<String, JavaClass> getInputs() {
		return this.inputs;
	}
	
	public Set<String> getOptions() {
		return this.options;
	}
	
	public String getClassName() {
		return cls.getClassName();
	}
	
	public String getSimpleClassName() {
		final Matcher matcher = SIMPLE_CLASS_NAME_PATTERN.matcher(getClassName());
		if (!matcher.find()) {
			return getClassName();
		}
		return matcher.group(0);
	}
	
	public JavaClass getFunctionBlockClass() {
		return this.cls;
	}
}

@@ -1386,11 +1386,1162 @@
 .cls;%0A%09%7D
+%0A%0A%09@Override%0A%09public int hashCode() %7B%0A%09%09final int prime = 31;%0A%09%09int result = 1;%0A%09%09result = prime * result + ((cls == null) ? 0 : cls.hashCode());%0A%09%09result = prime * result + ((inputs == null) ? 0 : inputs.hashCode());%0A%09%09result = prime * result + ((options == null) ? 0 : options.hashCode());%0A%09%09result = prime * result + ((outputs == null) ? 0 : outputs.hashCode());%0A%09%09return result;%0A%09%7D%0A%0A%09@Override%0A%09public boolean equals(Object obj) %7B%0A%09%09if (this == obj)%0A%09%09%09return true;%0A%09%09if (obj == null)%0A%09%09%09return false;%0A%09%09if (getClass() != obj.getClass())%0A%09%09%09return false;%0A%09%09FunctionBlockClass other = (FunctionBlockClass) obj;%0A%09%09if (cls == null) %7B%0A%09%09%09if (other.cls != null)%0A%09%09%09%09return false;%0A%09%09%7D else if (!cls.equals(other.cls))%0A%09%09%09return false;%0A%09%09if (inputs == null) %7B%0A%09%09%09if (other.inputs != null)%0A%09%09%09%09return false;%0A%09%09%7D else if (!inputs.equals(other.inputs))%0A%09%09%09return false;%0A%09%09if (options == null) %7B%0A%09%09%09if (other.options != null)%0A%09%09%09%09return false;%0A%09%09%7D else if (!options.equals(other.options))%0A%09%09%09return false;%0A%09%09if (outputs == null) %7B%0A%09%09%09if (other.outputs != null)%0A%09%09%09%09return false;%0A%09%09%7D else if (!outputs.equals(other.outputs))%0A%09%09%09return false;%0A%09%09return true;%0A%09%7D
 %0A%7D%0A

Add hashCode, equals to FunctionBlockClass