diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/utils/ConstraintsUtils.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/utils/ConstraintsUtils.java index 65418a11ce1eb61738229f4b525f5906b054cbd6..91c2858f0e9aae46d8f7536f43def21d3905ee6c 100644 --- a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/utils/ConstraintsUtils.java +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/utils/ConstraintsUtils.java @@ -31,7 +31,7 @@ import org.fortiss.tooling.kernel.model.constraints.SuccessVerificationStatus; * @author aravantinos * @author $Author$ * @version $Rev$ - * @ConQAT.Rating YELLOW Hash: 1EE7F9BAEAF62D5E8C843797A8177D77 + * @ConQAT.Rating YELLOW Hash: 1325BAE0A0C28B3F093D89D912BE1AFF */ public class ConstraintsUtils { /** @@ -39,8 +39,18 @@ public class ConstraintsUtils { * @param clazz * @return <code>true</code> if <code>c</code> contains a constraint of type <code>clazz</code>. */ - public static boolean containsConstraintOfType(IConstrained c, Class<?> clazz) { - return !EcoreUtils.pickInstanceOf(clazz, c.getConstraints()).isEmpty(); + public static boolean containsConstraintOfType(IConstrained c, + Class<? extends IConstraint> clazz) { + return getConstraintOfType(c, clazz) != null; + } + + /** + * @param c + * @param clazz + * @return the first constraint of <code>c</code> of type <code>clazz</code>. + */ + public static <T extends IConstraint> T getConstraintOfType(IConstrained c, Class<T> clazz) { + return EcoreUtils.pickFirstInstanceOf(clazz, c.getConstraints()); } /** Exception which embeds an error. */