Skip to content

Package: ChildrenListImpl

ChildrenListImpl

nameinstructionbranchcomplexitylinemethod
ChildrenListImpl(Object)
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%
addChild(Object)
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%
addChildWithoutRefresh(Object)
M: 12 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
addChildren(Collection)
M: 14 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
addChildren(Object[])
M: 26 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 6 C: 0
0%
M: 1 C: 0
0%
childrenAdded()
M: 1 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getChild(int)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getChildren()
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%
getParent()
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%
hasChildren()
M: 7 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
isComplete()
M: 2 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
isSlow()
M: 2 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
setComplete()
M: 1 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

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 java.util.Collection;
17:
18: import org.eclipse.emf.common.util.BasicEList;
19: import org.eclipse.emf.ecp.spi.core.util.InternalChildrenList;
20:
21: /**
22: * @author Eike Stepper
23: */
24: public class ChildrenListImpl extends BasicEList<Object> implements InternalChildrenList {
25:         private static final long serialVersionUID = 1L;
26:
27:         private final Object parent;
28:
29:         /**
30:          * The ChildrenListImpl constructor.
31:          *
32:          * @param parent the parent object of this {@link ChildrenListImpl}
33:          */
34:         public ChildrenListImpl(Object parent) {
35:                 this.parent = parent;
36:         }
37:
38:         /** {@inheritDoc} */
39:         @Override
40:         public final Object getParent() {
41:                 return parent;
42:         }
43:
44:         /** {@inheritDoc} */
45:         @Override
46:         public synchronized boolean hasChildren() {
47:•                return !isEmpty();
48:         }
49:
50:         /** {@inheritDoc} */
51:         @Override
52:         public synchronized Object[] getChildren() {
53:                 return toArray(new Object[size()]);
54:         }
55:
56:         /** {@inheritDoc} */
57:         @Override
58:         public synchronized Object getChild(int index) {
59:                 return get(index);
60:         }
61:
62:         /** {@inheritDoc} */
63:         @Override
64:         public void addChildWithoutRefresh(Object child) {
65:                 synchronized (this) {
66:                         add(child);
67:                 }
68:         }
69:
70:         /** {@inheritDoc} */
71:         @Override
72:         public final void addChild(Object child) {
73:                 addChildWithoutRefresh(child);
74:                 childrenAdded();
75:         }
76:
77:         /** {@inheritDoc} */
78:         @Override
79:         public final <T> void addChildren(T... children) {
80:                 synchronized (this) {
81:•                        for (int i = 0; i < children.length; i++) {
82:                                 final Object child = children[i];
83:                                 add(child);
84:                         }
85:                 }
86:
87:                 childrenAdded();
88:         }
89:
90:         /** {@inheritDoc} */
91:         @Override
92:         public final <T> void addChildren(Collection<T> children) {
93:                 synchronized (this) {
94:                         addAll(children);
95:                 }
96:
97:                 childrenAdded();
98:         }
99:
100:         /** {@inheritDoc} */
101:         @Override
102:         public boolean isSlow() {
103:                 return false;
104:         }
105:
106:         /** {@inheritDoc} */
107:         @Override
108:         public boolean isComplete() {
109:                 return true;
110:         }
111:
112:         /** {@inheritDoc} */
113:         @Override
114:         public void setComplete() {
115:                 // Do nothing
116:         }
117:
118:         /**
119:          * This method is called whenever a child is added. Subclasses interested in this information should overwrite this
120:          * method.
121:          */
122:         protected void childrenAdded() {
123:                 // Can be overridden in subclasses
124:         }
125: }