From de065f88ab5499c26a1c124ae5c44954689cfccf Mon Sep 17 00:00:00 2001
From: Florian Hoelzl <hoelzl@fortiss.org>
Date: Tue, 3 Jan 2012 14:44:19 +0000
Subject: [PATCH] added improved base class => YELLOW refs 437

---
 .../extension/base/ConstraintCheckerBase.java |  6 +-
 .../base/ConstraintViolationBase.java         |  2 +-
 .../MultiViolationConstraintCheckerBase.java  | 56 +++++++++++++++++++
 3 files changed, 62 insertions(+), 2 deletions(-)
 create mode 100644 org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/extension/base/MultiViolationConstraintCheckerBase.java

diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/extension/base/ConstraintCheckerBase.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/extension/base/ConstraintCheckerBase.java
index bda4feb1f..575991fbc 100644
--- a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/extension/base/ConstraintCheckerBase.java
+++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/extension/base/ConstraintCheckerBase.java
@@ -28,10 +28,14 @@ import org.fortiss.tooling.kernel.extension.data.IConstraintViolation;
  * Base implementation for {@link IConstraintChecker}. It checks the model
  * element against null and returns an unmodifiable empty list.
  * 
+ * @param <T>
+ *            the model element class for elements to be checked by this
+ *            constraint checker.
+ * 
  * @author mou
  * @author $Author$
  * @version $Rev$
- * @ConQAT.Rating YELLOW Hash: 71E7C7994B89DFF53782600DB00DF8E1
+ * @ConQAT.Rating YELLOW Hash: 7A816E37EB8FA7634E27A501CA5C99A3
  */
 public abstract class ConstraintCheckerBase<T extends EObject> implements
 		IConstraintChecker<T> {
diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/extension/base/ConstraintViolationBase.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/extension/base/ConstraintViolationBase.java
index 25b87cba1..ff024fbdb 100644
--- a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/extension/base/ConstraintViolationBase.java
+++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/extension/base/ConstraintViolationBase.java
@@ -29,7 +29,7 @@ import org.fortiss.tooling.kernel.extension.data.IConstraintViolation;
  * @author hoelzl
  * @author $Author$
  * @version $Rev$
- * @ConQAT.Rating YELLOW Hash: 9DA8E3ED348BEB666713A27DF89CBD64
+ * @ConQAT.Rating YELLOW Hash: CC17BC4ED54FFD8211F02C90443F77C8
  */
 public class ConstraintViolationBase<T extends EObject> implements
 		IConstraintViolation<T> {
diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/extension/base/MultiViolationConstraintCheckerBase.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/extension/base/MultiViolationConstraintCheckerBase.java
new file mode 100644
index 000000000..2b12c06e8
--- /dev/null
+++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/extension/base/MultiViolationConstraintCheckerBase.java
@@ -0,0 +1,56 @@
+/*--------------------------------------------------------------------------+
+$Id$
+|                                                                          |
+| Copyright 2011 ForTISS GmbH                     |
+|                                                                          |
+| Licensed under the Apache License, Version 2.0 (the "License");          |
+| you may not use this file except in compliance with the License.         |
+| You may obtain a copy of the License at                                  |
+|                                                                          |
+|    http://www.apache.org/licenses/LICENSE-2.0                            |
+|                                                                          |
+| Unless required by applicable law or agreed to in writing, software      |
+| distributed under the License is distributed on an "AS IS" BASIS,        |
+| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
+| See the License for the specific language governing permissions and      |
+| limitations under the License.                                           |
++--------------------------------------------------------------------------*/
+package org.fortiss.tooling.kernel.extension.base;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.fortiss.tooling.kernel.extension.IConstraintChecker;
+import org.fortiss.tooling.kernel.extension.data.IConstraintViolation;
+
+/**
+ * Base implementation for {@link IConstraintChecker}. It checks the model
+ * element against null and returns an unmodifiable empty list.
+ * 
+ * @param <T>
+ *            the model element class for elements to be checked by this
+ *            constraint checker.
+ * @param <V>
+ *            the model element class of violating elements. Use {@link EObject}
+ *            as parameter value if you need multiple classes here.
+ * @author hoelzl
+ * @author $Author$
+ * @version $Rev$
+ * @ConQAT.Rating YELLOW Hash: 63108397E80BABBB4828D0094A82C776
+ */
+public abstract class MultiViolationConstraintCheckerBase<T extends EObject, V extends EObject>
+		extends ConstraintCheckerBase<T> {
+
+	/** {@inheritDoc} */
+	@Override
+	public final List<? extends IConstraintViolation<V>> apply(T modelElement) {
+		List<IConstraintViolation<V>> results = new ArrayList<IConstraintViolation<V>>();
+		collectViolations(modelElement, results);
+		return results;
+	}
+
+	/** Collects the violations in the given result lists. */
+	protected abstract void collectViolations(T modelElement,
+			List<IConstraintViolation<V>> results);
+}
-- 
GitLab