Skip to content

Package: ReferenceServiceCustomizationVendor

ReferenceServiceCustomizationVendor

nameinstructionbranchcomplexitylinemethod
ReferenceServiceCustomizationVendor()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
bid(EObject, EReference)
M: 0 C: 11
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
handles(EObject, EReference)
M: 0 C: 2
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) 2018 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: package org.eclipse.emf.ecp.ui.view.swt.reference;
15:
16: import org.eclipse.emf.ecore.EObject;
17: import org.eclipse.emf.ecore.EReference;
18: import org.eclipse.emfforms.bazaar.Bid;
19: import org.eclipse.emfforms.bazaar.Vendor;
20:
21: /**
22: * A partial implementation of vendor services for
23: * {@link org.eclipse.emf.ecp.ui.view.swt.DefaultReferenceService DefaultReferenceService}
24: * <em>customization strategies</em> in the bazaar. Clients may subclass to suit.
25: *
26: * @param <T> the type of reference service customization that I provide
27: *
28: * @author Christian W. Damus
29: *
30: * @since 1.16
31: */
32: public class ReferenceServiceCustomizationVendor<T> implements Vendor<T> {
33:
34:         private double defaultBid;
35:
36:         /**
37:          * Initializes me .
38:          */
39:         public ReferenceServiceCustomizationVendor() {
40:                 super();
41:         }
42:
43:         /**
44:          * Bid on provision for the given {@owner} and {@code reference}. This implementation
45:          * returns the default bid, which is the OSGi configured ranking of this service,
46:          * if the {@link #handles(EObject, EReference)} method return {@code true}.
47:          *
48:          * @param owner the owner of a reference being edited by the <em>Reference Service</em>
49:          * @param reference the reference being edited
50:          *
51:          * @return the bid, or {@code null} to opt out
52:          *
53:          * @see #handles(EObject, EReference)
54:          */
55:         @Bid
56:         public Double bid(EObject owner, EReference reference) {
57:•                if (handles(owner, reference)) {
58:                         return defaultBid;
59:                 }
60:                 return null;
61:         }
62:
63:         /**
64:          * Queries whether I should bid on the given {@code owner} and {@code reference}.
65:          * The default implementation just returns {@code true}; subclasses should override.
66:          *
67:          * @param owner the owner of a reference being edited by the <em>Reference Service</em>
68:          * @param reference the reference being edited
69:          *
70:          * @return whether I should bid
71:          */
72:         protected boolean handles(EObject owner, EReference reference) {
73:                 return true;
74:         }
75: }