Skip to content

Package: PreSetValidationService

PreSetValidationService

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2017 EclipseSource Muenchen GmbH and others.
3: *
4: * All rights reserved. This program and the accompanying materials
5: * are made available under the terms of the Eclipse Public License 2.0
6: * which accompanies this distribution, and is available at
7: * https://www.eclipse.org/legal/epl-2.0/
8: *
9: * SPDX-License-Identifier: EPL-2.0
10: *
11: * Contributors:
12: * Edgar Mueller - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emfforms.spi.common.validation;
15:
16: import org.eclipse.emf.common.util.Diagnostic;
17: import org.eclipse.emf.ecore.ENamedElement;
18: import org.eclipse.emf.ecore.EStructuralFeature;
19:
20: /**
21: * Pre-set validation service that checks whether a given value
22: * complies with constraints defined by a given feature.
23: *
24: * @since 1.13
25: */
26: public interface PreSetValidationService extends IFeatureConstraint {
27:
28:         /**
29:          * Validate a given value against constraints defined by the EDataType
30:          * of the {@link EStructuralFeature}.
31:          *
32:          * @param eStructuralFeature the feature that defines any constraints
33:          * @param value the value to be validated
34:          * @return a {@link Diagnostic} describing any potential errors
35:          */
36:         Diagnostic validate(EStructuralFeature eStructuralFeature, Object value);
37:
38:         /**
39:          * Add a custom {@link IFeatureConstraint}.
40:          *
41:          * @param element {@link ENamedElement} to add a validation constraint for
42:          * @param constraint the behavioral validation constraint
43:          */
44:         void addConstraintValidator(ENamedElement element, IFeatureConstraint constraint);
45:
46:         /**
47:          * Validate a given value against loose constraints defined by the EDataType of the
48:          * {@link EStructuralFeature}.
49:          *
50:          * @param eStructuralFeature the feature that defines any constraints
51:          * @param value the value to be validated
52:          * @return a {@link Diagnostic} describing any potential errors
53:          */
54:         Diagnostic validateLoose(EStructuralFeature eStructuralFeature, Object value);
55: }