Reduces visibility of internal fields/methods

Reduces the visibility of all fields to private and create setters/getters
when necessary. Exceptions are fields with GuiSync as these need to be
public.

Reduces the visibility of internal methods to private/protected/default when possible.
This commit is contained in:
yueh
2015-10-08 15:42:42 +02:00
parent f054bd699b
commit e94a0cfccf
497 changed files with 7865 additions and 6908 deletions
@@ -48,25 +48,25 @@ import appeng.util.item.AEItemStack;
public class CellInventory implements ICellInventory
{
static final String ITEM_TYPE_TAG = "it";
static final String ITEM_COUNT_TAG = "ic";
static final String ITEM_SLOT = "#";
static final String ITEM_SLOT_COUNT = "@";
static final String ITEM_PRE_FORMATTED_COUNT = "PF";
static final String ITEM_PRE_FORMATTED_SLOT = "PF#";
static final String ITEM_PRE_FORMATTED_NAME = "PN";
static final String ITEM_PRE_FORMATTED_FUZZY = "FP";
private static final String ITEM_TYPE_TAG = "it";
private static final String ITEM_COUNT_TAG = "ic";
private static final String ITEM_SLOT = "#";
private static final String ITEM_SLOT_COUNT = "@";
private static final String ITEM_PRE_FORMATTED_COUNT = "PF";
private static final String ITEM_PRE_FORMATTED_SLOT = "PF#";
private static final String ITEM_PRE_FORMATTED_NAME = "PN";
private static final String ITEM_PRE_FORMATTED_FUZZY = "FP";
private static final HashSet<Integer> BLACK_LIST = new HashSet<Integer>();
protected static String[] itemSlots;
protected static String[] itemSlotCount;
protected final NBTTagCompound tagCompound;
protected final ISaveProvider container;
protected int maxItemTypes = 63;
protected short storedItems = 0;
protected int storedItemCount = 0;
protected IItemList<IAEItemStack> cellItems;
protected ItemStack i;
protected IStorageCell cellType;
private static String[] itemSlots;
private static String[] itemSlotCount;
private final NBTTagCompound tagCompound;
private final ISaveProvider container;
private int maxItemTypes = 63;
private short storedItems = 0;
private int storedItemCount = 0;
private IItemList<IAEItemStack> cellItems;
private ItemStack i;
private IStorageCell cellType;
protected CellInventory( final NBTTagCompound data, final ISaveProvider container )
{
@@ -74,7 +74,7 @@ public class CellInventory implements ICellInventory
this.container = container;
}
protected CellInventory( final ItemStack o, final ISaveProvider container ) throws AppEngException
private CellInventory( final ItemStack o, final ISaveProvider container ) throws AppEngException
{
if( itemSlots == null )
{
@@ -185,7 +185,7 @@ public class CellInventory implements ICellInventory
BLACK_LIST.add( ( meta << Platform.DEF_OFFSET ) | itemID );
}
public static boolean isBlackListed( final IAEItemStack input )
private static boolean isBlackListed( final IAEItemStack input )
{
if( BLACK_LIST.contains( ( OreDictionary.WILDCARD_VALUE << Platform.DEF_OFFSET ) | Item.getIdFromItem( input.getItem() ) ) )
{
@@ -108,7 +108,7 @@ public class CellInventoryHandler extends MEInventoryHandler<IAEItemStack> imple
@Override
public ICellInventory getCellInv()
{
Object o = this.internal;
Object o = this.getInternal();
if( o instanceof MEPassThrough )
{
@@ -35,7 +35,7 @@ import appeng.util.item.AEItemStack;
public class CreativeCellInventory implements IMEInventoryHandler<IAEItemStack>
{
final IItemList<IAEItemStack> itemListCache = AEApi.instance().storage().createItemList();
private final IItemList<IAEItemStack> itemListCache = AEApi.instance().storage().createItemList();
protected CreativeCellInventory( final ItemStack o )
{
@@ -31,10 +31,10 @@ import appeng.api.storage.data.IAEStack;
public class DriveWatcher<T extends IAEStack<T>> extends MEInventoryHandler<T>
{
final int oldStatus = 0;
final ItemStack is;
final ICellHandler handler;
final IChestOrDrive cord;
private final int oldStatus = 0;
private final ItemStack is;
private final ICellHandler handler;
private final IChestOrDrive cord;
public DriveWatcher( final IMEInventory<T> i, final ItemStack is, final ICellHandler han, final IChestOrDrive cod )
{
@@ -35,9 +35,9 @@ import appeng.me.cache.GridStorageCache;
public class ItemWatcher implements IStackWatcher
{
final GridStorageCache gsc;
final IStackWatcherHost myObject;
final HashSet<IAEStack> myInterests = new HashSet<IAEStack>();
private final GridStorageCache gsc;
private final IStackWatcherHost myObject;
private final HashSet<IAEStack> myInterests = new HashSet<IAEStack>();
public ItemWatcher( final GridStorageCache cache, final IStackWatcherHost host )
{
@@ -94,13 +94,13 @@ public class ItemWatcher implements IStackWatcher
return false;
}
return this.myInterests.add( e.copy() ) && this.gsc.interestManager.put( e, this );
return this.myInterests.add( e.copy() ) && this.gsc.getInterestManager().put( e, this );
}
@Override
public boolean remove( final Object o )
{
return this.myInterests.remove( o ) && this.gsc.interestManager.remove( (IAEStack) o, this );
return this.myInterests.remove( o ) && this.gsc.getInterestManager().remove( (IAEStack) o, this );
}
@Override
@@ -157,17 +157,17 @@ public class ItemWatcher implements IStackWatcher
final Iterator<IAEStack> i = this.myInterests.iterator();
while( i.hasNext() )
{
this.gsc.interestManager.remove( i.next(), this );
this.gsc.getInterestManager().remove( i.next(), this );
i.remove();
}
}
class ItemWatcherIterator implements Iterator<IAEStack>
private class ItemWatcherIterator implements Iterator<IAEStack>
{
final ItemWatcher watcher;
final Iterator<IAEStack> interestIterator;
IAEStack myLast;
private final ItemWatcher watcher;
private final Iterator<IAEStack> interestIterator;
private IAEStack myLast;
public ItemWatcherIterator( final ItemWatcher parent, final Iterator<IAEStack> i )
{
@@ -190,7 +190,7 @@ public class ItemWatcher implements IStackWatcher
@Override
public void remove()
{
ItemWatcher.this.gsc.interestManager.remove( this.myLast, this.watcher );
ItemWatcher.this.gsc.getInterestManager().remove( this.myLast, this.watcher );
this.interestIterator.remove();
}
}
@@ -35,8 +35,8 @@ import appeng.util.item.AEItemStack;
public class MEIInventoryWrapper implements IMEInventory<IAEItemStack>
{
protected final IInventory target;
protected final InventoryAdaptor adaptor;
private final IInventory target;
private final InventoryAdaptor adaptor;
public MEIInventoryWrapper( final IInventory m, final InventoryAdaptor ia )
{
@@ -25,7 +25,6 @@ import appeng.api.config.IncludeExclude;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEStack;
import appeng.api.storage.data.IItemList;
@@ -36,9 +35,7 @@ import appeng.util.prioitylist.IPartitionList;
public class MEInventoryHandler<T extends IAEStack<T>> implements IMEInventoryHandler<T>
{
protected final IMEMonitor<T> monitor;
protected final IMEInventoryHandler<T> internal;
final StorageChannel channel;
private final IMEInventoryHandler<T> internal;
private int myPriority;
private IncludeExclude myWhitelist;
private AccessRestriction myAccess;
@@ -50,8 +47,6 @@ public class MEInventoryHandler<T extends IAEStack<T>> implements IMEInventoryHa
public MEInventoryHandler( final IMEInventory<T> i, final StorageChannel channel )
{
this.channel = channel;
if( i instanceof IMEInventoryHandler )
{
this.internal = (IMEInventoryHandler<T>) i;
@@ -61,15 +56,13 @@ public class MEInventoryHandler<T extends IAEStack<T>> implements IMEInventoryHa
this.internal = new MEPassThrough<T>( i, channel );
}
this.monitor = this.internal instanceof IMEMonitor ? (IMEMonitor<T>) this.internal : null;
this.myPriority = 0;
this.myWhitelist = IncludeExclude.WHITELIST;
this.setBaseAccess( AccessRestriction.READ_WRITE );
this.myPartitionList = new DefaultPriorityList<T>();
}
public IncludeExclude getWhitelist()
IncludeExclude getWhitelist()
{
return this.myWhitelist;
}
@@ -92,7 +85,7 @@ public class MEInventoryHandler<T extends IAEStack<T>> implements IMEInventoryHa
this.hasWriteAccess = this.cachedAccessRestriction.hasPermission( AccessRestriction.WRITE );
}
public IPartitionList<T> getPartitionList()
IPartitionList<T> getPartitionList()
{
return this.myPartitionList;
}
@@ -46,12 +46,12 @@ import appeng.util.inv.ItemSlot;
public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>
{
final InventoryAdaptor adaptor;
final IItemList<IAEItemStack> list = AEApi.instance().storage().createItemList();
final HashMap<IMEMonitorHandlerReceiver<IAEItemStack>, Object> listeners = new HashMap<IMEMonitorHandlerReceiver<IAEItemStack>, Object>();
private final InventoryAdaptor adaptor;
private final IItemList<IAEItemStack> list = AEApi.instance().storage().createItemList();
private final HashMap<IMEMonitorHandlerReceiver<IAEItemStack>, Object> listeners = new HashMap<IMEMonitorHandlerReceiver<IAEItemStack>, Object>();
private final NavigableMap<Integer, CachedItemStack> memory;
public BaseActionSource mySource;
public StorageFilter mode = StorageFilter.EXTRACTABLE_ONLY;
private BaseActionSource mySource;
private StorageFilter mode = StorageFilter.EXTRACTABLE_ONLY;
public MEMonitorIInventory( final InventoryAdaptor adaptor )
{
@@ -148,16 +148,16 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>
boolean changed = false;
for( final ItemSlot is : this.adaptor )
{
final CachedItemStack old = this.memory.get( is.slot );
high = Math.max( high, is.slot );
final CachedItemStack old = this.memory.get( is.getSlot() );
high = Math.max( high, is.getSlot() );
final ItemStack newIS = !is.isExtractable && this.mode == StorageFilter.EXTRACTABLE_ONLY ? null : is.getItemStack();
final ItemStack newIS = !is.isExtractable() && this.getMode() == StorageFilter.EXTRACTABLE_ONLY ? null : is.getItemStack();
final ItemStack oldIS = old == null ? null : old.itemStack;
if( this.isDifferent( newIS, oldIS ) )
{
final CachedItemStack cis = new CachedItemStack( is.getItemStack() );
this.memory.put( is.slot, cis );
this.memory.put( is.getSlot(), cis );
if( old != null && old.aeStack != null )
{
@@ -188,7 +188,7 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>
if( diff != 0 && stack != null )
{
final CachedItemStack cis = new CachedItemStack( is.getItemStack() );
this.memory.put( is.slot, cis );
this.memory.put( is.getSlot(), cis );
final IAEItemStack a = stack.copy();
a.setStackSize( diff );
@@ -250,7 +250,7 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>
final IMEMonitorHandlerReceiver<IAEItemStack> key = l.getKey();
if( key.isValid( l.getValue() ) )
{
key.postChange( this, a, this.mySource );
key.postChange( this, a, this.getActionSource() );
}
else
{
@@ -313,11 +313,31 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>
return this.list;
}
static class CachedItemStack
private StorageFilter getMode()
{
return this.mode;
}
public void setMode( final StorageFilter mode )
{
this.mode = mode;
}
private BaseActionSource getActionSource()
{
return this.mySource;
}
public void setActionSource( final BaseActionSource mySource )
{
this.mySource = mySource;
}
private static class CachedItemStack
{
final ItemStack itemStack;
final IAEItemStack aeStack;
private final ItemStack itemStack;
private final IAEItemStack aeStack;
public CachedItemStack( final ItemStack is )
{
@@ -38,9 +38,9 @@ import appeng.util.inv.ItemListIgnoreCrafting;
public class MEMonitorPassThrough<T extends IAEStack<T>> extends MEPassThrough<T> implements IMEMonitor<T>, IMEMonitorHandlerReceiver<T>
{
final HashMap<IMEMonitorHandlerReceiver<T>, Object> listeners = new HashMap<IMEMonitorHandlerReceiver<T>, Object>();
public BaseActionSource changeSource;
IMEMonitor<T> monitor;
private final HashMap<IMEMonitorHandlerReceiver<T>, Object> listeners = new HashMap<IMEMonitorHandlerReceiver<T>, Object>();
private BaseActionSource changeSource;
private IMEMonitor<T> monitor;
public MEMonitorPassThrough( final IMEInventory<T> i, final StorageChannel channel )
{
@@ -60,7 +60,7 @@ public class MEMonitorPassThrough<T extends IAEStack<T>> extends MEPassThrough<T
}
this.monitor = null;
final IItemList<T> before = this.getInternal() == null ? this.channel.createList() : this.getInternal().getAvailableItems( new ItemListIgnoreCrafting( this.channel.createList() ) );
final IItemList<T> before = this.getInternal() == null ? this.getWrappedChannel().createList() : this.getInternal().getAvailableItems( new ItemListIgnoreCrafting( this.getWrappedChannel().createList() ) );
super.setInternal( i );
if( i instanceof IMEMonitor )
@@ -68,14 +68,14 @@ public class MEMonitorPassThrough<T extends IAEStack<T>> extends MEPassThrough<T
this.monitor = (IMEMonitor<T>) i;
}
final IItemList<T> after = this.getInternal() == null ? this.channel.createList() : this.getInternal().getAvailableItems( new ItemListIgnoreCrafting( this.channel.createList() ) );
final IItemList<T> after = this.getInternal() == null ? this.getWrappedChannel().createList() : this.getInternal().getAvailableItems( new ItemListIgnoreCrafting( this.getWrappedChannel().createList() ) );
if( this.monitor != null )
{
this.monitor.addListener( this, this.monitor );
}
Platform.postListChanges( before, after, this, this.changeSource );
Platform.postListChanges( before, after, this, this.getChangeSource() );
}
@Override
@@ -102,7 +102,7 @@ public class MEMonitorPassThrough<T extends IAEStack<T>> extends MEPassThrough<T
{
if( this.monitor == null )
{
final IItemList<T> out = this.channel.createList();
final IItemList<T> out = this.getWrappedChannel().createList();
this.getInternal().getAvailableItems( new ItemListIgnoreCrafting( out ) );
return out;
}
@@ -152,4 +152,14 @@ public class MEMonitorPassThrough<T extends IAEStack<T>> extends MEPassThrough<T
}
}
}
private BaseActionSource getChangeSource()
{
return this.changeSource;
}
public void setChangeSource( final BaseActionSource changeSource )
{
this.changeSource = changeSource;
}
}
@@ -32,12 +32,12 @@ import appeng.api.storage.data.IItemList;
public class MEPassThrough<T extends IAEStack<T>> implements IMEInventoryHandler<T>
{
protected final StorageChannel channel;
private final StorageChannel wrappedChannel;
private IMEInventory<T> internal;
public MEPassThrough( final IMEInventory<T> i, final StorageChannel channel )
{
this.channel = channel;
this.wrappedChannel = channel;
this.setInternal( i );
}
@@ -110,4 +110,9 @@ public class MEPassThrough<T extends IAEStack<T>> implements IMEInventoryHandler
{
return true;
}
StorageChannel getWrappedChannel()
{
return this.wrappedChannel;
}
}
@@ -47,8 +47,8 @@ import appeng.util.ItemSorters;
public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInventoryHandler<T>
{
static final ThreadLocal<LinkedList> DEPTH_MOD = new ThreadLocal<LinkedList>();
static final ThreadLocal<LinkedList> DEPTH_SIM = new ThreadLocal<LinkedList>();
private static final ThreadLocal<LinkedList> DEPTH_MOD = new ThreadLocal<LinkedList>();
private static final ThreadLocal<LinkedList> DEPTH_SIM = new ThreadLocal<LinkedList>();
private static final Comparator<Integer> PRIORITY_SORTER = new Comparator<Integer>()
{
@@ -58,12 +58,12 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
return ItemSorters.compareInt( o2, o1 );
}
};
static int currentPass = 0;
final StorageChannel myChannel;
final SecurityCache security;
private static int currentPass = 0;
private final StorageChannel myChannel;
private final SecurityCache security;
// final TreeMultimap<Integer, IMEInventoryHandler<T>> priorityInventory;
private final NavigableMap<Integer, List<IMEInventoryHandler<T>>> priorityInventory;
int myPass = 0;
private int myPass = 0;
public NetworkInventoryHandler( final StorageChannel chan, final SecurityCache security )
{
@@ -164,7 +164,7 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
}
final IGrid gn = n.getGrid();
if( gn != this.security.myGrid )
if( gn != this.security.getGrid() )
{
final ISecurityGrid sg = gn.getCache( ISecurityGrid.class );
@@ -39,8 +39,8 @@ import com.mojang.authlib.GameProfile;
public class SecurityInventory implements IMEInventoryHandler<IAEItemStack>
{
public final IItemList<IAEItemStack> storedItems = AEApi.instance().storage().createItemList();
final TileSecurity securityTile;
private final IItemList<IAEItemStack> storedItems = AEApi.instance().storage().createItemList();
private final TileSecurity securityTile;
public SecurityInventory( final TileSecurity ts )
{
@@ -61,7 +61,7 @@ public class SecurityInventory implements IMEInventoryHandler<IAEItemStack>
return null;
}
this.storedItems.add( input );
this.getStoredItems().add( input );
this.securityTile.inventoryChanged();
return null;
}
@@ -91,7 +91,7 @@ public class SecurityInventory implements IMEInventoryHandler<IAEItemStack>
{
if( this.hasPermission( src ) )
{
final IAEItemStack target = this.storedItems.findPrecise( request );
final IAEItemStack target = this.getStoredItems().findPrecise( request );
if( target != null )
{
final IAEItemStack output = target.copy();
@@ -112,7 +112,7 @@ public class SecurityInventory implements IMEInventoryHandler<IAEItemStack>
@Override
public IItemList<IAEItemStack> getAvailableItems( final IItemList out )
{
for( final IAEItemStack ais : this.storedItems )
for( final IAEItemStack ais : this.getStoredItems() )
{
out.add( ais );
}
@@ -152,7 +152,7 @@ public class SecurityInventory implements IMEInventoryHandler<IAEItemStack>
return false;
}
for( final IAEItemStack ais : this.storedItems )
for( final IAEItemStack ais : this.getStoredItems() )
{
if( ais.isMeaningful() )
{
@@ -191,4 +191,9 @@ public class SecurityInventory implements IMEInventoryHandler<IAEItemStack>
{
return true;
}
public IItemList<IAEItemStack> getStoredItems()
{
return this.storedItems;
}
}
@@ -32,7 +32,7 @@ import appeng.tile.misc.TileCondenser;
public class VoidFluidInventory implements IMEInventoryHandler<IAEFluidStack>
{
final TileCondenser target;
private final TileCondenser target;
public VoidFluidInventory( final TileCondenser te )
{
@@ -32,7 +32,7 @@ import appeng.tile.misc.TileCondenser;
public class VoidItemInventory implements IMEInventoryHandler<IAEItemStack>
{
final TileCondenser target;
private final TileCondenser target;
public VoidItemInventory( final TileCondenser te )
{