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
@@ -25,10 +25,20 @@ import appeng.api.networking.IGridConnection;
public class ConnectionWrapper
{
public IGridConnection connection;
private IGridConnection connection;
public ConnectionWrapper( final IGridConnection gc )
{
this.connection = gc;
this.setConnection( gc );
}
public IGridConnection getConnection()
{
return this.connection;
}
public void setConnection( final IGridConnection connection )
{
this.connection = connection;
}
}
+32 -7
View File
@@ -31,10 +31,10 @@ import appeng.util.IWorldCallable;
public class Connections implements IWorldCallable<Void>
{
public final HashMap<IGridNode, TunnelConnection> connections = new HashMap<IGridNode, TunnelConnection>();
private final HashMap<IGridNode, TunnelConnection> connections = new HashMap<IGridNode, TunnelConnection>();
private final PartP2PTunnelME me;
public boolean create = false;
public boolean destroy = false;
private boolean create = false;
private boolean destroy = false;
public Connections( final PartP2PTunnelME o )
{
@@ -51,13 +51,38 @@ public class Connections implements IWorldCallable<Void>
public void markDestroy()
{
this.create = false;
this.destroy = true;
this.setCreate( false );
this.setDestroy( true );
}
public void markCreate()
{
this.create = true;
this.destroy = false;
this.setCreate( true );
this.setDestroy( false );
}
public HashMap<IGridNode, TunnelConnection> getConnections()
{
return this.connections;
}
public boolean isCreate()
{
return this.create;
}
private void setCreate( final boolean create )
{
this.create = create;
}
public boolean isDestroy()
{
return this.destroy;
}
private void setDestroy( final boolean destroy )
{
this.destroy = destroy;
}
}
+60 -25
View File
@@ -33,23 +33,23 @@ import appeng.parts.AEBasePart;
public class TickTracker implements Comparable<TickTracker>
{
public final TickingRequest request;
public final IGridTickable gt;
public final IGridNode node;
public final TickManagerCache host;
private final TickingRequest request;
private final IGridTickable gt;
private final IGridNode node;
private final TickManagerCache host;
public final long LastFiveTicksTime = 0;
private final long LastFiveTicksTime = 0;
public long lastTick;
public int current_rate;
private long lastTick;
private int currentRate;
public TickTracker( final TickingRequest req, final IGridNode node, final IGridTickable gt, final long currentTick, final TickManagerCache tickManagerCache )
{
this.request = req;
this.gt = gt;
this.node = node;
this.current_rate = ( req.minTickRate + req.maxTickRate ) / 2;
this.lastTick = currentTick;
this.setCurrentRate( ( req.minTickRate + req.maxTickRate ) / 2 );
this.setLastTick( currentTick );
this.host = tickManagerCache;
}
@@ -60,46 +60,81 @@ public class TickTracker implements Comparable<TickTracker>
public void setRate( final int rate )
{
this.current_rate = rate;
this.setCurrentRate( rate );
if( this.current_rate < this.request.minTickRate )
if( this.getCurrentRate() < this.getRequest().minTickRate )
{
this.current_rate = this.request.minTickRate;
this.setCurrentRate( this.getRequest().minTickRate );
}
if( this.current_rate > this.request.maxTickRate )
if( this.getCurrentRate() > this.getRequest().maxTickRate )
{
this.current_rate = this.request.maxTickRate;
this.setCurrentRate( this.getRequest().maxTickRate );
}
}
@Override
public int compareTo( @Nonnull final TickTracker t )
{
final int nextTick = (int) ( ( this.lastTick - this.host.getCurrentTick() ) + this.current_rate );
final int ts_nextTick = (int) ( ( t.lastTick - this.host.getCurrentTick() ) + t.current_rate );
final int nextTick = (int) ( ( this.getLastTick() - this.host.getCurrentTick() ) + this.getCurrentRate() );
final int ts_nextTick = (int) ( ( t.getLastTick() - this.host.getCurrentTick() ) + t.getCurrentRate() );
return nextTick - ts_nextTick;
}
public void addEntityCrashInfo( final CrashReportCategory crashreportcategory )
{
if( this.gt instanceof AEBasePart )
if( this.getGridTickable() instanceof AEBasePart )
{
final AEBasePart part = (AEBasePart) this.gt;
final AEBasePart part = (AEBasePart) this.getGridTickable();
part.addEntityCrashInfo( crashreportcategory );
}
crashreportcategory.addCrashSection( "CurrentTickRate", this.current_rate );
crashreportcategory.addCrashSection( "MinTickRate", this.request.minTickRate );
crashreportcategory.addCrashSection( "MaxTickRate", this.request.maxTickRate );
crashreportcategory.addCrashSection( "MachineType", this.gt.getClass().getName() );
crashreportcategory.addCrashSection( "GridBlockType", this.node.getGridBlock().getClass().getName() );
crashreportcategory.addCrashSection( "ConnectedSides", this.node.getConnectedSides() );
crashreportcategory.addCrashSection( "CurrentTickRate", this.getCurrentRate() );
crashreportcategory.addCrashSection( "MinTickRate", this.getRequest().minTickRate );
crashreportcategory.addCrashSection( "MaxTickRate", this.getRequest().maxTickRate );
crashreportcategory.addCrashSection( "MachineType", this.getGridTickable().getClass().getName() );
crashreportcategory.addCrashSection( "GridBlockType", this.getNode().getGridBlock().getClass().getName() );
crashreportcategory.addCrashSection( "ConnectedSides", this.getNode().getConnectedSides() );
final DimensionalCoord dc = this.node.getGridBlock().getLocation();
final DimensionalCoord dc = this.getNode().getGridBlock().getLocation();
if( dc != null )
{
crashreportcategory.addCrashSection( "Location", dc );
}
}
public int getCurrentRate()
{
return this.currentRate;
}
public void setCurrentRate( final int currentRate )
{
this.currentRate = currentRate;
}
public long getLastTick()
{
return this.lastTick;
}
public void setLastTick( final long lastTick )
{
this.lastTick = lastTick;
}
public IGridNode getNode()
{
return this.node;
}
public IGridTickable getGridTickable()
{
return this.gt;
}
public TickingRequest getRequest()
{
return this.request;
}
}
@@ -29,8 +29,8 @@ import appeng.util.iterators.NullIterator;
public class TunnelCollection<T extends PartP2PTunnel> implements Iterable<T>
{
final Class clz;
Collection<T> tunnelSources;
private final Class clz;
private Collection<T> tunnelSources;
public TunnelCollection( final Collection<T> src, final Class c )
{
+12 -2
View File
@@ -26,12 +26,22 @@ import appeng.parts.p2p.PartP2PTunnelME;
public class TunnelConnection
{
public final PartP2PTunnelME tunnel;
public final IGridConnection c;
private final PartP2PTunnelME tunnel;
private final IGridConnection c;
public TunnelConnection( final PartP2PTunnelME t, final IGridConnection con )
{
this.tunnel = t;
this.c = con;
}
public IGridConnection getConnection()
{
return this.c;
}
public PartP2PTunnelME getTunnel()
{
return this.tunnel;
}
}
+3 -3
View File
@@ -28,9 +28,9 @@ import appeng.parts.p2p.PartP2PTunnel;
public class TunnelIterator<T extends PartP2PTunnel> implements Iterator<T>
{
final Iterator<T> wrapped;
final Class targetType;
T Next;
private final Iterator<T> wrapped;
private final Class targetType;
private T Next;
public TunnelIterator( final Collection<T> tunnelSources, final Class clz )
{