| Conditions | 28 |
| Total Lines | 154 |
| Code Lines | 128 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
Complex classes like it.cnr.istc.pst.platinum.ai.lang.ddl.v3.parser.DDLTemporalRelationType.parse() often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
| 1 | package it.cnr.istc.pst.platinum.ai.lang.ddl.v3.parser; |
||
| 20 | void parse() |
||
| 21 | { |
||
| 22 | String relation_type = getText(); |
||
| 23 | if (relation_type.equals("MEETS")) { |
||
| 24 | relationType = TemporalRelationType.MEETS; |
||
| 25 | return; |
||
| 26 | } |
||
| 27 | if (relation_type.equals("MET-BY")) { |
||
| 28 | relationType = TemporalRelationType.MET_BY; |
||
| 29 | return; |
||
| 30 | } |
||
| 31 | if (relation_type.equals("BEFORE")) { |
||
| 32 | relationType = TemporalRelationType.BEFORE; |
||
| 33 | firstRange = (DDLRange) getChild(0); |
||
| 34 | firstRange.parse(); |
||
| 35 | return; |
||
| 36 | } |
||
| 37 | if (relation_type.equals("AFTER")) { |
||
| 38 | relationType = TemporalRelationType.AFTER; |
||
| 39 | firstRange = (DDLRange) getChild(0); |
||
| 40 | firstRange.parse(); |
||
| 41 | return; |
||
| 42 | } |
||
| 43 | if (relation_type.equals("EQUALS")) { |
||
| 44 | relationType = TemporalRelationType.EQUALS; |
||
| 45 | return; |
||
| 46 | } |
||
| 47 | if (relation_type.equals("STARTS")) { |
||
| 48 | relationType = TemporalRelationType.STARTS; |
||
| 49 | return; |
||
| 50 | } |
||
| 51 | if (relation_type.equals("STARTED-BY")) { |
||
| 52 | relationType = TemporalRelationType.STARTED_BY; |
||
| 53 | return; |
||
| 54 | } |
||
| 55 | if (relation_type.equals("FINISHES")) { |
||
| 56 | relationType = TemporalRelationType.FINISHES; |
||
| 57 | return; |
||
| 58 | } |
||
| 59 | if (relation_type.equals("FINISHED-BY")) { |
||
| 60 | relationType = TemporalRelationType.FINISHED_BY; |
||
| 61 | return; |
||
| 62 | } |
||
| 63 | if (relation_type.equals("DURING")) { |
||
| 64 | relationType = TemporalRelationType.DURING; |
||
| 65 | firstRange = (DDLRange) getChild(0); |
||
| 66 | firstRange.parse(); |
||
| 67 | secondRange = (DDLRange) getChild(1); |
||
| 68 | secondRange.parse(); |
||
| 69 | return; |
||
| 70 | } |
||
| 71 | if (relation_type.equals("CONTAINS")) { |
||
| 72 | relationType = TemporalRelationType.CONTAINS; |
||
| 73 | firstRange = (DDLRange) getChild(0); |
||
| 74 | firstRange.parse(); |
||
| 75 | secondRange = (DDLRange) getChild(1); |
||
| 76 | secondRange.parse(); |
||
| 77 | return; |
||
| 78 | } |
||
| 79 | if (relation_type.equals("OVERLAPS")) { |
||
| 80 | relationType = TemporalRelationType.OVERLAPS; |
||
| 81 | firstRange = (DDLRange) getChild(0); |
||
| 82 | firstRange.parse(); |
||
| 83 | return; |
||
| 84 | } |
||
| 85 | if (relation_type.equals("OVERLAPPED-BY")) { |
||
| 86 | relationType = TemporalRelationType.OVERLAPPED_BY; |
||
| 87 | firstRange = (DDLRange) getChild(0); |
||
| 88 | firstRange.parse(); |
||
| 89 | return; |
||
| 90 | } |
||
| 91 | if (relation_type.equals("STARTS-AT")) { |
||
| 92 | relationType = TemporalRelationType.STARTS_AT; |
||
| 93 | return; |
||
| 94 | } |
||
| 95 | if (relation_type.equals("ENDS-AT")) { |
||
| 96 | relationType = TemporalRelationType.ENDS_AT; |
||
| 97 | return; |
||
| 98 | } |
||
| 99 | if (relation_type.equals("AT-START")) { |
||
| 100 | relationType = TemporalRelationType.AT_START; |
||
| 101 | return; |
||
| 102 | } |
||
| 103 | if (relation_type.equals("AT_END")) { |
||
| 104 | relationType = TemporalRelationType.AT_END; |
||
| 105 | return; |
||
| 106 | } |
||
| 107 | if (relation_type.equals("BEFORE-START")) { |
||
| 108 | relationType = TemporalRelationType.BEFORE_START; |
||
| 109 | firstRange = (DDLRange) getChild(0); |
||
| 110 | firstRange.parse(); |
||
| 111 | return; |
||
| 112 | } |
||
| 113 | if (relation_type.equals("AFTER-END")) { |
||
| 114 | relationType = TemporalRelationType.AFTER_END; |
||
| 115 | firstRange = (DDLRange) getChild(0); |
||
| 116 | firstRange.parse(); |
||
| 117 | return; |
||
| 118 | } |
||
| 119 | if (relation_type.equals("START-START")) { |
||
| 120 | relationType = TemporalRelationType.START_START; |
||
| 121 | firstRange = (DDLRange) getChild(0); |
||
| 122 | firstRange.parse(); |
||
| 123 | return; |
||
| 124 | } |
||
| 125 | if (relation_type.equals("START-END")) { |
||
| 126 | relationType = TemporalRelationType.START_END; |
||
| 127 | firstRange = (DDLRange) getChild(0); |
||
| 128 | firstRange.parse(); |
||
| 129 | return; |
||
| 130 | } |
||
| 131 | if (relation_type.equals("END-START")) { |
||
| 132 | relationType = TemporalRelationType.END_START; |
||
| 133 | firstRange = (DDLRange) getChild(0); |
||
| 134 | firstRange.parse(); |
||
| 135 | return; |
||
| 136 | } |
||
| 137 | if (relation_type.equals("END-END")) { |
||
| 138 | relationType = TemporalRelationType.END_END; |
||
| 139 | firstRange = (DDLRange) getChild(0); |
||
| 140 | firstRange.parse(); |
||
| 141 | return; |
||
| 142 | } |
||
| 143 | if (relation_type.equals("CONTAINS-START")) { |
||
| 144 | relationType = TemporalRelationType.CONTAINS_START; |
||
| 145 | firstRange = (DDLRange) getChild(0); |
||
| 146 | firstRange.parse(); |
||
| 147 | secondRange = (DDLRange) getChild(1); |
||
| 148 | secondRange.parse(); |
||
| 149 | return; |
||
| 150 | } |
||
| 151 | if (relation_type.equals("CONTAINS-END")) { |
||
| 152 | relationType = TemporalRelationType.CONTAINS_END; |
||
| 153 | firstRange = (DDLRange) getChild(0); |
||
| 154 | firstRange.parse(); |
||
| 155 | secondRange = (DDLRange) getChild(1); |
||
| 156 | secondRange.parse(); |
||
| 157 | return; |
||
| 158 | } |
||
| 159 | if (relation_type.equals("STARTS-DURING")) { |
||
| 160 | relationType = TemporalRelationType.STARTS_DURING; |
||
| 161 | firstRange = (DDLRange) getChild(0); |
||
| 162 | firstRange.parse(); |
||
| 163 | secondRange = (DDLRange) getChild(1); |
||
| 164 | secondRange.parse(); |
||
| 165 | return; |
||
| 166 | } |
||
| 167 | if (relation_type.equals("ENDS-DURING")) { |
||
| 168 | relationType = TemporalRelationType.ENDS_DURING; |
||
| 169 | firstRange = (DDLRange) getChild(0); |
||
| 170 | firstRange.parse(); |
||
| 171 | secondRange = (DDLRange) getChild(1); |
||
| 172 | secondRange.parse(); |
||
| 173 | return; |
||
| 174 | } |
||
| 229 |