Skip to content

Package: ConditionService

ConditionService

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2016 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: * Eugen - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emf.ecp.view.spi.rule;
15:
16: import java.util.Map;
17: import java.util.Set;
18:
19: import org.eclipse.emf.ecore.EClass;
20: import org.eclipse.emf.ecore.EObject;
21: import org.eclipse.emf.ecore.EStructuralFeature.Setting;
22: import org.eclipse.emf.ecp.common.spi.UniqueSetting;
23: import org.eclipse.emf.ecp.view.spi.model.VDomainModelReference;
24: import org.eclipse.emf.ecp.view.spi.rule.model.Condition;
25:
26: /**
27: * The {@link ConditionService} is used to retrieve the relevant information for conditions.
28: *
29: * @param <T> The type of the Condition this service applies to
30: * @author Eugen Neufeld
31: * @since 1.10
32: */
33: public interface ConditionService<T extends Condition> {
34:
35:         /**
36:          * The EClass this ConditionService is implemented for.
37:          *
38:          * @return The EClass of the {@link Condition}
39:          */
40:         EClass getConditionType();
41:
42:         /**
43:          * The set of {@link UniqueSetting} that are relevant for the provided condition and domain model.
44:          *
45:          * @param condition The {@link Condition} to get the UniqueSettings for
46:          * @param domainModel The {@link EObject} to use for retrieving
47:          * @return The Set of UniqueSettings. This Set must not be null.
48:          */
49:         Set<UniqueSetting> getConditionSettings(T condition, EObject domainModel);
50:
51:         /**
52:          * Evaluates the given condition.
53:          *
54:          * @param condition The Condition to evaluate
55:          * @param domainModel The root domain object of this condition.
56:          * @return {@code true}, if the condition matches, {@code false} otherwise
57:          */
58:         boolean evaluate(T condition, EObject domainModel);
59:
60:         /**
61:          * Evaluates the given condition.
62:          *
63:          * @param condition The Condition to evaluate
64:          * @param domainModel The root domain object of this condition.
65:          * @param possibleNewValues
66:          * the new value that should be compared against the expected value of the condition
67:          * @return {@code true}, if the condition matches, {@code false} otherwise
68:          */
69:         boolean evaluateChangedValues(T condition, EObject domainModel, Map<Setting, Object> possibleNewValues);
70:
71:         /**
72:          * The Set of {@link VDomainModelReference} that are relevant for the condition.
73:          *
74:          * @param condition The {@link Condition} to retrieve the VDMRs for
75:          * @return The Set of VDomainModelReferences. This Set must not be null.
76:          */
77:         Set<VDomainModelReference> getDomainModelReferences(T condition);
78: }