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 1ea48fb389
commit 500fc47490
463 changed files with 5670 additions and 3757 deletions
@@ -32,16 +32,16 @@ import appeng.core.AELog;
public final class IntegrationNode
{
final String displayName;
final String modID;
final IntegrationType shortName;
IntegrationStage state = IntegrationStage.PRE_INIT;
IntegrationStage failedStage = IntegrationStage.PRE_INIT;
Throwable exception = null;
String name = null;
Class<?> classValue = null;
Object instance;
IIntegrationModule mod = null;
private final String displayName;
private final String modID;
private final IntegrationType shortName;
private IntegrationStage state = IntegrationStage.PRE_INIT;
private IntegrationStage failedStage = IntegrationStage.PRE_INIT;
private Throwable exception = null;
private String name = null;
private Class<?> classValue = null;
private Object instance;
private IIntegrationModule mod = null;
public IntegrationNode( final String displayName, final String modID, final IntegrationType shortName, final String name )
{
@@ -54,24 +54,24 @@ public final class IntegrationNode
@Override
public String toString()
{
return this.shortName.name() + ':' + this.state.name();
return this.getShortName().name() + ':' + this.getState().name();
}
public boolean isActive()
boolean isActive()
{
if( this.state == IntegrationStage.PRE_INIT )
if( this.getState() == IntegrationStage.PRE_INIT )
{
this.call( IntegrationStage.PRE_INIT );
}
return this.state != IntegrationStage.FAILED;
return this.getState() != IntegrationStage.FAILED;
}
void call( final IntegrationStage stage )
{
if( this.state != IntegrationStage.FAILED )
if( this.getState() != IntegrationStage.FAILED )
{
if( this.state.ordinal() > stage.ordinal() )
if( this.getState().ordinal() > stage.ordinal() )
{
return;
}
@@ -101,24 +101,24 @@ public final class IntegrationNode
this.classValue = this.getClass().getClassLoader().loadClass( this.name );
this.mod = (IIntegrationModule) this.classValue.getConstructor().newInstance();
final Field f = this.classValue.getField( "instance" );
f.set( this.classValue, this.instance = this.mod );
f.set( this.classValue, this.setInstance( this.mod ) );
}
else
{
throw new ModNotInstalled( this.modID );
}
this.state = IntegrationStage.INIT;
this.setState( IntegrationStage.INIT );
break;
case INIT:
this.mod.init();
this.state = IntegrationStage.POST_INIT;
this.setState( IntegrationStage.POST_INIT );
break;
case POST_INIT:
this.mod.postInit();
this.state = IntegrationStage.READY;
this.setState( IntegrationStage.READY );
break;
case FAILED:
@@ -130,13 +130,13 @@ public final class IntegrationNode
{
this.failedStage = stage;
this.exception = t;
this.state = IntegrationStage.FAILED;
this.setState( IntegrationStage.FAILED );
}
}
if( stage == IntegrationStage.POST_INIT )
{
if( this.state == IntegrationStage.FAILED )
if( this.getState() == IntegrationStage.FAILED )
{
AELog.info( this.displayName + " - Integration Disabled" );
if( !( this.exception instanceof ModNotInstalled ) )
@@ -150,4 +150,30 @@ public final class IntegrationNode
}
}
}
Object getInstance()
{
return this.instance;
}
private Object setInstance( final Object instance )
{
this.instance = instance;
return instance;
}
IntegrationType getShortName()
{
return this.shortName;
}
IntegrationStage getState()
{
return this.state;
}
private void setState( final IntegrationStage state )
{
this.state = state;
}
}
@@ -83,7 +83,7 @@ public enum IntegrationRegistry
builder.append( ", " );
}
final String integrationState = node.shortName + ":" + ( node.state == IntegrationStage.FAILED ? "OFF" : "ON" );
final String integrationState = node.getShortName() + ":" + ( node.getState() == IntegrationStage.FAILED ? "OFF" : "ON" );
builder.append( integrationState );
}
@@ -94,7 +94,7 @@ public enum IntegrationRegistry
{
for( final IntegrationNode node : this.modules )
{
if( node.shortName == name )
if( node.getShortName() == name )
{
return node.isActive();
}
@@ -107,9 +107,9 @@ public enum IntegrationRegistry
{
for( final IntegrationNode node : this.modules )
{
if( node.shortName == name && node.isActive() )
if( node.getShortName() == name && node.isActive() )
{
return node.instance;
return node.getInstance();
}
}
@@ -36,8 +36,8 @@ import appeng.integration.abstraction.IBuildCraftTransport;
public class BCPipeInventory implements IMEInventory<IAEItemStack>
{
final TileEntity te;
final ForgeDirection direction;
private final TileEntity te;
private final ForgeDirection direction;
public BCPipeInventory( final TileEntity te, final ForgeDirection direction )
{
@@ -54,7 +54,7 @@ public class BetterStorage implements IIntegrationModule, IBetterStorage
{
if( te instanceof ICrateStorage )
{
return new BSCrateStorageAdaptor( te, d );
return new BSCrateStorageAdaptor( te );
}
return null;
}
@@ -195,7 +195,7 @@ public class FMP implements IIntegrationModule, IPartFactory, IPartConverter, IF
final TMultiPart p = i.next();
if( p instanceof CableBusPart )
{
return ( (CableBusPart) p ).cb;
return ( (CableBusPart) p ).getCableBus();
}
}
}
@@ -177,7 +177,7 @@ public class NEIAEShapedRecipeHandler extends TemplateRecipeHandler
return RecipeInfo.getOverlayHandler( gui, "crafting2x2" );
}
public boolean isRecipe2x2( final int recipe )
private boolean isRecipe2x2( final int recipe )
{
for( final PositionedStack stack : this.getIngredientStacks( recipe ) )
{
@@ -195,11 +195,11 @@ public class NEIAEShapedRecipeHandler extends TemplateRecipeHandler
return NEIClientUtils.translate( "recipe.shaped" );
}
public class CachedShapedRecipe extends TemplateRecipeHandler.CachedRecipe
private class CachedShapedRecipe extends TemplateRecipeHandler.CachedRecipe
{
public final List<PositionedStack> ingredients;
public final PositionedStack result;
private final List<PositionedStack> ingredients;
private final PositionedStack result;
public CachedShapedRecipe( final ShapedRecipe recipe )
{
@@ -208,7 +208,7 @@ public class NEIAEShapedRecipeHandler extends TemplateRecipeHandler
this.setIngredients( recipe.getWidth(), recipe.getHeight(), recipe.getIngredients() );
}
public void setIngredients( final int width, final int height, final Object[] items )
private void setIngredients( final int width, final int height, final Object[] items )
{
final boolean useSingleItems = AEConfig.instance.disableColoredCableRecipesInNEI();
for( int x = 0; x < width; x++ )
@@ -251,7 +251,7 @@ public class NEIAEShapedRecipeHandler extends TemplateRecipeHandler
return this.getCycledIngredients( NEIAEShapedRecipeHandler.this.cycleticks / 20, this.ingredients );
}
public void computeVisuals()
private void computeVisuals()
{
for( final PositionedStack p : this.ingredients )
{
@@ -177,7 +177,7 @@ public class NEIAEShapelessRecipeHandler extends TemplateRecipeHandler
return RecipeInfo.getOverlayHandler( gui, "crafting2x2" );
}
public boolean isRecipe2x2( final int recipe )
private boolean isRecipe2x2( final int recipe )
{
for( final PositionedStack stack : this.getIngredientStacks( recipe ) )
{
@@ -195,11 +195,11 @@ public class NEIAEShapelessRecipeHandler extends TemplateRecipeHandler
return NEIClientUtils.translate( "recipe.shapeless" );
}
public class CachedShapelessRecipe extends TemplateRecipeHandler.CachedRecipe
private class CachedShapelessRecipe extends TemplateRecipeHandler.CachedRecipe
{
public final List<PositionedStack> ingredients;
public final PositionedStack result;
private final List<PositionedStack> ingredients;
private final PositionedStack result;
public CachedShapelessRecipe( final ShapelessRecipe recipe )
{
@@ -220,7 +220,7 @@ public class NEIAEShapelessRecipeHandler extends TemplateRecipeHandler
return this.getCycledIngredients( NEIAEShapelessRecipeHandler.this.cycleticks / 20, this.ingredients );
}
public void setIngredients( final Object[] items )
private void setIngredients( final Object[] items )
{
final boolean useSingleItems = AEConfig.instance.disableColoredCableRecipesInNEI();
for( int x = 0; x < 3; x++ )
@@ -251,7 +251,7 @@ public class NEIAEShapelessRecipeHandler extends TemplateRecipeHandler
}
}
public void computeVisuals()
private void computeVisuals()
{
for( final PositionedStack p : this.ingredients )
{
@@ -44,13 +44,8 @@ import appeng.util.Platform;
public class NEICraftingHandler implements IOverlayHandler
{
final int offsetX;
final int offsetY;
public NEICraftingHandler( final int x, final int y )
{
this.offsetX = x;
this.offsetY = y;
}
@Override
@@ -69,7 +64,7 @@ public class NEICraftingHandler implements IOverlayHandler
}
}
public void overlayRecipe( final GuiContainer gui, final List<PositionedStack> ingredients, final boolean shift )
private void overlayRecipe( final GuiContainer gui, final List<PositionedStack> ingredients, final boolean shift )
{
try
{
@@ -46,8 +46,8 @@ import appeng.items.parts.ItemFacade;
public class NEIFacadeRecipeHandler extends TemplateRecipeHandler
{
final ItemFacade facade;
final IItemDefinition anchorDefinition;
private final ItemFacade facade;
private final IItemDefinition anchorDefinition;
public NEIFacadeRecipeHandler()
{
@@ -176,7 +176,7 @@ public class NEIFacadeRecipeHandler extends TemplateRecipeHandler
return RecipeInfo.getOverlayHandler( gui, "crafting2x2" );
}
public boolean isRecipe2x2( final int recipe )
private boolean isRecipe2x2( final int recipe )
{
for( final PositionedStack stack : this.getIngredientStacks( recipe ) )
{
@@ -183,12 +183,12 @@ public class NEIGrinderRecipeHandler extends TemplateRecipeHandler
return GuiText.GrindStone.getLocal();
}
public class CachedGrindStoneRecipe extends TemplateRecipeHandler.CachedRecipe
private class CachedGrindStoneRecipe extends TemplateRecipeHandler.CachedRecipe
{
public final List<PositionedStack> ingredients;
public final PositionedStack result;
public String displayChance;
boolean hasOptional = false;
private final List<PositionedStack> ingredients;
private final PositionedStack result;
private String displayChance;
private boolean hasOptional = false;
public CachedGrindStoneRecipe( final IGrinderEntry recipe )
{
@@ -231,7 +231,7 @@ public class NEIGrinderRecipeHandler extends TemplateRecipeHandler
return this.getCycledIngredients( NEIGrinderRecipeHandler.this.cycleticks / 20, this.ingredients );
}
public void computeVisuals()
private void computeVisuals()
{
for( final PositionedStack p : this.ingredients )
{
@@ -160,11 +160,11 @@ public class NEIInscriberRecipeHandler extends TemplateRecipeHandler
return GuiText.Inscriber.getLocal();
}
public class CachedInscriberRecipe extends TemplateRecipeHandler.CachedRecipe
private class CachedInscriberRecipe extends TemplateRecipeHandler.CachedRecipe
{
public final List<PositionedStack> ingredients;
public final PositionedStack result;
private final List<PositionedStack> ingredients;
private final PositionedStack result;
public CachedInscriberRecipe( final IInscriberRecipe recipe )
{
@@ -196,7 +196,7 @@ public class NEIInscriberRecipeHandler extends TemplateRecipeHandler
return this.getCycledIngredients( NEIInscriberRecipeHandler.this.cycleticks / 20, this.ingredients );
}
public void computeVisuals()
private void computeVisuals()
{
for( final PositionedStack p : this.ingredients )
{
@@ -181,7 +181,7 @@ public class NEIWorldCraftingHandler implements ICraftingHandler, IUsageHandler
return this;
}
public NEIWorldCraftingHandler newInstance()
private NEIWorldCraftingHandler newInstance()
{
try
{
@@ -37,8 +37,8 @@ public class TerminalCraftingSlotFinder implements IStackPositioner
{
if( ps != null )
{
ps.relx += GuiMEMonitorable.CraftingGridOffsetX;
ps.rely += GuiMEMonitorable.CraftingGridOffsetY;
ps.relx += GuiMEMonitorable.craftingGridOffsetX;
ps.rely += GuiMEMonitorable.craftingGridOffsetY;
}
}
return a;
@@ -21,7 +21,6 @@ package appeng.integration.modules.helpers;
import net.mcft.copy.betterstorage.api.crate.ICrateStorage;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.config.Actionable;
import appeng.api.networking.security.BaseActionSource;
@@ -35,12 +34,10 @@ import appeng.util.item.AEItemStack;
public class BSCrate implements IMEInventory<IAEItemStack>
{
private final ICrateStorage crateStorage;
private final ForgeDirection side;
public BSCrate( final Object object, final ForgeDirection d )
public BSCrate( final Object object )
{
this.crateStorage = (ICrateStorage) object;
this.side = d;
}
@Override
@@ -43,7 +43,7 @@ public class BSCrateHandler implements IExternalStorageHandler
{
if( channel == StorageChannel.ITEMS )
{
return new BSCrate( te, ForgeDirection.UNKNOWN );
return new BSCrate( te );
}
return null;
}
@@ -23,7 +23,6 @@ import java.util.Iterator;
import net.mcft.copy.betterstorage.api.crate.ICrateStorage;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.config.FuzzyMode;
import appeng.util.InventoryAdaptor;
@@ -36,13 +35,11 @@ import appeng.util.iterators.StackToSlotIterator;
public class BSCrateStorageAdaptor extends InventoryAdaptor
{
final ICrateStorage cs;
final ForgeDirection side;
private final ICrateStorage cs;
public BSCrateStorageAdaptor( final Object te, final ForgeDirection d )
public BSCrateStorageAdaptor( final Object te )
{
this.cs = (ICrateStorage) te;
this.side = d;
}
@Override
@@ -27,10 +27,15 @@ import cpw.mods.fml.common.eventhandler.Event;
public class FMPPacketEvent extends Event
{
public final EntityPlayerMP sender;
private final EntityPlayerMP sender;
public FMPPacketEvent( final EntityPlayerMP sender )
{
this.sender = sender;
}
public EntityPlayerMP getSender()
{
return this.sender;
}
}
@@ -35,7 +35,7 @@ import appeng.util.item.AEItemStack;
public class FactorizationBarrel implements IMEInventory<IAEItemStack>
{
final IFZ fProxy;
private final IFZ fProxy;
private final TileEntity te;
public FactorizationBarrel( final IFZ proxy, final TileEntity tile )
@@ -102,12 +102,12 @@ public class FactorizationBarrel implements IMEInventory<IAEItemStack>
return input;
}
public long remainingItemTypes()
private long remainingItemTypes()
{
return this.fProxy.barrelGetItem( this.te ) == null ? 1 : 0;
}
public boolean containsItemType( final IAEItemStack i, final boolean acceptEmpty )
private boolean containsItemType( final IAEItemStack i, final boolean acceptEmpty )
{
final ItemStack currentItem = this.fProxy.barrelGetItem( this.te );
@@ -120,7 +120,7 @@ public class FactorizationBarrel implements IMEInventory<IAEItemStack>
return i.equals( currentItem );
}
public long storedItemCount()
private long storedItemCount()
{
return this.fProxy.barrelGetItemCount( this.te );
}
@@ -36,12 +36,10 @@ import appeng.util.item.AEItemStack;
public class MinefactoryReloadedDeepStorageUnit implements IMEInventory<IAEItemStack>
{
final IDeepStorageUnit dsu;
final TileEntity te;
private final IDeepStorageUnit dsu;
public MinefactoryReloadedDeepStorageUnit( final TileEntity ta )
{
this.te = ta;
this.dsu = (IDeepStorageUnit) ta;
}