Merge pull request #175 from thatsIch/TypeSafety

Type safety
This commit is contained in:
Chris
2014-09-28 19:51:31 -07:00
111 changed files with 237 additions and 239 deletions
+1 -1
View File
@@ -156,7 +156,7 @@ public class GridConnection implements IGridConnection, IPathItem
@Override
public IReadOnlyCollection<IPathItem> getPossibleOptions()
{
return new ReadOnlyCollection( Arrays.asList( new IPathItem[] { (IPathItem) a(), (IPathItem) b() } ) );
return new ReadOnlyCollection<IPathItem>( Arrays.asList( (IPathItem) a(), (IPathItem) b() ) );
}
@Override
+5 -5
View File
@@ -39,7 +39,7 @@ public class GridNode implements IGridNode, IPathItem
final static private MENetworkChannelsChanged event = new MENetworkChannelsChanged();
final static private int channelCount[] = new int[] { 0, 8, 32 };
final List<IGridConnection> Connections = new LinkedList();
final List<IGridConnection> Connections = new LinkedList<IGridConnection>();
GridStorage myStorage = null;
IGridBlock gridProxy;
@@ -167,14 +167,14 @@ public class GridNode implements IGridNode, IPathItem
{
Object tracker = new Object();
LinkedList<GridNode> nextRun = new LinkedList();
LinkedList<GridNode> nextRun = new LinkedList<GridNode>();
nextRun.add( this );
visitorIterationNumber = tracker;
if ( g instanceof IGridConnectionVisitor )
{
LinkedList<IGridConnection> nextConn = new LinkedList();
LinkedList<IGridConnection> nextConn = new LinkedList<IGridConnection>();
IGridConnectionVisitor gcv = (IGridConnectionVisitor) g;
while (!nextRun.isEmpty())
@@ -183,7 +183,7 @@ public class GridNode implements IGridNode, IPathItem
gcv.visitConnection( nextConn.poll() );
LinkedList<GridNode> thisRun = nextRun;
nextRun = new LinkedList();
nextRun = new LinkedList<GridNode>();
for (GridNode n : thisRun)
n.visitorConnection( tracker, g, nextRun, nextConn );
@@ -194,7 +194,7 @@ public class GridNode implements IGridNode, IPathItem
while (!nextRun.isEmpty())
{
LinkedList<GridNode> thisRun = nextRun;
nextRun = new LinkedList();
nextRun = new LinkedList<GridNode>();
for (GridNode n : thisRun)
n.visitorNode( tracker, g, nextRun );
+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();
private WeakHashMap<GridStorage,Boolean> divided = new WeakHashMap<GridStorage,Boolean>();
final GridStorageSearch mySearchEntry; // keep myself in the list until I'm
// lost...
+4 -4
View File
@@ -57,7 +57,7 @@ public class NetworkEventBus
class MENetworkEventInfo
{
private ArrayList<EventMethod> methods = new ArrayList();
private 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();
private static Hashtable<Class<? extends MENetworkEvent>, Hashtable<Class, MENetworkEventInfo>> events = new Hashtable();
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>>();
public void readClass(Class listAs, Class c)
{
@@ -95,7 +95,7 @@ public class NetworkEventBus
Hashtable<Class, MENetworkEventInfo> classEvents = events.get( types[0] );
if ( classEvents == null )
events.put( types[0], classEvents = new Hashtable() );
events.put( types[0], classEvents = new Hashtable<Class, MENetworkEventInfo>() );
MENetworkEventInfo thisEvent = classEvents.get( listAs );
if ( thisEvent == null )
+1 -1
View File
@@ -8,7 +8,7 @@ import java.util.List;
public class NetworkList implements Collection<Grid>
{
private List<Grid> networks = new LinkedList();
private List<Grid> networks = new LinkedList<Grid>();
@Override
public boolean add(Grid e)
+10 -10
View File
@@ -68,8 +68,8 @@ import com.google.common.collect.SetMultimap;
public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper, ICellProvider, IMEInventoryHandler
{
HashSet<CraftingCPUCluster> cpuClusters = new HashSet();
HashSet<ICraftingProvider> providers = new HashSet();
HashSet<CraftingCPUCluster> cpuClusters = new HashSet<CraftingCPUCluster>();
HashSet<ICraftingProvider> providers = new HashSet<ICraftingProvider>();
private HashMap<IGridNode, ICraftingWatcher> watchers = new HashMap<IGridNode, ICraftingWatcher>();
@@ -77,14 +77,14 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
IStorageGrid sg;
IEnergyGrid eg;
HashMap<ICraftingPatternDetails, List<ICraftingMedium>> craftingMethods = new HashMap();
HashMap<IAEItemStack, ImmutableList<ICraftingPatternDetails>> craftableItems = new HashMap();
HashSet<IAEItemStack> emitableItems = new HashSet();
HashMap<String, CraftingLinkNexus> links = new HashMap();
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>();
boolean updateList = false;
final private SetMultimap<IAEStack, ItemWatcher> interests = HashMultimap.create();
final public GenericInterestManager interestManager = new GenericInterestManager( interests );
final private SetMultimap<IAEStack, CraftingWatcher> interests = HashMultimap.create();
final public GenericInterestManager<CraftingWatcher> interestManager = new GenericInterestManager<CraftingWatcher>( interests );
class ActiveCpuIterator implements Iterator<ICraftingCPU>
{
@@ -301,7 +301,7 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
// erase list.
craftingMethods.clear();
craftableItems = new HashMap();
craftableItems = new HashMap<IAEItemStack, ImmutableList<ICraftingPatternDetails>>();
emitableItems.clear();
// update the stuff that was in the list...
@@ -311,7 +311,7 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
for (ICraftingProvider cp : providers)
cp.provideCrafting( this );
HashMap<IAEItemStack, Set<ICraftingPatternDetails>> tmpCraft = new HashMap();
HashMap<IAEItemStack, Set<ICraftingPatternDetails>> tmpCraft = new HashMap<IAEItemStack, Set<ICraftingPatternDetails>>();
// new craftables!
for (ICraftingPatternDetails details : craftingMethods.keySet())
+3 -3
View File
@@ -71,15 +71,15 @@ public class EnergyGridCache implements IEnergyGrid
double extra = 0;
IAEPowerStorage lastProvider;
final Set<IAEPowerStorage> providers = new LinkedHashSet();
final Set<IAEPowerStorage> providers = new LinkedHashSet<IAEPowerStorage>();
IAEPowerStorage lastRequester;
final Set<IAEPowerStorage> requesters = new LinkedHashSet();
final Set<IAEPowerStorage> requesters = new LinkedHashSet<IAEPowerStorage>();
final public TreeSet<EnergyThreshold> interests = new TreeSet<EnergyThreshold>();
final private HashMap<IGridNode, IEnergyWatcher> watchers = new HashMap<IGridNode, IEnergyWatcher>();
final private Set<IEnergyGrid> localSeen = new HashSet();
final private Set<IEnergyGrid> localSeen = new HashSet<IEnergyGrid>();
private double buffer()
{
+4 -4
View File
@@ -39,10 +39,10 @@ public class GridStorageCache implements IStorageGrid
{
final private SetMultimap<IAEStack, ItemWatcher> interests = HashMultimap.create();
final public GenericInterestManager interestManager = new GenericInterestManager( interests );
final public GenericInterestManager<ItemWatcher> interestManager = new GenericInterestManager<ItemWatcher>( interests );
final HashSet<ICellProvider> activeCellProviders = new HashSet();
final HashSet<ICellProvider> inactiveCellProviders = new HashSet();
final HashSet<ICellProvider> activeCellProviders = new HashSet<ICellProvider>();
final HashSet<ICellProvider> inactiveCellProviders = new HashSet<ICellProvider>();
final public IGrid myGrid;
private NetworkInventoryHandler<IAEItemStack> myItemNetwork;
@@ -95,7 +95,7 @@ public class GridStorageCache implements IStorageGrid
private class CellChangeTracker
{
List<CellChangeTrackerRecord> data = new LinkedList();
List<CellChangeTrackerRecord> data = new LinkedList<CellChangeTrackerRecord>();
public void postChanges(StorageChannel channel, int i, IMEInventoryHandler<? extends IAEStack> h, BaseActionSource actionSrc)
{
+1 -1
View File
@@ -22,7 +22,7 @@ import com.google.common.collect.Multimap;
public class P2PCache implements IGridCache
{
final private HashMap<Long, PartP2PTunnel> inputs = new HashMap();
final private HashMap<Long, PartP2PTunnel> inputs = new HashMap<Long, PartP2PTunnel>();
final private Multimap<Long, PartP2PTunnel> outputs = LinkedHashMultimap.create();
final private TunnelCollection NullColl = new TunnelCollection<PartP2PTunnel>( null, null );
+6 -6
View File
@@ -43,7 +43,7 @@ public class PathGridCache implements IPathingGrid
boolean updateNetwork = true;
boolean booting = false;
final LinkedList<PathSegment> active = new LinkedList();
final LinkedList<PathSegment> active = new LinkedList<PathSegment>();
ControllerState controllerState = ControllerState.NO_CONTROLLER;
@@ -53,13 +53,13 @@ public class PathGridCache implements IPathingGrid
public int channelsInUse = 0;
int lastChannels = 0;
final Set<TileController> controllers = new HashSet();
final Set<IGridNode> requireChannels = new HashSet();
final Set<IGridNode> blockDense = new HashSet();
final Set<TileController> controllers = new HashSet<TileController>();
final Set<IGridNode> requireChannels = new HashSet<IGridNode>();
final Set<IGridNode> blockDense = new HashSet<IGridNode>();
final IGrid myGrid;
private HashSet<IPathItem> semiOpen = new HashSet();
private HashSet<IPathItem> closedList = new HashSet();
private HashSet<IPathItem> semiOpen = new HashSet<IPathItem>();
private HashSet<IPathItem> closedList = new HashSet<IPathItem>();
public int channelsByBlocks = 0;
public double channelPowerUsage = 0.0;
+1 -1
View File
@@ -22,7 +22,7 @@ import appeng.me.GridNode;
public class SecurityCache implements IGridCache, ISecurityGrid
{
final private List<ISecurityProvider> securityProvider = new ArrayList();
final private List<ISecurityProvider> securityProvider = new ArrayList<ISecurityProvider>();
final private HashMap<Integer, EnumSet<SecurityPermissions>> playerPerms = new HashMap<Integer, EnumSet<SecurityPermissions>>();
public SecurityCache(IGrid g) {
+4 -4
View File
@@ -29,8 +29,8 @@ public class SpatialPylonCache implements IGridCache, ISpatialCache
DimensionalCoord captureMax;
boolean isValid = false;
List<TileSpatialIOPort> ioPorts = new LinkedList();
HashMap<SpatialPylonCluster, SpatialPylonCluster> clusters = new HashMap();
List<TileSpatialIOPort> ioPorts = new LinkedList<TileSpatialIOPort>();
HashMap<SpatialPylonCluster, SpatialPylonCluster> clusters = new HashMap<SpatialPylonCluster, SpatialPylonCluster>();
boolean needsUpdate = false;
@@ -80,8 +80,8 @@ public class SpatialPylonCache implements IGridCache, ISpatialCache
double minPower = 0;
double maxPower = 0;
clusters = new HashMap();
ioPorts = new LinkedList();
clusters = new HashMap<SpatialPylonCluster, SpatialPylonCluster>();
ioPorts = new LinkedList<TileSpatialIOPort>();
for (IGridNode gm : grid.getMachines( TileSpatialIOPort.class ))
{
+1 -1
View File
@@ -10,7 +10,7 @@ public class Connections implements Callable
{
final private PartP2PTunnelME me;
final public HashMap<IGridNode, TunnelConnection> connections = new HashMap();
final public HashMap<IGridNode, TunnelConnection> connections = new HashMap<IGridNode, TunnelConnection>();
public boolean create = false;
public boolean destroy = false;
@@ -21,8 +21,8 @@ public class TunnelCollection<T extends PartP2PTunnel> implements Iterable<T>
public Iterator<T> iterator()
{
if ( tunnelSources == null )
return new NullIterator();
return new TunnelIterator( tunnelSources, clz );
return new NullIterator<T>();
return new TunnelIterator<T>( tunnelSources, clz );
}
public void setSource(Collection<T> c)
@@ -1,11 +1,7 @@
package appeng.me.cluster.implementations;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map;
import java.util.*;
import java.util.Map.Entry;
import java.util.Set;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
@@ -83,7 +79,7 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
IItemList<IAEItemStack> waitingFor = AEApi.instance().storage().createItemList();
// instance sate
final private LinkedList<TileCraftingTile> tiles = new LinkedList();
final private LinkedList<TileCraftingTile> tiles = new LinkedList<TileCraftingTile>();
final private LinkedList<TileCraftingTile> storage = new LinkedList<TileCraftingTile>();
final private LinkedList<TileCraftingMonitorTile> status = new LinkedList<TileCraftingMonitorTile>();
@@ -290,9 +286,11 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
if ( sg.interestManager.containsKey( diff ) )
{
Set<CraftingWatcher> list = sg.interestManager.get( diff );
if ( !list.isEmpty() )
{
for (CraftingWatcher iw : list)
iw.getHost().onRequestChange( sg, diff );
}
}
@@ -23,7 +23,7 @@ public class SpatialPylonCluster implements IAECluster
public Axis currentAxis = Axis.UNFORMED;
final List<TileSpatialPylon> line = new ArrayList();
final List<TileSpatialPylon> line = new ArrayList<TileSpatialPylon>();
public boolean isValid;
public boolean hasPower;
public boolean hasChannel;
@@ -50,7 +50,7 @@ public class EnergyWatcher implements IEnergyWatcher
EnergyGridCache gsc;
IEnergyWatcherHost myObject;
HashSet<EnergyThreshold> myInterests = new HashSet();
HashSet<EnergyThreshold> myInterests = new HashSet<EnergyThreshold>();
public void post(EnergyGridCache energyGridCache)
{
@@ -35,7 +35,7 @@ public class GenericInterestManager<T>
public void enableTransactions()
{
if ( transDepth == 0 )
transactions = new LinkedList();
transactions = new LinkedList<SavedTransactions>();
transDepth++;
}
@@ -25,7 +25,7 @@ public class PathSegment
PathGridCache pgc;
public PathSegment(PathGridCache myPGC, List open, Set semiOpen, Set closed)
public PathSegment(PathGridCache myPGC, List<IPathItem> open, Set<IPathItem> semiOpen, Set<IPathItem> closed)
{
this.open = open;
this.semiOpen = semiOpen;
@@ -41,7 +41,7 @@ public class PathSegment
public boolean step()
{
List<IPathItem> oldOpen = open;
open = new LinkedList();
open = new LinkedList<IPathItem>();
for (IPathItem i : oldOpen)
{
@@ -335,7 +335,7 @@ public class CellInventory implements ICellInventory
return 8 - div;
}
private static HashSet<Integer> blackList = new HashSet();
private static HashSet<Integer> blackList = new HashSet<Integer>();
public static void addBasicBlackList(int itemID, int Meta)
{
@@ -50,7 +50,7 @@ public class ItemWatcher implements IStackWatcher
GridStorageCache gsc;
IStackWatcherHost myObject;
HashSet<IAEStack> myInterests = new HashSet();
HashSet<IAEStack> myInterests = new HashSet<IAEStack>();
public ItemWatcher(GridStorageCache cache, IStackWatcherHost host) {
gsc = cache;
@@ -184,7 +184,7 @@ public class MEIInventoryWrapper implements IMEInventory<IAEItemStack>
}
@Override
public IItemList<IAEItemStack> getAvailableItems(IItemList out)
public IItemList<IAEItemStack> getAvailableItems(IItemList<IAEItemStack> out)
{
for (int x = 0; x < target.getSizeInventory(); x++)
{
@@ -52,7 +52,7 @@ public class MEMonitorIInventory implements IMEInventory<IAEItemStack>, IMEMonit
final TreeMap<Integer, CachedItemStack> memory;
final IItemList<IAEItemStack> list = AEApi.instance().storage().createItemList();
final HashMap<IMEMonitorHandlerReceiver<IAEItemStack>, Object> listeners = new HashMap();
final HashMap<IMEMonitorHandlerReceiver<IAEItemStack>, Object> listeners = new HashMap<IMEMonitorHandlerReceiver<IAEItemStack>, Object>();
public BaseActionSource mySource;
public StorageFilter mode = StorageFilter.EXTRACTABLE_ONLY;
@@ -72,7 +72,7 @@ public class MEMonitorIInventory implements IMEInventory<IAEItemStack>, IMEMonit
public MEMonitorIInventory(InventoryAdaptor adaptor)
{
this.adaptor = adaptor;
memory = new TreeMap();
memory = new TreeMap<Integer, CachedItemStack>();
}
@Override
@@ -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();
HashMap<IMEMonitorHandlerReceiver<T>, Object> listeners = new HashMap<IMEMonitorHandlerReceiver<T>, Object>();
IMEMonitor<T> monitor;
public BaseActionSource changeSource;
@@ -26,7 +26,7 @@ import appeng.util.ItemSorters;
public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInventoryHandler<T>
{
private final static Comparator prioritySorter = new Comparator<Integer>() {
private final static Comparator<Integer> prioritySorter = new Comparator<Integer>() {
@Override
public int compare(Integer o1, Integer o2)
@@ -45,7 +45,7 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
public NetworkInventoryHandler(StorageChannel chan, SecurityCache security) {
myChannel = chan;
this.security = security;
priorityInventory = new TreeMap( prioritySorter ); // TreeMultimap.create( prioritySorter, hashSorter );
priorityInventory = new TreeMap<Integer, List<IMEInventoryHandler<T>>>( prioritySorter ); // TreeMultimap.create( prioritySorter, hashSorter );
}
public void addNewStorage(IMEInventoryHandler<T> h)
@@ -53,7 +53,7 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
int priority = h.getPriority();
List<IMEInventoryHandler<T>> list = priorityInventory.get( priority );
if ( list == null )
priorityInventory.put( priority, list = new ArrayList() );
priorityInventory.put( priority, list = new ArrayList<IMEInventoryHandler<T>>() );
list.add( h );
}