1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.structure; |
22 |
|
|
23 |
|
import java.util.ArrayList; |
24 |
|
import java.util.List; |
25 |
|
|
|
|
| 0% |
Uncovered Elements: 75 (75) |
Complexity: 23 |
Complexity Density: 0.53 |
|
26 |
|
public class StructureCommand implements StructureCommandI |
27 |
|
{ |
28 |
|
private String command; |
29 |
|
|
30 |
|
private List<String> parameters; |
31 |
|
|
32 |
|
private boolean waitNeeded = false; |
33 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
34 |
0 |
public StructureCommand(String cmd, String... params)... |
35 |
|
{ |
36 |
0 |
command = cmd; |
37 |
0 |
if (params != null) |
38 |
|
{ |
39 |
0 |
for (String p : params) |
40 |
|
{ |
41 |
0 |
addParameter(p); |
42 |
|
} |
43 |
|
} |
44 |
|
} |
45 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
46 |
0 |
public void setWaitNeeded(boolean wait)... |
47 |
|
{ |
48 |
0 |
waitNeeded = wait; |
49 |
|
} |
50 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
51 |
0 |
@Override... |
52 |
|
public boolean isWaitNeeded() |
53 |
|
{ |
54 |
0 |
return waitNeeded; |
55 |
|
} |
56 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
57 |
0 |
@Override... |
58 |
|
public void addParameter(String param) |
59 |
|
{ |
60 |
0 |
if (parameters == null) |
61 |
|
{ |
62 |
0 |
parameters = new ArrayList<>(); |
63 |
|
} |
64 |
0 |
parameters.add(param); |
65 |
|
} |
66 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
67 |
0 |
@Override... |
68 |
|
public String getCommand() |
69 |
|
{ |
70 |
0 |
return command; |
71 |
|
} |
72 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
73 |
0 |
@Override... |
74 |
|
public List<String> getParameters() |
75 |
|
{ |
76 |
0 |
return parameters; |
77 |
|
} |
78 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
79 |
0 |
@Override... |
80 |
|
public boolean hasParameters() |
81 |
|
{ |
82 |
0 |
return parameters != null && !parameters.isEmpty(); |
83 |
|
} |
84 |
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 3 |
Complexity Density: 0.25 |
|
85 |
0 |
@Override... |
86 |
|
public String toString() |
87 |
|
{ |
88 |
0 |
if (!hasParameters()) |
89 |
|
{ |
90 |
0 |
return command; |
91 |
|
} |
92 |
0 |
StringBuilder sb = new StringBuilder(32); |
93 |
0 |
sb.append(command).append("("); |
94 |
0 |
boolean first = true; |
95 |
0 |
for (String p : parameters) |
96 |
|
{ |
97 |
0 |
if (!first) |
98 |
|
{ |
99 |
0 |
sb.append(","); |
100 |
|
} |
101 |
0 |
first = false; |
102 |
0 |
sb.append(p); |
103 |
|
} |
104 |
0 |
sb.append(")"); |
105 |
0 |
return sb.toString(); |
106 |
|
} |
107 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
108 |
0 |
@Override... |
109 |
|
public int hashCode() |
110 |
|
{ |
111 |
0 |
int h = command.hashCode(); |
112 |
0 |
if (parameters != null) |
113 |
|
{ |
114 |
0 |
for (String p : parameters) |
115 |
|
{ |
116 |
0 |
h = h * 37 + p.hashCode(); |
117 |
|
} |
118 |
|
} |
119 |
0 |
return h; |
120 |
|
} |
121 |
|
|
122 |
|
|
123 |
|
|
124 |
|
|
125 |
|
|
|
|
| 0% |
Uncovered Elements: 26 (26) |
Complexity: 9 |
Complexity Density: 0.64 |
|
126 |
0 |
@Override... |
127 |
|
public boolean equals(Object obj) |
128 |
|
{ |
129 |
0 |
if (obj == null || !(obj instanceof StructureCommand)) |
130 |
|
{ |
131 |
0 |
return false; |
132 |
|
} |
133 |
0 |
StructureCommand sc = (StructureCommand) obj; |
134 |
|
|
135 |
0 |
if (!command.equals(sc.command)) |
136 |
|
{ |
137 |
0 |
return false; |
138 |
|
} |
139 |
0 |
if (parameters == null || sc.parameters == null) |
140 |
|
{ |
141 |
0 |
return (parameters == null) && (sc.parameters == null); |
142 |
|
} |
143 |
|
|
144 |
0 |
int j = parameters.size(); |
145 |
0 |
if (j != sc.parameters.size()) |
146 |
|
{ |
147 |
0 |
return false; |
148 |
|
} |
149 |
0 |
for (int i = 0; i < j; i++) |
150 |
|
{ |
151 |
0 |
if (!parameters.get(i).equals(sc.parameters.get(i))) |
152 |
|
{ |
153 |
0 |
return false; |
154 |
|
} |
155 |
|
} |
156 |
0 |
return true; |
157 |
|
} |
158 |
|
|
159 |
|
} |