Package: ClassType

ClassType

nameinstructionbranchcomplexitylinemethod
ClassType(IReadOnlyQueryEnvironment, Class)
M: 7 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
equals(Object)
M: 35 C: 0
0%
M: 10 C: 0
0%
M: 6 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%
getType()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
hashCode()
M: 12 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%
toString()
M: 12 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 5 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: * {@link Class} validation type.
17: *
18: * @author <a href="mailto:yvan.lussaud@obeo.fr">Yvan Lussaud</a>
19: */
20: public final class ClassType extends AbstractJavaType implements IJavaType {
21:
22:         /**
23:          * The {@link Class}.
24:          */
25:         private final Class<?> type;
26:
27:         /**
28:          * Constructor.
29:          *
30:          * @param queryEnvironment
31:          * the {@link IReadOnlyQueryEnvironment}
32:          * @param type
33:          * the {@link Class}
34:          */
35:         public ClassType(IReadOnlyQueryEnvironment queryEnvironment, Class<?> type) {
36:                 super(queryEnvironment);
37:                 this.type = type;
38:         }
39:
40:         /**
41:          * Gets the {@link Class}.
42:          *
43:          * @return the {@link Class}
44:          */
45:         public Class<?> getType() {
46:                 return type;
47:         }
48:
49:         /**
50:          * {@inheritDoc}
51:          *
52:          * @see java.lang.Object#toString()
53:          */
54:         @Override
55:         public String toString() {
56:                 final String result;
57:•                if (type != null) {
58:                         result = type.getCanonicalName();
59:                 } else {
60:                         result = "null";
61:                 }
62:                 return result;
63:         }
64:
65:         /**
66:          * {@inheritDoc}
67:          *
68:          * @see org.eclipse.acceleo.query.validation.type.AbstractType#hashCode()
69:          */
70:         @Override
71:         public int hashCode() {
72:                 final int result;
73:
74:•                if (type != null) {
75:                         result = type.hashCode();
76:                 } else {
77:                         result = 0;
78:                 }
79:
80:                 return result;
81:         }
82:
83:         /**
84:          * {@inheritDoc}
85:          *
86:          * @see org.eclipse.acceleo.query.validation.type.AbstractType#equals(java.lang.Object)
87:          */
88:         @Override
89:         public boolean equals(Object obj) {
90:                 final boolean result;
91:
92:•                if (type != null) {
93:•                        result = obj.getClass() == getClass() && type.equals(((ClassType)obj).getType());
94:                 } else {
95:•                        result = obj.getClass() == getClass() && ((ClassType)obj).getType() == null;
96:                 }
97:
98:                 return result;
99:         }
100:
101: }