4
4
5
5
import com .google .common .annotations .VisibleForTesting ;
6
6
import com .google .common .collect .ImmutableList ;
7
+ import games .strategy .triplea .Constants ;
7
8
import games .strategy .triplea .Properties ;
8
9
import games .strategy .triplea .attachments .TerritoryAttachment ;
9
10
import games .strategy .triplea .attachments .UnitAttachment ;
19
20
import lombok .Getter ;
20
21
import lombok .Setter ;
21
22
import lombok .extern .slf4j .Slf4j ;
23
+ import org .jetbrains .annotations .NonNls ;
22
24
import org .triplea .java .collections .CollectionUtils ;
23
25
24
26
/**
31
33
@ Getter
32
34
@ EqualsAndHashCode (of = "id" , callSuper = false )
33
35
public class Unit extends GameDataComponent implements DynamicallyModifiable {
34
- public static final String TRANSPORTED_BY = "transportedBy" ;
35
- public static final String UNLOADED = "unloaded" ;
36
- public static final String LOADED_THIS_TURN = "wasLoadedThisTurn" ;
37
- public static final String UNLOADED_TO = "unloadedTo" ;
38
- public static final String UNLOADED_IN_COMBAT_PHASE = "wasUnloadedInCombatPhase" ;
39
- public static final String ALREADY_MOVED = "alreadyMoved" ;
40
- public static final String BONUS_MOVEMENT = "bonusMovement" ;
41
- public static final String SUBMERGED = "submerged" ;
42
- public static final String WAS_IN_COMBAT = "wasInCombat" ;
43
- public static final String LOADED_AFTER_COMBAT = "wasLoadedAfterCombat" ;
44
- public static final String UNLOADED_AMPHIBIOUS = "wasAmphibious" ;
45
- public static final String ORIGINATED_FROM = "originatedFrom" ;
46
- public static final String WAS_SCRAMBLED = "wasScrambled" ;
47
- public static final String MAX_SCRAMBLE_COUNT = "maxScrambleCount" ;
48
- public static final String WAS_IN_AIR_BATTLE = "wasInAirBattle" ;
49
- public static final String LAUNCHED = "launched" ;
50
- public static final String AIRBORNE = "airborne" ;
51
- public static final String CHARGED_FLAT_FUEL_COST = "chargedFlatFuelCost" ;
36
+ @ NonNls public static final String TRANSPORTED_BY = "transportedBy" ;
37
+ @ NonNls public static final String UNLOADED = "unloaded" ;
38
+ @ NonNls public static final String LOADED_THIS_TURN = "wasLoadedThisTurn" ;
39
+ @ NonNls public static final String UNLOADED_TO = "unloadedTo" ;
40
+ @ NonNls public static final String UNLOADED_IN_COMBAT_PHASE = "wasUnloadedInCombatPhase" ;
41
+ @ NonNls public static final String ALREADY_MOVED = "alreadyMoved" ;
42
+ @ NonNls public static final String BONUS_MOVEMENT = "bonusMovement" ;
43
+ @ NonNls public static final String SUBMERGED = "submerged" ;
44
+ @ NonNls public static final String WAS_IN_COMBAT = "wasInCombat" ;
45
+ @ NonNls public static final String LOADED_AFTER_COMBAT = "wasLoadedAfterCombat" ;
46
+ @ NonNls public static final String UNLOADED_AMPHIBIOUS = "wasAmphibious" ;
47
+ @ NonNls public static final String ORIGINATED_FROM = "originatedFrom" ;
48
+ @ NonNls public static final String WAS_SCRAMBLED = "wasScrambled" ;
49
+ @ NonNls public static final String MAX_SCRAMBLE_COUNT = "maxScrambleCount" ;
50
+ @ NonNls public static final String WAS_IN_AIR_BATTLE = "wasInAirBattle" ;
51
+ @ NonNls public static final String LAUNCHED = "launched" ;
52
+ @ NonNls public static final String AIRBORNE = "airborne" ;
53
+ @ NonNls public static final String CHARGED_FLAT_FUEL_COST = "chargedFlatFuelCost" ;
52
54
53
55
private static final long serialVersionUID = -79061939642779999L ;
54
56
@@ -222,7 +224,7 @@ private static void printError(final String errorMessage) {
222
224
}
223
225
224
226
@ Override
225
- public @ Nullable MutableProperty <?> getPropertyOrNull (String propertyName ) {
227
+ public @ Nullable MutableProperty <?> getPropertyOrNull (@ NonNls String propertyName ) {
226
228
switch (propertyName ) {
227
229
case "owner" :
228
230
return MutableProperty .ofSimple (this ::setOwner , this ::getOwner );
@@ -232,49 +234,49 @@ private static void printError(final String errorMessage) {
232
234
return MutableProperty .ofSimple (this ::setHits , this ::getHits );
233
235
case "type" :
234
236
return MutableProperty .ofReadOnlySimple (this ::getType );
235
- case "transportedBy" :
237
+ case TRANSPORTED_BY :
236
238
return MutableProperty .ofSimple (this ::setTransportedBy , this ::getTransportedBy );
237
- case "unloaded" :
239
+ case UNLOADED :
238
240
return MutableProperty .ofSimple (this ::setUnloaded , this ::getUnloaded );
239
- case "wasLoadedThisTurn" :
241
+ case LOADED_THIS_TURN :
240
242
return MutableProperty .ofSimple (this ::setWasLoadedThisTurn , this ::getWasLoadedThisTurn );
241
- case "unloadedTo" :
243
+ case UNLOADED_TO :
242
244
return MutableProperty .ofSimple (this ::setUnloadedTo , this ::getUnloadedTo );
243
- case "wasUnloadedInCombatPhase" :
245
+ case UNLOADED_IN_COMBAT_PHASE :
244
246
return MutableProperty .ofSimple (
245
247
this ::setWasUnloadedInCombatPhase , this ::getWasUnloadedInCombatPhase );
246
- case "alreadyMoved" :
248
+ case ALREADY_MOVED :
247
249
return MutableProperty .ofSimple (this ::setAlreadyMoved , this ::getAlreadyMoved );
248
- case "bonusMovement" :
250
+ case BONUS_MOVEMENT :
249
251
return MutableProperty .ofSimple (this ::setBonusMovement , this ::getBonusMovement );
250
252
case "unitDamage" :
251
253
return MutableProperty .ofSimple (this ::setUnitDamage , this ::getUnitDamage );
252
- case "submerged" :
254
+ case SUBMERGED :
253
255
return MutableProperty .ofSimple (this ::setSubmerged , this ::getSubmerged );
254
- case "originalOwner" :
256
+ case Constants . ORIGINAL_OWNER :
255
257
return MutableProperty .ofSimple (this ::setOriginalOwner , this ::getOriginalOwner );
256
- case "wasInCombat" :
258
+ case WAS_IN_COMBAT :
257
259
return MutableProperty .ofSimple (this ::setWasInCombat , this ::getWasInCombat );
258
- case "wasLoadedAfterCombat" :
260
+ case LOADED_AFTER_COMBAT :
259
261
return MutableProperty .ofSimple (
260
262
this ::setWasLoadedAfterCombat , this ::getWasLoadedAfterCombat );
261
- case "wasAmphibious" :
263
+ case UNLOADED_AMPHIBIOUS :
262
264
return MutableProperty .ofSimple (this ::setWasAmphibious , this ::getWasAmphibious );
263
- case "originatedFrom" :
265
+ case ORIGINATED_FROM :
264
266
return MutableProperty .ofSimple (this ::setOriginatedFrom , this ::getOriginatedFrom );
265
- case "wasScrambled" :
267
+ case WAS_SCRAMBLED :
266
268
return MutableProperty .ofSimple (this ::setWasScrambled , this ::getWasScrambled );
267
- case "maxScrambleCount" :
269
+ case MAX_SCRAMBLE_COUNT :
268
270
return MutableProperty .ofSimple (this ::setMaxScrambleCount , this ::getMaxScrambleCount );
269
- case "wasInAirBattle" :
271
+ case WAS_IN_AIR_BATTLE :
270
272
return MutableProperty .ofSimple (this ::setWasInAirBattle , this ::getWasInAirBattle );
271
273
case "disabled" :
272
274
return MutableProperty .ofSimple (this ::setDisabled , this ::getDisabled );
273
- case "launched" :
275
+ case LAUNCHED :
274
276
return MutableProperty .ofSimple (this ::setLaunched , this ::getLaunched );
275
- case "airborne" :
277
+ case AIRBORNE :
276
278
return MutableProperty .ofSimple (this ::setAirborne , this ::getAirborne );
277
- case "chargedFlatFuelCost" :
279
+ case CHARGED_FLAT_FUEL_COST :
278
280
return MutableProperty .ofSimple (this ::setChargedFlatFuelCost , this ::getChargedFlatFuelCost );
279
281
default :
280
282
return null ;
@@ -377,11 +379,11 @@ public void setTransportedBy(final Unit transportedBy) {
377
379
}
378
380
379
381
/**
380
- * This is a very slow method because it checks all territories on the map. Try not to use this
381
- * method if possible.
382
+ * Try not to use this method if possible.
382
383
*
383
384
* @return Unmodifiable collection of units that this unit is transporting in the same territory
384
385
* it is located in
386
+ * @deprecated This is a very slow method because it checks all territories on the map.
385
387
*/
386
388
@ Deprecated
387
389
public List <Unit > getTransporting () {
@@ -488,11 +490,11 @@ public boolean canTakeHitWithoutBeingKilled() {
488
490
}
489
491
490
492
/**
491
- * Avoid calling this method, it checks every territory on the map. To undeprecate we should
493
+ * Avoid calling this method, it checks every territory on the map. To avoid deprecation we should
492
494
* optimize this to halt on the first territory we have found with a transporting unit, or
493
495
* otherwise optimize this to not check every territory.
494
496
*
495
- * @deprecated Avoid callling this method, it calls {@link #getTransporting()} which is slow and
497
+ * @deprecated Avoid calling this method, it calls {@link #getTransporting()} which is slow and
496
498
* needs optimization.
497
499
*/
498
500
@ Deprecated
0 commit comments