Clover Coverage Report - KS Contract Documentation Generator 0.0.1-SNAPSHOT
Coverage timestamp: Wed Dec 31 1969 19:00:00 EST
../../../../../../img/srcFileCovDistChart0.png 0% of files have more coverage
18   77   12   2.57
10   48   0.67   7
7     1.71  
1    
 
  GetterSetterNameCalculator       Line # 26 18 0% 12 35 0% 0.0
 
No Tests
 
1    /*
2    * Copyright 2010 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.osedu.org/licenses/ECL-2.0
9    *
10    * Unless required by applicable law or agreed to in writing, software
11    * distributed under the License is distributed on an "AS IS" BASIS,
12    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13    * See the License for the specific language governing permissions and
14    * limitations under the License.
15    */
16    package org.kuali.student.contract.writer.service;
17   
18    import org.kuali.student.contract.model.MessageStructure;
19    import org.kuali.student.contract.model.ServiceContractModel;
20    import org.kuali.student.contract.writer.JavaClassWriter;
21   
22    /**
23    *
24    * @author nwright
25    */
 
26    public class GetterSetterNameCalculator {
27   
28    private MessageStructure ms;
29    private JavaClassWriter writer;
30    private ServiceContractModel model;
31   
 
32  0 toggle public GetterSetterNameCalculator(MessageStructure ms,
33    JavaClassWriter writer,
34    ServiceContractModel model) {
35  0 this.ms = ms;
36  0 this.writer = writer;
37  0 this.model = model;
38    }
39   
 
40  0 toggle public String calcGetter() {
41  0 if (calcFieldTypeToUse(ms.getType()).equals("Boolean")) {
42  0 if (ms.getShortName().toLowerCase().startsWith("is")) {
43  0 return calcInitLower(ms.getShortName());
44    }
45  0 return "is" + calcInitUpper(ms.getShortName());
46    }
47  0 return "get" + calcInitUpper(ms.getShortName());
48    }
49   
 
50  0 toggle public String calcSetter() {
51  0 if (calcFieldTypeToUse(ms.getType()).equals("Boolean")) {
52  0 if (ms.getShortName().toLowerCase().startsWith("is")) {
53  0 return "set" + calcInitUpper(ms.getShortName().substring(2));
54    }
55    }
56  0 return "set" + calcInitUpper(ms.getShortName());
57    }
58   
 
59  0 toggle public static String calcInitUpper(String name) {
60  0 return name.substring(0, 1).toUpperCase() + name.substring(1);
61    }
62   
 
63  0 toggle public static String calcInitLower(String name) {
64  0 return name.substring(0, 1).toLowerCase() + name.substring(1);
65    }
66   
 
67  0 toggle public String calcFieldTypeToUse(String type) {
68  0 return MessageStructureTypeCalculator.calculate(writer, model, type, type, null);
69    }
70   
 
71  0 toggle public static String stripList(String str) {
72  0 if (str.endsWith("List")) {
73  0 return str.substring(0, str.length() - "List".length());
74    }
75  0 return str;
76    }
77    }