Package: VDMSet

VDMSet

nameinstructionbranchcomplexitylinemethod
VDMSet()
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%
copy()
M: 27 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 7 C: 0
0%
M: 1 C: 0
0%
toString()
M: 44 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: * #%~
3: * VDM Code Generator Runtime
4: * %%
5: * Copyright (C) 2008 - 2014 Overture
6: * %%
7: * This program is free software: you can redistribute it and/or modify
8: * it under the terms of the GNU General Public License as
9: * published by the Free Software Foundation, either version 3 of the
10: * License, or (at your option) any later version.
11: *
12: * This program is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: * GNU General Public License for more details.
16: *
17: * You should have received a copy of the GNU General Public
18: * License along with this program. If not, see
19: * <http://www.gnu.org/licenses/gpl-3.0.html>.
20: * #~%
21: */
22: package org.overture.codegen.runtime;
23:
24: import java.util.Iterator;
25: import java.util.LinkedHashSet;
26:
27: @SuppressWarnings("rawtypes")
28: public class VDMSet extends LinkedHashSet implements ValueType
29: {
30:         private static final long serialVersionUID = 2984495719595419443L;
31:
32:         @SuppressWarnings("unchecked")
33:         public VDMSet copy()
34:         {
35:                 VDMSet setClone = new VDMSet();
36:
37:•                for (Object element : this)
38:                 {
39:•                        if (element instanceof ValueType)
40:                         {
41:                                 element = ((ValueType) element).copy();
42:                         }
43:
44:                         setClone.add(element);
45:                 }
46:
47:                 return setClone;
48:         }
49:
50:         @Override
51:         public String toString()
52:         {
53:                 Iterator iterator = this.iterator();
54:
55:•                if (!iterator.hasNext())
56:                 {
57:                         return "{}";
58:                 }
59:
60:                 StringBuilder sb = new StringBuilder();
61:
62:                 sb.append('{');
63:
64:                 for (;;)
65:                 {
66:                         Object element = iterator.next();
67:
68:•                        sb.append(element == this ? "(this Collection)"
69:                                         : Utils.toString(element));
70:
71:•                        if (!iterator.hasNext())
72:                         {
73:                                 return sb.append('}').toString();
74:                         }
75:
76:                         sb.append(',').append(' ');
77:                 }
78:         }
79: }