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
+2 -2
View File
@@ -10,8 +10,8 @@ import appeng.core.AELog;
public class ConfigManager implements IConfigManager
{
HashMap<Enum, Enum> Settings = new HashMap<Enum, Enum>();
IConfigManagerHost target;
final HashMap<Enum, Enum> Settings = new HashMap<Enum, Enum>();
final IConfigManagerHost target;
public ConfigManager(IConfigManagerHost tile) {
target = tile;
@@ -10,8 +10,8 @@ import net.minecraft.item.ItemStack;
public class InWorldToolOperationResult
{
public ItemStack BlockItem;
public List<ItemStack> Drops;
public final ItemStack BlockItem;
public final List<ItemStack> Drops;
public static InWorldToolOperationResult getBlockOperationResult(ItemStack[] items)
{
+4 -4
View File
@@ -53,7 +53,7 @@ public class ItemSorters
return 1;
}
public static Comparator<IAEItemStack> ConfigBased_SortByName = new Comparator<IAEItemStack>() {
public static final Comparator<IAEItemStack> ConfigBased_SortByName = new Comparator<IAEItemStack>() {
@Override
public int compare(IAEItemStack o1, IAEItemStack o2)
@@ -64,7 +64,7 @@ public class ItemSorters
}
};
public static Comparator<IAEItemStack> ConfigBased_SortByMod = new Comparator<IAEItemStack>() {
public static final Comparator<IAEItemStack> ConfigBased_SortByMod = new Comparator<IAEItemStack>() {
@Override
public int compare(IAEItemStack o1, IAEItemStack o2)
@@ -86,7 +86,7 @@ public class ItemSorters
}
};
public static Comparator<IAEItemStack> ConfigBased_SortBySize = new Comparator<IAEItemStack>() {
public static final Comparator<IAEItemStack> ConfigBased_SortBySize = new Comparator<IAEItemStack>() {
@Override
public int compare(IAEItemStack o1, IAEItemStack o2)
@@ -97,7 +97,7 @@ public class ItemSorters
}
};
public static Comparator<IAEItemStack> ConfigBased_SortByInvTweaks = new Comparator<IAEItemStack>() {
public static final Comparator<IAEItemStack> ConfigBased_SortByInvTweaks = new Comparator<IAEItemStack>() {
@Override
public int compare(IAEItemStack o1, IAEItemStack o2)
+3 -3
View File
@@ -119,14 +119,14 @@ import cpw.mods.fml.relauncher.SideOnly;
public class Platform
{
public static Block air = Blocks.air;
public static final Block air = Blocks.air;
public static final int DEF_OFFSET = 16;
/*
* random source, use it for item drop locations...
*/
static private Random rdnSrc = new Random();
static private final Random rdnSrc = new Random();
public static Random getRandom()
{
@@ -907,7 +907,7 @@ public class Platform
return false;
}
private static WeakHashMap<World, EntityPlayer> fakePlayers = new WeakHashMap<World, EntityPlayer>();
private static final WeakHashMap<World, EntityPlayer> fakePlayers = new WeakHashMap<World, EntityPlayer>();
public static EntityPlayer getPlayer(WorldServer w)
{
@@ -11,8 +11,8 @@ import appeng.util.Platform;
public class AdaptorIInventory extends InventoryAdaptor
{
private IInventory i;
private boolean wrapperEnabled;
private final IInventory i;
private final boolean wrapperEnabled;
public AdaptorIInventory(IInventory s) {
i = s;
@@ -12,10 +12,10 @@ import buildcraft.api.inventory.ISpecialInventory;
public class AdaptorISpecialInventory extends InventoryAdaptor
{
private AdaptorIInventory remover;
private final AdaptorIInventory remover;
private ISpecialInventory i;
private ForgeDirection d;
private final ISpecialInventory i;
private final ForgeDirection d;
public AdaptorISpecialInventory(ISpecialInventory s, ForgeDirection dd) {
i = s;
@@ -12,7 +12,7 @@ import appeng.util.iterators.StackToSlotIterator;
public class AdaptorList extends InventoryAdaptor
{
private List<ItemStack> i;
private final List<ItemStack> i;
public AdaptorList(List<ItemStack> s) {
i = s;
@@ -15,7 +15,7 @@ import appeng.util.iterators.NullIterator;
public class AdaptorPlayerHand extends InventoryAdaptor
{
private EntityPlayer p;
private final EntityPlayer p;
public AdaptorPlayerHand(EntityPlayer _p) {
p = _p;
@@ -18,8 +18,8 @@ import com.google.common.collect.ImmutableList;
public class IMEAdaptor extends InventoryAdaptor
{
IMEInventory<IAEItemStack> target;
BaseActionSource src;
final IMEInventory<IAEItemStack> target;
final BaseActionSource src;
int maxSlots = 0;
public IMEAdaptor(IMEInventory<IAEItemStack> input, BaseActionSource src) {
@@ -8,8 +8,8 @@ import appeng.api.storage.data.IItemList;
public class IMEAdaptorIterator implements Iterator<ItemSlot>
{
Iterator<IAEItemStack> stack;
ItemSlot slot = new ItemSlot();
final Iterator<IAEItemStack> stack;
final ItemSlot slot = new ItemSlot();
int offset = 0;
boolean hasNext;
@@ -9,7 +9,7 @@ import appeng.util.item.AEItemStack;
public class IMEInventoryDestination implements IInventoryDestination
{
IMEInventory<IAEItemStack> me;
final IMEInventory<IAEItemStack> me;
public IMEInventoryDestination(IMEInventory<IAEItemStack> o) {
me = o;
@@ -97,7 +97,7 @@ public class WrapperInvSlot
}
}
private IInventory inv;
private final IInventory inv;
public WrapperInvSlot(IInventory inv) {
this.inv = inv;
@@ -7,7 +7,7 @@ import net.minecraft.item.ItemStack;
public class WrapperInventoryRange implements IInventory
{
private IInventory src;
private final IInventory src;
int[] slots;
protected boolean ignoreValidItems = false;
@@ -8,8 +8,8 @@ import net.minecraftforge.common.util.ForgeDirection;
public class WrapperMCISidedInventory extends WrapperInventoryRange implements IInventory, IInventoryWrapper
{
private ForgeDirection dir;
ISidedInventory side;
private final ForgeDirection dir;
final ISidedInventory side;
public WrapperMCISidedInventory(ISidedInventory a, ForgeDirection d) {
super( a, a.getAccessibleSlotsFromSide( d.ordinal() ), false );
@@ -9,8 +9,8 @@ import net.minecraftforge.common.util.ForgeDirection;
public class WrapperTEPipe implements IInventory
{
TileEntity ad;
ForgeDirection dir;
final TileEntity ad;
final ForgeDirection dir;
public WrapperTEPipe(TileEntity te, ForgeDirection d) {
ad = te;
@@ -17,8 +17,8 @@ public class AEItemDef
public int def;
private int itemID;
public Item item;
private final int itemID;
public final Item item;
public int damageValue;
public int displayDamage;
@@ -37,8 +37,8 @@ public class AEItemDef
public OreReference isOre;
static AESharedNBT lowTag = new AESharedNBT( Integer.MIN_VALUE );
static AESharedNBT highTag = new AESharedNBT( Integer.MAX_VALUE );
static final AESharedNBT lowTag = new AESharedNBT( Integer.MIN_VALUE );
static final AESharedNBT highTag = new AESharedNBT( Integer.MAX_VALUE );
public AEItemDef(Item it) {
item = it;
@@ -18,8 +18,9 @@ import appeng.util.Platform;
public class AESharedNBT extends NBTTagCompound implements IAETagCompound
{
private Item item;
private int meta, hash;
private final Item item;
private final int meta;
private int hash;
public SharedSearchObject sso;
private IItemComparison comp;
@@ -120,7 +121,7 @@ public class AESharedNBT extends NBTTagCompound implements IAETagCompound
/*
* Shared Tag Compound Cache.
*/
private static WeakHashMap<SharedSearchObject, WeakReference<SharedSearchObject>> sharedTagCompounds = new WeakHashMap<SharedSearchObject, WeakReference<SharedSearchObject>>();
private static final WeakHashMap<SharedSearchObject, WeakReference<SharedSearchObject>> sharedTagCompounds = new WeakHashMap<SharedSearchObject, WeakReference<SharedSearchObject>>();
/*
* Debug purposes.
@@ -11,7 +11,7 @@ import appeng.api.storage.data.IAEItemStack;
public class OreHelper
{
public static OreHelper instance = new OreHelper();
public static final OreHelper instance = new OreHelper();
class ItemRef
{
@@ -28,9 +28,9 @@ public class OreHelper
hash = ref.hashCode() ^ damage;
}
Item ref;
int damage;
int hash;
final Item ref;
final int damage;
final int hash;
@Override
public boolean equals(Object obj)
@@ -58,7 +58,7 @@ public class OreHelper
}
HashMap<ItemRef, OreResult> references = new HashMap<ItemRef, OreResult>();
final HashMap<ItemRef, OreResult> references = new HashMap<ItemRef, OreResult>();
public OreReference isOre(ItemStack ItemStack)
{
@@ -12,9 +12,9 @@ import appeng.api.storage.data.IAEItemStack;
public class OreReference
{
private LinkedList<ItemStack> otherOptions = new LinkedList<ItemStack>();
private final LinkedList<ItemStack> otherOptions = new LinkedList<ItemStack>();
private ArrayList<IAEItemStack> aeOtherOptions = null;
private HashSet<Integer> ores = new HashSet<Integer>();
private final HashSet<Integer> ores = new HashSet<Integer>();
public Collection<ItemStack> getEquivalents()
{
@@ -7,8 +7,8 @@ import appeng.util.Platform;
public class SharedSearchObject
{
int def;
int hash;
final int def;
final int hash;
NBTTagCompound compound;
public AESharedNBT shared;
@@ -6,7 +6,7 @@ public class ChainedIterator<T> implements Iterator<T>
{
int offset = 0;
T[] list;
final T[] list;
public ChainedIterator(T... list) {
this.list = list;
@@ -9,7 +9,7 @@ import appeng.api.networking.IGridNode;
public class ProxyNodeIterator implements Iterator<IGridNode>
{
Iterator<IGridHost> hosts;
final Iterator<IGridHost> hosts;
public ProxyNodeIterator(Iterator<IGridHost> hosts) {
this.hosts = hosts;