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 bda4feb1fff896deea035bdd1995a8489e9787b7..575991fbccff985f14c917fd31c8dd2576e2885f 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 25b87cba14012d849288ada316ee2d2b748bf708..ff024fbdbe1de51ad3fed6e917168b478ec92004 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 0000000000000000000000000000000000000000..2b12c06e8b6063bad50cc5269a81f6bee8f506ce --- /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); +}