metrics NEATC and NEIPO added
diff --git a/org.eclipse.emf.refactor.metrics.uml24/bin/org/eclipse/emf/refactor/metrics/uml24/umlcl/NEATC.class b/org.eclipse.emf.refactor.metrics.uml24/bin/org/eclipse/emf/refactor/metrics/uml24/umlcl/NEATC.class
new file mode 100644
index 0000000..b072eb5
--- /dev/null
+++ b/org.eclipse.emf.refactor.metrics.uml24/bin/org/eclipse/emf/refactor/metrics/uml24/umlcl/NEATC.class
Binary files differ
diff --git a/org.eclipse.emf.refactor.metrics.uml24/bin/org/eclipse/emf/refactor/metrics/uml24/umlop/NEIPO.class b/org.eclipse.emf.refactor.metrics.uml24/bin/org/eclipse/emf/refactor/metrics/uml24/umlop/NEIPO.class
new file mode 100644
index 0000000..871cc05
--- /dev/null
+++ b/org.eclipse.emf.refactor.metrics.uml24/bin/org/eclipse/emf/refactor/metrics/uml24/umlop/NEIPO.class
Binary files differ
diff --git a/org.eclipse.emf.refactor.metrics.uml24/plugin.xml b/org.eclipse.emf.refactor.metrics.uml24/plugin.xml
index b8e07c4..82b27dd 100644
--- a/org.eclipse.emf.refactor.metrics.uml24/plugin.xml
+++ b/org.eclipse.emf.refactor.metrics.uml24/plugin.xml
@@ -17,4 +17,22 @@
metric_name="TNCP">
</metric>
</extension>
+<extension point="org.eclipse.emf.refactor.metrics">
+<metric id="org.eclipse.emf.refactor.metrics.uml24.neatc"
+ metric_calculate_class="org.eclipse.emf.refactor.metrics.uml24.umlcl.NEATC"
+ metric_context="Class"
+ metric_description="Number of equal attributes with other classes"
+ metric_metamodel="http://www.eclipse.org/uml2/4.0.0/UML"
+ metric_name="NEATC">
+</metric>
+</extension>
+<extension point="org.eclipse.emf.refactor.metrics">
+<metric id="org.eclipse.emf.refactor.metrics.uml24.neipo"
+ metric_calculate_class="org.eclipse.emf.refactor.metrics.uml24.umlop.NEIPO"
+ metric_context="Operation"
+ metric_description="Number of equal input-parameters in sibling operations"
+ metric_metamodel="http://www.eclipse.org/uml2/4.0.0/UML"
+ metric_name="NEIPO">
+</metric>
+</extension>
</plugin>
diff --git a/org.eclipse.emf.refactor.metrics.uml24/src/org/eclipse/emf/refactor/metrics/uml24/umlcl/NEATC.java b/org.eclipse.emf.refactor.metrics.uml24/src/org/eclipse/emf/refactor/metrics/uml24/umlcl/NEATC.java
new file mode 100644
index 0000000..65e784b
--- /dev/null
+++ b/org.eclipse.emf.refactor.metrics.uml24/src/org/eclipse/emf/refactor/metrics/uml24/umlcl/NEATC.java
@@ -0,0 +1,100 @@
+package org.eclipse.emf.refactor.metrics.uml24.umlcl;
+
+import java.util.List;
+
+import org.eclipse.emf.common.util.BasicEList;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.TreeIterator;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.refactor.metrics.interfaces.IMetricCalculator;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.Property;
+
+public final class NEATC implements IMetricCalculator {
+
+ private List<EObject> context;
+
+ @Override
+ public void setContext(List<EObject> context) {
+ this.context=context;
+ }
+
+ @Override
+ public double calculate() {
+ Class cl = (Class) context.get(0);
+ double result = 0.0;
+ // custom code - begin
+ EList<Class> otherClasses = getOtherClassses(cl);
+ if (otherClasses.isEmpty()) return result;
+ Double[] maxEqualAttributes = new Double[otherClasses.size()];
+ for (int i=0; i < maxEqualAttributes.length; i++) maxEqualAttributes[i] = 0.0;
+ for (Property attr : cl.getOwnedAttributes()) {
+ for (int i=0; i < otherClasses.size(); i++) {
+ if (containsEqualAttribute(otherClasses.get(i), attr)) {
+ maxEqualAttributes[i]++;
+ }
+ }
+ }
+ result = max(maxEqualAttributes);
+ // custom code - end
+ return result;
+ }
+
+ private double max(Double[] doubleArray) {
+ Double result = 0.0;
+ for (int i=0; i < doubleArray.length; i++) {
+ if (doubleArray[i] > result) {
+ result = doubleArray[i];
+ }
+ }
+ return result;
+ }
+
+ private boolean containsEqualAttribute(Class c, Property attr) {
+ boolean contains = false;
+ for (Property att : c.getOwnedAttributes()) {
+ if (haveEqualNames(attr, att)
+ && haveEqualTypes(attr, att)
+ && haveEqualVisibility(attr, att)
+ && haveEqualMultiplicities(attr, att)) {
+ contains = true;
+ break;
+ }
+ }
+ return contains;
+ }
+
+ private boolean haveEqualMultiplicities(Property attr, Property att) {
+ return ((attr.getLower() == att.getLower()) && (attr.getUpper() == att.getUpper()));
+ }
+
+ private boolean haveEqualVisibility(Property attr, Property att) {
+ return attr.getVisibility().equals(att.getVisibility());
+ }
+
+ private boolean haveEqualTypes(Property attr, Property att) {
+ return ((att.getType() == null) && (attr.getType() == null)) ||
+ ((att.getType() != null) && (attr.getType() != null)) && (att.getType().equals(attr.getType()));
+ }
+
+ private boolean haveEqualNames(Property attr, Property att) {
+ if (attr == null || att == null) return false;
+ if (attr.getName() == null || att.getName() == null) return false;
+ return att.getName().equals(attr.getName());
+ }
+
+ private EList<Class> getOtherClassses(Class cl) {
+ EList<Class> otherClasses = new BasicEList<Class>();
+ TreeIterator<EObject> iter = context.get(0).eResource().getAllContents();
+ while (iter.hasNext()) {
+ EObject eObject = iter.next();
+ if (eObject instanceof Class) {
+ Class otherClass = (Class) eObject;
+ if (!otherClass.equals(cl)) {
+ otherClasses.add(otherClass);
+ }
+ }
+ }
+ return otherClasses;
+ }
+}
\ No newline at end of file
diff --git a/org.eclipse.emf.refactor.metrics.uml24/src/org/eclipse/emf/refactor/metrics/uml24/umlop/NEIPO.java b/org.eclipse.emf.refactor.metrics.uml24/src/org/eclipse/emf/refactor/metrics/uml24/umlop/NEIPO.java
new file mode 100644
index 0000000..ec456da
--- /dev/null
+++ b/org.eclipse.emf.refactor.metrics.uml24/src/org/eclipse/emf/refactor/metrics/uml24/umlop/NEIPO.java
@@ -0,0 +1,109 @@
+package org.eclipse.emf.refactor.metrics.uml24.umlop;
+
+import java.util.List;
+
+import org.eclipse.emf.common.util.BasicEList;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.refactor.metrics.interfaces.IMetricCalculator;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.Operation;
+import org.eclipse.uml2.uml.Parameter;
+import org.eclipse.uml2.uml.ParameterDirectionKind;
+
+public final class NEIPO implements IMetricCalculator {
+
+ private List<EObject> context;
+
+ @Override
+ public void setContext(List<EObject> context) {
+ this.context=context;
+ }
+
+ @Override
+ public double calculate() {
+ Operation op = (Operation) context.get(0);
+ if (op.getClass_() != null) {
+ return getNumberOfEqualParametersInSiblingOperations(op);
+ } else {
+ return 0.0;
+ }
+ }
+
+ private double getNumberOfEqualParametersInSiblingOperations(Operation op) {
+ double result = 0.0;
+ Class owningClass = op.getClass_();
+ EList<Operation> siblingOperations = getSiblingOperations(owningClass, op);
+ if (siblingOperations.isEmpty()) return result;
+ Double[] maxEqualParameters = new Double[siblingOperations.size()];
+ for (int i=0; i < maxEqualParameters.length; i++) maxEqualParameters[i] = 0.0;
+ for (Parameter param : op.getOwnedParameters()) {
+ if (param.getDirection().getValue() == ParameterDirectionKind.IN ||
+ param.getDirection().getValue() == ParameterDirectionKind.INOUT) {
+ for (int i=0; i < siblingOperations.size(); i++) {
+ if (containsEqualParameter(siblingOperations.get(i), param)) {
+ maxEqualParameters[i]++;
+ }
+ }
+ }
+ }
+ result = max(maxEqualParameters);
+ return result;
+ }
+
+ private double max(Double[] doubleArray) {
+ Double result = 0.0;
+ for (int i=0; i < doubleArray.length; i++) {
+ if (doubleArray[i] > result) {
+ result = doubleArray[i];
+ }
+ }
+ return result;
+ }
+
+ private boolean containsEqualParameter(Operation op, Parameter param) {
+ boolean contains = false;
+ for (Parameter p : op.getOwnedParameters()) {
+ if (haveEqualDirections(p, param)
+ && haveEqualNames(p, param)
+ && haveEqualTypes(p, param)
+ && haveEqualVisibility(p, param)
+ && haveEqualMultiplicities(p, param) ) {
+ contains = true;
+ break;
+ }
+ }
+ return contains;
+ }
+
+ private boolean haveEqualMultiplicities(Parameter p, Parameter param) {
+ return ((p.getLower() == param.getLower()) && (p.getUpper() == param.getUpper()));
+ }
+
+ private boolean haveEqualVisibility(Parameter p, Parameter param) {
+ return p.getVisibility().equals(param.getVisibility());
+ }
+
+ private boolean haveEqualTypes(Parameter p, Parameter param) {
+ return ((p.getType() == null) && (param.getType() == null)) ||
+ ((p.getType() != null) && (param.getType() != null)) && (p.getType().equals(param.getType()));
+ }
+
+ private boolean haveEqualNames(Parameter p, Parameter param) {
+ return p.getName().equals(param.getName());
+ }
+
+ private boolean haveEqualDirections(Parameter p, Parameter param) {
+ return (p.getDirection().getValue() == param.getDirection().getValue());
+ }
+
+ private EList<Operation> getSiblingOperations(Class owningClass, Operation op) {
+ EList<Operation> siblingOperations = new BasicEList<Operation>();
+ for (Operation oper : owningClass.getOwnedOperations()) {
+ if (! oper.equals(op)) {
+ siblingOperations.add(oper);
+ }
+ }
+ return siblingOperations;
+ }
+}
\ No newline at end of file