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
+3 -3
View File
@@ -23,9 +23,9 @@ public class Grid implements IGrid
GridStorage myStorage;
NetworkEventBus bus = new NetworkEventBus();
HashMap<Class<? extends IGridHost>, Set> Machines = new HashMap<Class<? extends IGridHost>, Set>();
HashMap<Class<? extends IGridCache>, GridCacheWrapper> caches = new HashMap<Class<? extends IGridCache>, GridCacheWrapper>();
final NetworkEventBus bus = new NetworkEventBus();
final HashMap<Class<? extends IGridHost>, Set> Machines = new HashMap<Class<? extends IGridHost>, Set>();
final HashMap<Class<? extends IGridCache>, GridCacheWrapper> caches = new HashMap<Class<? extends IGridCache>, GridCacheWrapper>();
GridNode pivot;
int isImportant; // how import is this network?
+1 -1
View File
@@ -42,7 +42,7 @@ public class GridNode implements IGridNode, IPathItem
final List<IGridConnection> Connections = new LinkedList<IGridConnection>();
GridStorage myStorage = null;
IGridBlock gridProxy;
final IGridBlock gridProxy;
Grid myGrid;
Object visitorIterationNumber = null;
+1 -1
View File
@@ -22,7 +22,7 @@ public class GridStorage implements IGridStorage
final NBTTagCompound data;
public boolean isDirty = false;
private WeakHashMap<GridStorage,Boolean> divided = new WeakHashMap<GridStorage,Boolean>();
private final WeakHashMap<GridStorage,Boolean> divided = new WeakHashMap<GridStorage,Boolean>();
final GridStorageSearch mySearchEntry; // keep myself in the list until I'm
// lost...
+3 -3
View File
@@ -57,7 +57,7 @@ public class NetworkEventBus
class MENetworkEventInfo
{
private ArrayList<EventMethod> methods = new ArrayList<EventMethod>();
private final ArrayList<EventMethod> methods = new ArrayList<EventMethod>();
public void Add(Class Event, Class ObjClass, Method ObjMethod)
{
@@ -71,8 +71,8 @@ public class NetworkEventBus
}
}
private static Set<Class> readClasses = new HashSet<Class>();
private static Hashtable<Class<? extends MENetworkEvent>, Hashtable<Class, MENetworkEventInfo>> events = new Hashtable<Class<? extends MENetworkEvent>, Hashtable<Class, MENetworkEventInfo>>();
private static final Set<Class> readClasses = new HashSet<Class>();
private static final Hashtable<Class<? extends MENetworkEvent>, Hashtable<Class, MENetworkEventInfo>> events = new Hashtable<Class<? extends MENetworkEvent>, Hashtable<Class, MENetworkEventInfo>>();
public void readClass(Class listAs, Class c)
{
+1 -1
View File
@@ -9,7 +9,7 @@ public class NodeIterator<IGridNode> implements Iterator<IGridNode>
{
boolean hasMore;
Iterator lvl1;
final Iterator lvl1;
Iterator lvl2;
boolean pull()
+8 -8
View File
@@ -68,19 +68,19 @@ import com.google.common.collect.SetMultimap;
public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper, ICellProvider, IMEInventoryHandler
{
HashSet<CraftingCPUCluster> cpuClusters = new HashSet<CraftingCPUCluster>();
HashSet<ICraftingProvider> providers = new HashSet<ICraftingProvider>();
final HashSet<CraftingCPUCluster> cpuClusters = new HashSet<CraftingCPUCluster>();
final HashSet<ICraftingProvider> providers = new HashSet<ICraftingProvider>();
private HashMap<IGridNode, ICraftingWatcher> watchers = new HashMap<IGridNode, ICraftingWatcher>();
private final HashMap<IGridNode, ICraftingWatcher> watchers = new HashMap<IGridNode, ICraftingWatcher>();
IGrid grid;
final IGrid grid;
IStorageGrid sg;
IEnergyGrid eg;
HashMap<ICraftingPatternDetails, List<ICraftingMedium>> craftingMethods = new HashMap<ICraftingPatternDetails, List<ICraftingMedium>>();
final HashMap<ICraftingPatternDetails, List<ICraftingMedium>> craftingMethods = new HashMap<ICraftingPatternDetails, List<ICraftingMedium>>();
HashMap<IAEItemStack, ImmutableList<ICraftingPatternDetails>> craftableItems = new HashMap<IAEItemStack, ImmutableList<ICraftingPatternDetails>>();
HashSet<IAEItemStack> emitableItems = new HashSet<IAEItemStack>();
HashMap<String, CraftingLinkNexus> links = new HashMap<String, CraftingLinkNexus>();
final HashSet<IAEItemStack> emitableItems = new HashSet<IAEItemStack>();
final HashMap<String, CraftingLinkNexus> links = new HashMap<String, CraftingLinkNexus>();
boolean updateList = false;
final private SetMultimap<IAEStack, CraftingWatcher> interests = HashMultimap.create();
@@ -287,7 +287,7 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
details.add( medium );
}
static Comparator<ICraftingPatternDetails> comp = new Comparator<ICraftingPatternDetails>(){
static final Comparator<ICraftingPatternDetails> comp = new Comparator<ICraftingPatternDetails>(){
@Override
public int compare(ICraftingPatternDetails o1,
ICraftingPatternDetails o2) {
+4 -4
View File
@@ -46,12 +46,12 @@ public class GridStorageCache implements IStorageGrid
final public IGrid myGrid;
private NetworkInventoryHandler<IAEItemStack> myItemNetwork;
private NetworkMonitor<IAEItemStack> itemMonitor = new NetworkMonitor<IAEItemStack>( this, StorageChannel.ITEMS );
private final NetworkMonitor<IAEItemStack> itemMonitor = new NetworkMonitor<IAEItemStack>( this, StorageChannel.ITEMS );
private NetworkInventoryHandler<IAEFluidStack> myFluidNetwork;
private NetworkMonitor<IAEFluidStack> fluidMonitor = new NetworkMonitor<IAEFluidStack>( this, StorageChannel.FLUIDS );
private final NetworkMonitor<IAEFluidStack> fluidMonitor = new NetworkMonitor<IAEFluidStack>( this, StorageChannel.FLUIDS );
private HashMap<IGridNode, IStackWatcher> watchers = new HashMap<IGridNode, IStackWatcher>();
private final HashMap<IGridNode, IStackWatcher> watchers = new HashMap<IGridNode, IStackWatcher>();
public GridStorageCache(IGrid g) {
myGrid = g;
@@ -95,7 +95,7 @@ public class GridStorageCache implements IStorageGrid
private class CellChangeTracker
{
List<CellChangeTrackerRecord> data = new LinkedList<CellChangeTrackerRecord>();
final List<CellChangeTrackerRecord> data = new LinkedList<CellChangeTrackerRecord>();
public void postChanges(StorageChannel channel, int i, IMEInventoryHandler<? extends IAEStack> h, BaseActionSource actionSrc)
{
+1 -1
View File
@@ -16,7 +16,7 @@ public class TickTracker implements Comparable<TickTracker>
public final IGridNode node;
public final TickManagerCache host;
public long LastFiveTicksTime = 0;
public final long LastFiveTicksTime = 0;
public long lastTick;
public int current_rate;
+2 -2
View File
@@ -8,8 +8,8 @@ import appeng.parts.p2p.PartP2PTunnel;
public class TunnelIterator<T extends PartP2PTunnel> implements Iterator<T>
{
Iterator<T> wrapped;
Class targetType;
final Iterator<T> wrapped;
final Class targetType;
T Next;
private void findNext()
@@ -73,9 +73,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
boolean waiting = false;
private boolean isComplete = true;
int usedOps[] = new int[3];
final int[] usedOps = new int[3];
Map<ICraftingPatternDetails, TaskProgress> tasks = new HashMap<ICraftingPatternDetails, TaskProgress>();
final Map<ICraftingPatternDetails, TaskProgress> tasks = new HashMap<ICraftingPatternDetails, TaskProgress>();
IItemList<IAEItemStack> waitingFor = AEApi.instance().storage().createItemList();
// instance sate
@@ -90,8 +90,8 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
public String myName = "";
int accelerator = 0;
public WorldCoord min;
public WorldCoord max;
public final WorldCoord min;
public final WorldCoord max;
public boolean isDestroyed = false;
private final HashMap<IMEMonitorHandlerReceiver<IAEItemStack>, Object> listeners = new HashMap<IMEMonitorHandlerReceiver<IAEItemStack>, Object>();
@@ -48,9 +48,9 @@ public class EnergyWatcher implements IEnergyWatcher
}
EnergyGridCache gsc;
IEnergyWatcherHost myObject;
HashSet<EnergyThreshold> myInterests = new HashSet<EnergyThreshold>();
final EnergyGridCache gsc;
final IEnergyWatcherHost myObject;
final HashSet<EnergyThreshold> myInterests = new HashSet<EnergyThreshold>();
public void post(EnergyGridCache energyGridCache)
{
@@ -8,8 +8,8 @@ import appeng.api.networking.energy.IEnergySource;
public class ChannelPowerSrc implements IEnergySource
{
IGridNode node;
IEnergySource realSrc;
final IGridNode node;
final IEnergySource realSrc;
public ChannelPowerSrc(IGridNode networkNode, IEnergySource src) {
node = networkNode;
@@ -23,7 +23,7 @@ public class PathSegment
}
PathGridCache pgc;
final PathGridCache pgc;
public PathSegment(PathGridCache myPGC, List<IPathItem> open, Set<IPathItem> semiOpen, Set<IPathItem> closed)
{
@@ -35,8 +35,8 @@ public class PathSegment
}
List<IPathItem> open;
Set<IPathItem> semiOpen;
Set<IPathItem> closed;
final Set<IPathItem> semiOpen;
final Set<IPathItem> closed;
public boolean step()
{
@@ -335,7 +335,7 @@ public class CellInventory implements ICellInventory
return 8 - div;
}
private static HashSet<Integer> blackList = new HashSet<Integer>();
private static final HashSet<Integer> blackList = new HashSet<Integer>();
public static void addBasicBlackList(int itemID, int Meta)
{
@@ -16,7 +16,7 @@ import appeng.util.item.AEItemStack;
public class CreativeCellInventory implements IMEInventoryHandler<IAEItemStack>
{
IItemList<IAEItemStack> itemListCache = AEApi.instance().storage().createItemList();
final IItemList<IAEItemStack> itemListCache = AEApi.instance().storage().createItemList();
public static IMEInventoryHandler getCell(ItemStack o)
{
@@ -11,7 +11,7 @@ import appeng.api.storage.data.IAEStack;
public class DriveWatcher<T extends IAEStack<T>> extends MEInventoryHandler<T>
{
int oldStatus = 0;
final int oldStatus = 0;
final ItemStack is;
final ICellHandler handler;
final IChestOrDrive cord;
@@ -48,9 +48,9 @@ public class ItemWatcher implements IStackWatcher
}
GridStorageCache gsc;
IStackWatcherHost myObject;
HashSet<IAEStack> myInterests = new HashSet<IAEStack>();
final GridStorageCache gsc;
final IStackWatcherHost myObject;
final HashSet<IAEStack> myInterests = new HashSet<IAEStack>();
public ItemWatcher(GridStorageCache cache, IStackWatcherHost host) {
gsc = cache;
@@ -15,8 +15,8 @@ import appeng.util.item.AEItemStack;
public class MEIInventoryWrapper implements IMEInventory<IAEItemStack>
{
protected IInventory target;
protected InventoryAdaptor adaptor;
protected final IInventory target;
protected final InventoryAdaptor adaptor;
public MEIInventoryWrapper(IInventory m, InventoryAdaptor ia) {
target = m;
@@ -18,7 +18,7 @@ import appeng.util.inv.ItemListIgnoreCrafting;
public class MEMonitorPassThrough<T extends IAEStack<T>> extends MEPassThrough<T> implements IMEMonitor<T>, IMEMonitorHandlerReceiver<T>
{
HashMap<IMEMonitorHandlerReceiver<T>, Object> listeners = new HashMap<IMEMonitorHandlerReceiver<T>, Object>();
final HashMap<IMEMonitorHandlerReceiver<T>, Object> listeners = new HashMap<IMEMonitorHandlerReceiver<T>, Object>();
IMEMonitor<T> monitor;
public BaseActionSource changeSource;
@@ -12,7 +12,7 @@ import appeng.tile.misc.TileCondenser;
public class VoidFluidInventory implements IMEInventoryHandler<IAEFluidStack>
{
TileCondenser target;
final TileCondenser target;
public VoidFluidInventory(TileCondenser te) {
target = te;
@@ -12,7 +12,7 @@ import appeng.tile.misc.TileCondenser;
public class VoidItemInventory implements IMEInventoryHandler<IAEItemStack>
{
TileCondenser target;
final TileCondenser target;
public VoidItemInventory(TileCondenser te) {
target = te;