Skip to content

Package: IFilteredViewProvider

IFilteredViewProvider

nameinstructionbranchcomplexitylinemethod
canProvideViewModel(EObject, VViewModelProperties)
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
provideViewModel(EObject, VViewModelProperties)
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2019 Christian W. Damus 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: * Christian W. Damus - initial API and implementation
13: *
14: *******************************************************************************/
15: package org.eclipse.emf.ecp.view.spi.provider;
16:
17: import static java.util.Collections.emptySet;
18:
19: import java.util.Collection;
20:
21: import org.eclipse.emf.ecore.EObject;
22: import org.eclipse.emf.ecp.view.spi.model.VView;
23: import org.eclipse.emf.ecp.view.spi.model.VViewModelProperties;
24:
25: /**
26: * A specialized <em>{@linkplain IViewProvider view provider}</em> that filters views
27: * by properties in the <em>{@linkplain VViewModelProperties loading properties}</em>.
28: * The mechanism by which matching of filters is performed is unspecified, but filters are
29: * specified as key-value pairs in the {@code properties} parameter of each API method.
30: *
31: * @since 1.22
32: */
33: public interface IFilteredViewProvider extends IViewProvider {
34:
35:         /**
36:          * Queries whether I {@linkplain #canProvideViewModel(EObject, VViewModelProperties, Collection) can provide}
37:          * without any filter properties being required.
38:          */
39:         @Override
40:         default double canProvideViewModel(EObject eObject, VViewModelProperties properties) {
41:                 return canProvideViewModel(eObject, properties, emptySet());
42:         }
43:
44:         /**
45:          * Queries the confidence with which I can provide a view model for the given domain model
46:          * {@code object} where some keys in the {@code properties} are required to be matched in
47:          * an implementation-specific way by the view models the I have access to.
48:          *
49:          * @param object the domain model object for which a view is to be requested
50:          * @param properties the {@link VViewModelProperties properties} for providing the view, that
51:          * may or may not include matching filters
52:          * @param requiredKeys a subset (possibly empty) of the keys in the {@code properties} that
53:          * must be matched by any view model that I would provide. If any of these keys does not match
54:          * a view model, then that view model must not be provided. Otherwise, it may just be less
55:          * preferred than some other view model that does match
56:          *
57:          * @return a <strong>positive</strong> double indicating how well I am suited to
58:          * provide a {@link VView} for the given {@code object}, or
59:          * {@link IViewProvider#NOT_APPLICABLE} if I cannot provide a view model
60:          */
61:         double canProvideViewModel(EObject object, VViewModelProperties properties,
62:                 Collection<String> requiredKeys);
63:
64:         /**
65:          * Obtains a {@linkplain #provideViewModel(EObject, VViewModelProperties, Collection) view model}
66:          * without any filter properties being required.
67:          */
68:         @Override
69:         default VView provideViewModel(EObject object, VViewModelProperties properties) {
70:                 return provideViewModel(object, properties, emptySet());
71:         }
72:
73:         /**
74:          * Obtains the view model that I {@linkplain #canProvideViewModel(EObject, VViewModelProperties, Collection) can
75:          * provide}
76:          * for the given domain model {@code object}. This method is only called if a previous invocation of
77:          * {@link #canProvideViewModel(EObject, VViewModelProperties, Collection)} with the same arguments
78:          * returned the highest positive result amongst all available providers.
79:          *
80:          * @param object the domain model object for which a view is to be requested
81:          * @param properties the {@link VViewModelProperties properties} for providing the view, that
82:          * may or may not include matching filters
83:          * @param requiredKeys a subset (possibly empty) of the keys in the {@code properties} that
84:          * must be matched by any view model that I would provide. If any of these keys does not match
85:          * a view model, then that view model must not be provided. Otherwise, it may just be less
86:          * preferred than some other view model that does match
87:          *
88:          * @return the view model
89:          */
90:         VView provideViewModel(EObject object, VViewModelProperties properties,
91:                 Collection<String> requiredKeys);
92:
93: }