Conditions | 4 |
Total Lines | 18 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | package es.webbeta.serializer; |
||
19 | public String format(String name) { |
||
20 | if (name.contains(" ")) |
||
21 | throw new IllegalArgumentException("A field cannot have empty spaces."); |
||
22 | |||
23 | if (formatterType == FieldFormatterType.INHERITED) |
||
24 | return name; |
||
25 | else { |
||
26 | boolean hasDashOrUnderscore = name.contains("-") || name.contains("_"); |
||
27 | |||
28 | if (hasDashOrUnderscore) { |
||
29 | name = name.replace("-", "_"); |
||
30 | name = name.toLowerCase(); |
||
31 | |||
32 | return CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.valueOf(formatterType.getStringType().toUpperCase()), name); |
||
33 | } else { |
||
34 | name = String.valueOf(Ascii.toLowerCase(name.charAt(0))) + name.substring(1); |
||
35 | |||
36 | return CaseFormat.LOWER_CAMEL.to(CaseFormat.valueOf(formatterType.getStringType().toUpperCase()), name); |
||
37 | } |
||
42 |