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
@@ -316,7 +316,7 @@ public class AdaptorIInventory extends InventoryAdaptor
return left;
}
boolean canRemoveStackFromSlot( final int x, final ItemStack is )
private boolean canRemoveStackFromSlot( final int x, final ItemStack is )
{
if( this.wrapperEnabled )
{
@@ -331,11 +331,11 @@ public class AdaptorIInventory extends InventoryAdaptor
return new InvIterator();
}
class InvIterator implements Iterator<ItemSlot>
private class InvIterator implements Iterator<ItemSlot>
{
final ItemSlot is = new ItemSlot();
int x = 0;
private final ItemSlot is = new ItemSlot();
private int x = 0;
@Override
public boolean hasNext()
@@ -348,10 +348,10 @@ public class AdaptorIInventory extends InventoryAdaptor
{
final ItemStack iss = AdaptorIInventory.this.i.getStackInSlot( this.x );
this.is.isExtractable = AdaptorIInventory.this.canRemoveStackFromSlot( this.x, iss );
this.is.setExtractable( AdaptorIInventory.this.canRemoveStackFromSlot( this.x, iss ) );
this.is.setItemStack( iss );
this.is.slot = this.x;
this.is.setSlot( this.x );
this.x++;
return this.is;
}
+16 -6
View File
@@ -38,9 +38,9 @@ import com.google.common.collect.ImmutableList;
public class IMEAdaptor extends InventoryAdaptor
{
final IMEInventory<IAEItemStack> target;
final BaseActionSource src;
int maxSlots = 0;
private final IMEInventory<IAEItemStack> target;
private final BaseActionSource src;
private int maxSlots = 0;
public IMEAdaptor( final IMEInventory<IAEItemStack> input, final BaseActionSource src )
{
@@ -54,7 +54,7 @@ public class IMEAdaptor extends InventoryAdaptor
return new IMEAdaptorIterator( this, this.getList() );
}
IItemList<IAEItemStack> getList()
private IItemList<IAEItemStack> getList()
{
return this.target.getAvailableItems( AEApi.instance().storage().createItemList() );
}
@@ -65,7 +65,7 @@ public class IMEAdaptor extends InventoryAdaptor
return this.doRemoveItems( amount, filter, destination, Actionable.MODULATE );
}
public ItemStack doRemoveItems( final int amount, final ItemStack filter, final IInventoryDestination destination, final Actionable type )
private ItemStack doRemoveItems( final int amount, final ItemStack filter, final IInventoryDestination destination, final Actionable type )
{
IAEItemStack req = null;
@@ -114,7 +114,7 @@ public class IMEAdaptor extends InventoryAdaptor
return this.doRemoveItemsFuzzy( amount, filter, destination, Actionable.MODULATE, fuzzyMode );
}
public ItemStack doRemoveItemsFuzzy( final int amount, final ItemStack filter, final IInventoryDestination destination, final Actionable type, final FuzzyMode fuzzyMode )
private ItemStack doRemoveItemsFuzzy( final int amount, final ItemStack filter, final IInventoryDestination destination, final Actionable type, final FuzzyMode fuzzyMode )
{
final IAEItemStack reqFilter = AEItemStack.create( filter );
if( reqFilter == null )
@@ -185,4 +185,14 @@ public class IMEAdaptor extends InventoryAdaptor
{
return !this.getList().isEmpty();
}
int getMaxSlots()
{
return this.maxSlots;
}
void setMaxSlots( final int maxSlots )
{
this.maxSlots = maxSlots;
}
}
@@ -38,7 +38,7 @@ public final class IMEAdaptorIterator implements Iterator<ItemSlot>
public IMEAdaptorIterator( final IMEAdaptor parent, final IItemList<IAEItemStack> availableItems )
{
this.stack = availableItems.iterator();
this.containerSize = parent.maxSlots;
this.containerSize = parent.getMaxSlots();
this.parent = parent;
}
@@ -52,13 +52,13 @@ public final class IMEAdaptorIterator implements Iterator<ItemSlot>
@Override
public ItemSlot next()
{
this.slot.slot = this.offset;
this.slot.setSlot( this.offset );
this.offset++;
this.slot.isExtractable = true;
this.slot.setExtractable( true );
if( this.parent.maxSlots < this.offset )
if( this.parent.getMaxSlots() < this.offset )
{
this.parent.maxSlots = this.offset;
this.parent.setMaxSlots( this.offset );
}
if( this.hasNext )
@@ -29,7 +29,7 @@ import appeng.util.item.AEItemStack;
public class IMEInventoryDestination implements IInventoryDestination
{
final IMEInventory<IAEItemStack> me;
private final IMEInventory<IAEItemStack> me;
public IMEInventoryDestination( final IMEInventory<IAEItemStack> o )
{
@@ -30,7 +30,7 @@ import appeng.api.storage.data.IItemList;
public class ItemListIgnoreCrafting<T extends IAEStack> implements IItemList<T>
{
final IItemList<T> target;
private final IItemList<T> target;
public ItemListIgnoreCrafting( final IItemList<T> cla )
{
+23 -3
View File
@@ -27,8 +27,8 @@ import appeng.util.item.AEItemStack;
public class ItemSlot
{
public int slot;
public boolean isExtractable;
private int slot;
private boolean isExtractable;
// one or the other..
private IAEItemStack aeItemStack;
private ItemStack itemStack;
@@ -49,9 +49,29 @@ public class ItemSlot
return this.aeItemStack == null ? ( this.itemStack == null ? null : ( this.aeItemStack = AEItemStack.create( this.itemStack ) ) ) : this.aeItemStack;
}
public void setAEItemStack( final IAEItemStack is )
void setAEItemStack( final IAEItemStack is )
{
this.aeItemStack = is;
this.itemStack = null;
}
public boolean isExtractable()
{
return this.isExtractable;
}
void setExtractable( final boolean isExtractable )
{
this.isExtractable = isExtractable;
}
public int getSlot()
{
return this.slot;
}
public void setSlot( final int slot )
{
this.slot = slot;
}
}
@@ -35,7 +35,7 @@ import net.minecraft.util.IChatComponent;
public class WrapperChainedInventory implements IInventory
{
int fullSize = 0;
private int fullSize = 0;
private List<IInventory> l;
private Map<Integer, InvOffset> offsets;
@@ -44,13 +44,13 @@ public class WrapperChainedInventory implements IInventory
this.setInventory( inventories );
}
public void setInventory( final IInventory... a )
private void setInventory( final IInventory... a )
{
this.l = ImmutableList.copyOf( a );
this.calculateSizes();
}
public void calculateSizes()
private void calculateSizes()
{
this.offsets = new HashMap<Integer, WrapperChainedInventory.InvOffset>();
@@ -78,7 +78,7 @@ public class WrapperChainedInventory implements IInventory
this.setInventory( inventories );
}
public void setInventory( final List<IInventory> a )
private void setInventory( final List<IInventory> a )
{
this.l = a;
this.calculateSizes();
@@ -230,12 +230,12 @@ public class WrapperChainedInventory implements IInventory
return false;
}
static class InvOffset
private static class InvOffset
{
int offset;
int size;
IInventory i;
private int offset;
private int size;
private IInventory i;
}
@Override
@@ -45,7 +45,7 @@ public class WrapperInvSlot
return true;
}
class InternalInterfaceWrapper implements IInventory
private class InternalInterfaceWrapper implements IInventory
{
private final IInventory inv;
@@ -29,31 +29,31 @@ public class WrapperInventoryRange implements IInventory
{
private final IInventory src;
protected boolean ignoreValidItems = false;
int[] slots;
private boolean ignoreValidItems = false;
private int[] slots;
public WrapperInventoryRange( final IInventory a, final int[] s, final boolean ignoreValid )
{
this.src = a;
this.slots = s;
this.setSlots( s );
if( this.slots == null )
if( this.getSlots() == null )
{
this.slots = new int[0];
this.setSlots( new int[0] );
}
this.ignoreValidItems = ignoreValid;
this.setIgnoreValidItems( ignoreValid );
}
public WrapperInventoryRange( final IInventory a, final int min, final int size, final boolean ignoreValid )
{
this.src = a;
this.slots = new int[size];
this.setSlots( new int[size] );
for( int x = 0; x < size; x++ )
{
this.slots[x] = min + x;
this.getSlots()[x] = min + x;
}
this.ignoreValidItems = ignoreValid;
this.setIgnoreValidItems( ignoreValid );
}
public static String concatLines( final int[] s, final String separator )
@@ -77,31 +77,31 @@ public class WrapperInventoryRange implements IInventory
@Override
public int getSizeInventory()
{
return this.slots.length;
return this.getSlots().length;
}
@Override
public ItemStack getStackInSlot( final int var1 )
{
return this.src.getStackInSlot( this.slots[var1] );
return this.src.getStackInSlot( this.getSlots()[var1] );
}
@Override
public ItemStack decrStackSize( final int var1, final int var2 )
{
return this.src.decrStackSize( this.slots[var1], var2 );
return this.src.decrStackSize( this.getSlots()[var1], var2 );
}
@Override
public ItemStack getStackInSlotOnClosing( final int var1 )
{
return this.src.getStackInSlotOnClosing( this.slots[var1] );
return this.src.getStackInSlotOnClosing( this.getSlots()[var1] );
}
@Override
public void setInventorySlotContents( final int var1, final ItemStack var2 )
{
this.src.setInventorySlotContents( this.slots[var1], var2 );
this.src.setInventorySlotContents( this.getSlots()[var1], var2 );
}
@Override
@@ -183,11 +183,31 @@ public class WrapperInventoryRange implements IInventory
@Override
public boolean isItemValidForSlot( final int i, final ItemStack itemstack )
{
if( this.ignoreValidItems )
if( this.isIgnoreValidItems() )
{
return true;
}
return this.src.isItemValidForSlot( this.slots[i], itemstack );
return this.src.isItemValidForSlot( this.getSlots()[i], itemstack );
}
boolean isIgnoreValidItems()
{
return this.ignoreValidItems;
}
private void setIgnoreValidItems( final boolean ignoreValidItems )
{
this.ignoreValidItems = ignoreValidItems;
}
int[] getSlots()
{
return this.slots;
}
private void setSlots( final int[] slots )
{
this.slots = slots;
}
}
@@ -27,7 +27,7 @@ import net.minecraft.util.EnumFacing;
public class WrapperMCISidedInventory extends WrapperInventoryRange implements IInventoryWrapper
{
final ISidedInventory side;
private final ISidedInventory side;
private final EnumFacing dir;
public WrapperMCISidedInventory( final ISidedInventory a, final EnumFacing d )
@@ -51,14 +51,14 @@ public class WrapperMCISidedInventory extends WrapperInventoryRange implements I
public boolean isItemValidForSlot( final int i, final ItemStack itemstack )
{
if( this.ignoreValidItems )
if( this.isIgnoreValidItems() )
{
return true;
}
if( this.side.isItemValidForSlot( this.slots[i], itemstack ) )
if( this.side.isItemValidForSlot( this.getSlots()[i], itemstack ) )
{
return this.side.canInsertItem( this.slots[i], itemstack, this.dir );
return this.side.canInsertItem( this.getSlots()[i], itemstack, this.dir );
}
return false;
@@ -72,6 +72,6 @@ public class WrapperMCISidedInventory extends WrapperInventoryRange implements I
return false;
}
return this.side.canExtractItem( this.slots[i], is, this.dir );
return this.side.canExtractItem( this.getSlots()[i], is, this.dir );
}
}