Skip to content

Package: ECPModelContextAdapter

ECPModelContextAdapter

nameinstructionbranchcomplexitylinemethod
ECPModelContextAdapter(ECPContainer)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
getContext()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
isAdapterForType(Object)
M: 5 C: 8
62%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 1 C: 2
67%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2013 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: * Eike Stepper - initial API and implementation
13: *
14: *******************************************************************************/
15:
16: package org.eclipse.emf.ecp.core.util;
17:
18: import org.eclipse.emf.common.notify.impl.AdapterImpl;
19:
20: /**
21: * The {@link ECPModelContextAdapter} can be used to be able to get the {@link ECPContainer} from a Notifier.
22: *
23: * @author Eike Stepper
24: * @author Eugen Neufeld
25: * @noextend This class is not intended to be subclassed by clients.
26: */
27: public class ECPModelContextAdapter extends AdapterImpl {
28:         private final ECPContainer context;
29:
30:         /**
31:          * Constructor of this Adapter which expects an {@link ECPContainer}.
32:          *
33:          * @param context the {@link ECPContainer} of this adapter
34:          */
35:         public ECPModelContextAdapter(ECPContainer context) {
36:                 this.context = context;
37:         }
38:
39:         /**
40:          * The {@link ECPContainer} of this Adapter.
41:          *
42:          * @return the {@link ECPContainer}
43:          */
44:         public final ECPContainer getContext() {
45:                 return context;
46:         }
47:
48:         @Override
49:         public boolean isAdapterForType(Object type) {
50:•                if (type instanceof Class<?>) {
51:                         return ((Class<?>) type).isInstance(this);
52:                 }
53:                 return context.equals(type);
54:         }
55:
56: }