1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
package org.kuali.student.contract.writer; |
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
@author |
21 |
|
|
|
|
| 0% |
Uncovered Elements: 42 (42) |
Complexity: 9 |
Complexity Density: 0.33 |
|
22 |
|
public class JavaEnumConstantCalculator { |
23 |
|
|
24 |
|
private String name; |
25 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
26 |
0
|
public JavaEnumConstantCalculator(String name) {... |
27 |
0
|
this.name = name; |
28 |
|
} |
29 |
|
|
|
|
| 0% |
Uncovered Elements: 19 (19) |
Complexity: 4 |
Complexity Density: 0.31 |
|
30 |
0
|
public String calc() {... |
31 |
0
|
StringBuilder buf = new StringBuilder(name.length() + 3); |
32 |
|
|
33 |
0
|
char c = Character.toUpperCase(name.charAt(0)); |
34 |
0
|
buf.append(c); |
35 |
0
|
boolean lastUpper = Character.isUpperCase(c); |
36 |
0
|
for (int i = 1; i < name.length(); i++) { |
37 |
0
|
c = name.charAt(i); |
38 |
0
|
if (Character.isUpperCase(c)) { |
39 |
0
|
if (!lastUpper) { |
40 |
0
|
buf.append('_'); |
41 |
|
} |
42 |
0
|
lastUpper = true; |
43 |
|
} else { |
44 |
0
|
lastUpper = false; |
45 |
|
} |
46 |
|
|
47 |
0
|
buf.append(Character.toUpperCase(c)); |
48 |
|
} |
49 |
|
|
50 |
0
|
return buf.toString(); |
51 |
|
} |
52 |
|
|
|
|
| 0% |
Uncovered Elements: 19 (19) |
Complexity: 4 |
Complexity Density: 0.31 |
|
53 |
0
|
public String reverse() {... |
54 |
0
|
StringBuffer buf = new StringBuffer(name.length()); |
55 |
0
|
boolean uppercase = true; |
56 |
0
|
for (int i = 0; i < name.length(); i++) { |
57 |
0
|
char c = name.charAt(i); |
58 |
0
|
if (uppercase) { |
59 |
0
|
c = Character.toUpperCase(c); |
60 |
0
|
uppercase = false; |
61 |
|
} else { |
62 |
0
|
c = Character.toLowerCase(c); |
63 |
|
} |
64 |
0
|
if (c == '_') { |
65 |
0
|
uppercase = true; |
66 |
0
|
continue; |
67 |
|
} |
68 |
0
|
buf.append(c); |
69 |
|
} |
70 |
|
|
71 |
0
|
return buf.toString(); |
72 |
|
} |
73 |
|
} |