Skip to content

Package: EMFFormsDMRSegmentExpander

EMFFormsDMRSegmentExpander

nameinstructionbranchcomplexitylinemethod
static {...}
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2018 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: * Lucas Koehler - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emfforms.spi.core.services.domainexpander;
15:
16: import java.util.Optional;
17:
18: import org.eclipse.emf.ecore.EObject;
19: import org.eclipse.emf.ecp.view.spi.model.VDomainModelReferenceSegment;
20:
21: /**
22: * This service offers the method {@link #prepareDomainObject(VDomainModelReferenceSegment, EObject)} that allows to
23: * expand a given {@link EObject domain object} for a {@link VDomainModelReferenceSegment}. The method
24: * {@link #isApplicable(VDomainModelReferenceSegment)} is used to determine how suitable this service is for a certain
25: * {@link VDomainModelReferenceSegment}.
26: * <p>
27: * <strong>Note:</strong> This interface is not intended for public use but defines the services which are internally
28: * used in the {@link EMFFormsDomainExpander}.
29: *
30: * @author Lucas Koehler
31: * @since 1.19
32: *
33: */
34: public interface EMFFormsDMRSegmentExpander {
35:         /**
36:          * This value is returned by {@link #isApplicable(VDomainModelReferenceSegment)} if the
37:          * {@link EMFFormsDMRSegmentExpander} is not applicable for the given {@link VDomainModelReferenceSegment}.
38:          */
39:         Double NOT_APPLICABLE = Double.NEGATIVE_INFINITY;
40:
41:         /**
42:          * Prepares a {@link EObject domain object} for the given {@link VDomainModelReferenceSegment}. Thereby, the feature
43:          * defined by the segment is analyzed and if it is a reference, the missing target object will be created. Thereby,
44:          * the segment is not changed. The target of the segment's feature is returned. This is the created {@link EObject}
45:          * if it was created by this method or the already existing target of the segment's feature.
46:          * <p>
47:          * Example:<br/>
48:          * DMR: A -a-> B<br/>
49:          * The domain model is instance of A but does not reference an instance of B. The segment contains the feature 'a'.
50:          * <br/>
51:          * => An instance of B is created and referenced by the domain model. B is returned by this expander.
52:          *
53:          * @param segment The {@link VDomainModelReferenceSegment} for which the {@link EObject domain object} should be
54:          * prepared.
55:          * @param domainObject The {@link EObject domain object} to prepare.
56:          * @return The new target of the segment's feature. If an {@link EObject} was created, it is returned,
57:          * otherwise the already existing target is returned. May return nothing. If the given segment was not the
58:          * DMR's last segment, this causes the DMR expansion process to fail.
59:          * @throws EMFFormsExpandingFailedException if the domain expansion fails.
60:          */
61:         Optional<EObject> prepareDomainObject(VDomainModelReferenceSegment segment, EObject domainObject)
62:                 throws EMFFormsExpandingFailedException;
63:
64:         /**
65:          * Returns how suitable this {@link EMFFormsDMRSegmentExpander} is for the given
66:          * {@link VDomainModelReferenceSegment}.
67:          *
68:          * @param segment The {@link VDomainModelReferenceSegment} for which an {@link EObject domain object} should
69:          * be prepared.
70:          * @return a value indicating how suitable this {@link EMFFormsDMRSegmentExpander} is to expand a {@link EObject
71:          * domain object} for the given {@link VDomainModelReferenceSegment}. Returns NOT_APPLICABLE if it's not
72:          * applicable.
73:          */
74:         double isApplicable(VDomainModelReferenceSegment segment);
75:
76:         /**
77:          * Returns whether a supported {@link VDomainModelReferenceSegment segment} needs to be expanded when it is the last
78:          * segment of a {@link VDomainModelReferenceSegment}.
79:          *
80:          * @return Whether the last segment needs to be expanded
81:          */
82:         boolean needsToExpandLastSegment();
83: }