Skip to content

Package: Element

Element

nameinstructionbranchcomplexitylinemethod
Element(String)
M: 5 C: 8
62%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 1 C: 4
80%
M: 0 C: 1
100%
compareTo(ECPElement)
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%
equals(Object)
M: 4 C: 29
88%
M: 3 C: 7
70%
M: 3 C: 3
50%
M: 2 C: 6
75%
M: 0 C: 1
100%
getName()
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%
hashCode()
M: 0 C: 22
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
toString()
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%

Coverage

1: /********************************************************************************
2: * Copyright (c) 2011 Eike Stepper (Berlin, Germany) 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: package org.eclipse.emf.ecp.internal.core.util;
15:
16: import org.eclipse.emf.ecp.core.util.ECPElement;
17:
18: /**
19: * @author Eike Stepper
20: */
21: public abstract class Element implements ECPElement {
22:         private final String name;
23:
24:         /**
25:          * The constructor of an {@link Element}.
26:          *
27:          * @param name the name of the created element
28:          */
29:         public Element(String name) {
30:•                if (name == null) {
31:                         throw new IllegalArgumentException("name is null"); //$NON-NLS-1$
32:                 }
33:
34:                 this.name = name;
35:         }
36:
37:         /** {@inheritDoc} */
38:         @Override
39:         public final String getName() {
40:                 return name;
41:         }
42:
43:         /** {@inheritDoc} */
44:         @Override
45:         public int compareTo(ECPElement o) {
46:                 return name.compareTo(o.getName());
47:         }
48:
49:         @Override
50:         public int hashCode() {
51:                 final int prime = 31;
52:                 int result = 1;
53:                 result = prime * result + name.hashCode();
54:                 result = prime * result + getType().hashCode();
55:                 return result;
56:         }
57:
58:         @Override
59:         public boolean equals(Object obj) {
60:•                if (this == obj) {
61:                         return true;
62:                 }
63:
64:•                if (obj == null) {
65:                         return false;
66:                 }
67:
68:•                if (obj instanceof Element) {
69:                         final Element that = (Element) obj;
70:•                        return getType().equals(that.getType()) && name.equals(that.getName());
71:                 }
72:
73:                 return false;
74:         }
75:
76:         @Override
77:         public String toString() {
78:                 return name;
79:         }
80:
81:         /**
82:          * This return the type of the object.
83:          *
84:          * @return the type
85:          */
86:         public abstract String getType();
87: }