Package: AbstractJavaType

AbstractJavaType

nameinstructionbranchcomplexitylinemethod
AbstractJavaType(IReadOnlyQueryEnvironment)
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
isAssignableFrom(IType)
M: 39 C: 0
0%
M: 6 C: 0
0%
M: 4 C: 0
0%
M: 12 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2015 Obeo.
3: * All rights reserved. This program and the accompanying materials
4: * are made available under the terms of the Eclipse Public License v1.0
5: * which accompanies this distribution, and is available at
6: * http://www.eclipse.org/legal/epl-v10.html
7: *
8: * Contributors:
9: * Obeo - initial API and implementation
10: *******************************************************************************/
11: package org.eclipse.acceleo.query.validation.type;
12:
13: import org.eclipse.acceleo.query.runtime.IReadOnlyQueryEnvironment;
14:
15: /**
16: * Abstract implementation of {@link IJavaType}.
17: *
18: * @author <a href="mailto:yvan.lussaud@obeo.fr">Yvan Lussaud</a>
19: */
20: public abstract class AbstractJavaType extends AbstractType implements IJavaType {
21:
22:         /**
23:          * The {@link IReadOnlyQueryEnvironment}.
24:          */
25:         private IReadOnlyQueryEnvironment queryEnvironment;
26:
27:         /**
28:          * Constructor.
29:          *
30:          * @param queryEnvironment
31:          * the {@link IReadOnlyQueryEnvironment}
32:          */
33:         public AbstractJavaType(IReadOnlyQueryEnvironment queryEnvironment) {
34:                 this.queryEnvironment = queryEnvironment;
35:         }
36:
37:         /**
38:          * {@inheritDoc}
39:          *
40:          * @see org.eclipse.acceleo.query.validation.type.IType#isAssignableFrom(org.eclipse.acceleo.query.validation.type.IType)
41:          */
42:         @Override
43:         public boolean isAssignableFrom(IType otherType) {
44:                 final boolean result;
45:
46:•                if (otherType instanceof IJavaType) {
47:                         result = isAssignableFrom(getType(), ((IJavaType)otherType).getType());
48:•                } else if (otherType instanceof EClassifierType) {
49:                         final Class<?> otherClass = queryEnvironment.getEPackageProvider().getClass(
50:                                         ((EClassifierType)otherType).getType());
51:•                        if (otherClass != null) {
52:                                 result = isAssignableFrom(getType(), otherClass);
53:                         } else {
54:                                 result = false;
55:                         }
56:                 } else {
57:                         result = false;
58:                 }
59:
60:                 return result;
61:         }
62:
63: }