Make fields final if possible to ensure immutability

This commit is contained in:
thatsIch
2014-09-29 09:54:34 +02:00
parent 35f6c84d9f
commit 474596f095
261 changed files with 607 additions and 597 deletions
@@ -7,7 +7,7 @@ public class CraftBranchFailure extends Exception
private static final long serialVersionUID = 654603652836724823L;
IAEItemStack missing;
final IAEItemStack missing;
public CraftBranchFailure(IAEItemStack what, long howMany) {
super( "Failed: " + what.getItem().getUnlocalizedName() + " x " + howMany );
@@ -7,7 +7,7 @@ public class CraftingCalculationFailure extends RuntimeException
private static final long serialVersionUID = 654603652836724823L;
IAEItemStack missing;
final IAEItemStack missing;
public CraftingCalculationFailure(IAEItemStack what, long howMany) {
super( "this should have been caught!" );
+10 -10
View File
@@ -27,9 +27,9 @@ public class CraftingJob implements Runnable, ICraftingJob
IAEItemStack output;
IItemList<IAEItemStack> storage;
final IItemList<IAEItemStack> storage;
HashSet<IAEItemStack> prophecies;
final HashSet<IAEItemStack> prophecies;
boolean simulate = false;
final MECraftingInventory original;
@@ -40,7 +40,7 @@ public class CraftingJob implements Runnable, ICraftingJob
private ICraftingCallback callback;
long bytes = 0;
World world;
final World world;
@Override
public IAEItemStack getOutput()
@@ -105,8 +105,8 @@ public class CraftingJob implements Runnable, ICraftingJob
}
IItemList<IAEItemStack> crafting = AEApi.instance().storage().createItemList();
IItemList<IAEItemStack> missing = AEApi.instance().storage().createItemList();
final IItemList<IAEItemStack> crafting = AEApi.instance().storage().createItemList();
final IItemList<IAEItemStack> missing = AEApi.instance().storage().createItemList();
public void addTask(IAEItemStack what, long crafts, ICraftingPatternDetails details, int depth)
{
@@ -127,11 +127,11 @@ public class CraftingJob implements Runnable, ICraftingJob
class twoIntegers
{
public long perOp = 0;
public long times = 0;
public final long perOp = 0;
public final long times = 0;
}
HashMap<String, twoIntegers> opsAndMultiplier = new HashMap<String, twoIntegers>();
final HashMap<String, twoIntegers> opsAndMultiplier = new HashMap<String, twoIntegers>();
@Override
public void run()
@@ -257,8 +257,8 @@ public class CraftingJob implements Runnable, ICraftingJob
private boolean running = false;
private boolean done = false;
private Object monitor = new Object();
private Stopwatch watch = Stopwatch.createUnstarted();
private final Object monitor = new Object();
private final Stopwatch watch = Stopwatch.createUnstarted();
private int time = 5;
/**
@@ -19,18 +19,18 @@ public class CraftingTreeNode
{
// parent node.
private CraftingTreeProcess parent;
private World world;
private final CraftingTreeProcess parent;
private final World world;
// what slot!
int slot;
final int slot;
int bytes = 0;
// what item is this?
private IAEItemStack what;
private final IAEItemStack what;
// what are the crafting patterns for this?
private ArrayList<CraftingTreeProcess> nodes = new ArrayList<CraftingTreeProcess>();
private final ArrayList<CraftingTreeProcess> nodes = new ArrayList<CraftingTreeProcess>();
boolean canEmit = false;
boolean cannotUse = false;
@@ -38,8 +38,8 @@ public class CraftingTreeNode
long missing = 0;
long howManyEmitted = 0;
CraftingJob job;
IItemList<IAEItemStack> used = AEApi.instance().storage().createItemList();
final CraftingJob job;
final IItemList<IAEItemStack> used = AEApi.instance().storage().createItemList();
boolean exhausted = false;
boolean sim;
@@ -24,9 +24,9 @@ public class CraftingTreeProcess
{
World world;
CraftingTreeNode parent;
ICraftingPatternDetails details;
CraftingJob job;
final CraftingTreeNode parent;
final ICraftingPatternDetails details;
final CraftingJob job;
long crafts = 0;
boolean containerItems;
@@ -36,7 +36,7 @@ public class CraftingTreeProcess
private long bytes = 0;
final private int depth;
Map<CraftingTreeNode, Long> nodes = new HashMap<CraftingTreeNode, Long>();
final Map<CraftingTreeNode, Long> nodes = new HashMap<CraftingTreeNode, Long>();
public boolean possible = true;
public CraftingTreeProcess(ICraftingGrid cc, CraftingJob job, ICraftingPatternDetails details, CraftingTreeNode craftingTreeNode, int depth, World world) {
@@ -48,9 +48,9 @@ public class CraftingWatcher implements ICraftingWatcher
}
CraftingGridCache gsc;
ICraftingWatcherHost host;
HashSet<IAEStack> myInterests = new HashSet<IAEStack>();
final CraftingGridCache gsc;
final ICraftingWatcherHost host;
final HashSet<IAEStack> myInterests = new HashSet<IAEStack>();
public CraftingWatcher(CraftingGridCache cache, ICraftingWatcherHost host) {
gsc = cache;