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
+47 -27
View File
@@ -64,9 +64,9 @@ public class GridNode implements IGridNode, IPathItem
private final List<IGridConnection> connections = new LinkedList<IGridConnection>();
private final IGridBlock gridProxy;
// old power draw, used to diff
public double previousDraw = 0.0;
public long lastSecurityKey = -1;
public int playerID = -1;
private double previousDraw = 0.0;
private long lastSecurityKey = -1;
private int playerID = -1;
private GridStorage myStorage = null;
private Grid myGrid;
private Object visitorIterationNumber = null;
@@ -80,12 +80,12 @@ public class GridNode implements IGridNode, IPathItem
this.gridProxy = what;
}
public IGridBlock getGridProxy()
IGridBlock getGridProxy()
{
return this.gridProxy;
}
public Grid getMyGrid()
Grid getMyGrid()
{
return this.myGrid;
}
@@ -95,12 +95,12 @@ public class GridNode implements IGridNode, IPathItem
return this.lastUsedChannels;
}
public Class<? extends IGridHost> getMachineClass()
Class<? extends IGridHost> getMachineClass()
{
return this.getMachine().getClass();
}
public void addConnection( final IGridConnection gridConnection )
void addConnection( final IGridConnection gridConnection )
{
this.connections.add( gridConnection );
if( gridConnection.hasDirection() )
@@ -113,7 +113,7 @@ public class GridNode implements IGridNode, IPathItem
Collections.sort( this.connections, new ConnectionComparator( gn ) );
}
public void removeConnection( final IGridConnection gridConnection )
void removeConnection( final IGridConnection gridConnection )
{
this.connections.remove( gridConnection );
if( gridConnection.hasDirection() )
@@ -122,7 +122,7 @@ public class GridNode implements IGridNode, IPathItem
}
}
public boolean hasConnection( final IGridNode otherSide )
boolean hasConnection( final IGridNode otherSide )
{
for( final IGridConnection gc : this.connections )
{
@@ -134,11 +134,11 @@ public class GridNode implements IGridNode, IPathItem
return false;
}
public void validateGrid()
void validateGrid()
{
final GridSplitDetector gsd = new GridSplitDetector( this.getInternalGrid().getPivot() );
this.beginVisit( gsd );
if( !gsd.pivotFound )
if( !gsd.isPivotFound() )
{
final IGridVisitor gp = new GridPropagator( new Grid( this ) );
this.beginVisit( gp );
@@ -231,7 +231,7 @@ public class GridNode implements IGridNode, IPathItem
return this.myGrid;
}
public void setGrid( final Grid grid )
void setGrid( final Grid grid )
{
if( this.myGrid == grid )
{
@@ -329,7 +329,7 @@ public class GridNode implements IGridNode, IPathItem
{
final NBTTagCompound node = nodeData.getCompoundTag( name );
this.playerID = node.getInteger( "p" );
this.lastSecurityKey = node.getLong( "k" );
this.setLastSecurityKey( node.getLong( "k" ) );
final long storageID = node.getLong( "g" );
final GridStorage gridStorage = WorldData.instance().storageData().getGridStorage( storageID );
@@ -349,7 +349,7 @@ public class GridNode implements IGridNode, IPathItem
final NBTTagCompound node = new NBTTagCompound();
node.setInteger( "p", this.playerID );
node.setLong( "k", this.lastSecurityKey );
node.setLong( "k", this.getLastSecurityKey() );
node.setLong( "g", this.myStorage.getID() );
nodeData.setTag( name, node );
@@ -387,12 +387,12 @@ public class GridNode implements IGridNode, IPathItem
}
}
public int getUsedChannels()
private int getUsedChannels()
{
return this.usedChannels;
}
public void FindConnections()
private void FindConnections()
{
if( !this.gridProxy.isWorldAccessible() )
{
@@ -445,7 +445,7 @@ public class GridNode implements IGridNode, IPathItem
}
else if( isValidConnection )
{
if( node.lastSecurityKey != -1 )
if( node.getLastSecurityKey() != -1 )
{
newSecurityConnections.add( f );
}
@@ -495,7 +495,7 @@ public class GridNode implements IGridNode, IPathItem
private IGridHost findGridHost( final World world, final int x, final int y, final int z )
{
final BlockPos pos = new BlockPos(x,y,z);
final BlockPos pos = new BlockPos( x, y, z );
if( world.isBlockLoaded( pos ) )
{
final TileEntity te = world.getTileEntity( pos );
@@ -507,7 +507,7 @@ public class GridNode implements IGridNode, IPathItem
return null;
}
public boolean canConnect( final GridNode from, final AEPartLocation dir )
private boolean canConnect( final GridNode from, final AEPartLocation dir )
{
if( !this.isValidDirection( dir ) )
{
@@ -527,7 +527,7 @@ public class GridNode implements IGridNode, IPathItem
return ( this.compressedData & ( 1 << ( 8 + dir.ordinal() ) ) ) > 0;
}
public AEColor getColor()
private AEColor getColor()
{
return AEColor.values()[( this.compressedData >> 3 ) & 0x1F];
}
@@ -541,9 +541,9 @@ public class GridNode implements IGridNode, IPathItem
final GridNode gn = (GridNode) gc.getOtherSide( this );
final GridConnection gcc = (GridConnection) gc;
if( gcc.visitorIterationNumber != tracker )
if( gcc.getVisitorIterationNumber() != tracker )
{
gcc.visitorIterationNumber = tracker;
gcc.setVisitorIterationNumber( tracker );
nextConnections.add( gc );
}
@@ -579,12 +579,12 @@ public class GridNode implements IGridNode, IPathItem
}
}
public GridStorage getGridStorage()
GridStorage getGridStorage()
{
return this.myStorage;
}
public void setGridStorage( final GridStorage s )
void setGridStorage( final GridStorage s )
{
this.myStorage = s;
this.usedChannels = 0;
@@ -624,7 +624,7 @@ public class GridNode implements IGridNode, IPathItem
return this.getUsedChannels() < this.getMaxChannels();
}
public int getMaxChannels()
private int getMaxChannels()
{
return CHANNEL_COUNT[this.compressedData & 0x03];
}
@@ -666,11 +666,31 @@ public class GridNode implements IGridNode, IPathItem
}
}
public int getLastUsedChannels()
private int getLastUsedChannels()
{
return this.lastUsedChannels;
}
public long getLastSecurityKey()
{
return this.lastSecurityKey;
}
public void setLastSecurityKey( final long lastSecurityKey )
{
this.lastSecurityKey = lastSecurityKey;
}
public double getPreviousDraw()
{
return this.previousDraw;
}
public void setPreviousDraw( final double previousDraw )
{
this.previousDraw = previousDraw;
}
private static class MachineSecurityBreak implements IWorldCallable<Void>
{
private final GridNode node;
@@ -681,7 +701,7 @@ public class GridNode implements IGridNode, IPathItem
}
@Override
public Void call( final World world) throws Exception
public Void call( final World world ) throws Exception
{
this.node.getMachine().securityBreak();