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:
@@ -26,18 +26,18 @@ import appeng.util.ItemSorters;
|
||||
public class EnergyThreshold implements Comparable<EnergyThreshold>
|
||||
{
|
||||
|
||||
public final double Limit;
|
||||
public final IEnergyWatcher watcher;
|
||||
final int hash;
|
||||
private final double Limit;
|
||||
private final IEnergyWatcher watcher;
|
||||
private final int hash;
|
||||
|
||||
public EnergyThreshold( final double lim, final IEnergyWatcher wat )
|
||||
{
|
||||
this.Limit = lim;
|
||||
this.watcher = wat;
|
||||
|
||||
if( this.watcher != null )
|
||||
if( this.getWatcher() != null )
|
||||
{
|
||||
this.hash = this.watcher.hashCode() ^ ( (Double) lim ).hashCode();
|
||||
this.hash = this.getWatcher().hashCode() ^ ( (Double) lim ).hashCode();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -54,6 +54,16 @@ public class EnergyThreshold implements Comparable<EnergyThreshold>
|
||||
@Override
|
||||
public int compareTo( final EnergyThreshold o )
|
||||
{
|
||||
return ItemSorters.compareDouble( this.Limit, o.Limit );
|
||||
return ItemSorters.compareDouble( this.getLimit(), o.getLimit() );
|
||||
}
|
||||
|
||||
double getLimit()
|
||||
{
|
||||
return this.Limit;
|
||||
}
|
||||
|
||||
public IEnergyWatcher getWatcher()
|
||||
{
|
||||
return this.watcher;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,9 +34,9 @@ import appeng.me.cache.EnergyGridCache;
|
||||
public class EnergyWatcher implements IEnergyWatcher
|
||||
{
|
||||
|
||||
final EnergyGridCache gsc;
|
||||
final IEnergyWatcherHost myObject;
|
||||
final HashSet<EnergyThreshold> myInterests = new HashSet<EnergyThreshold>();
|
||||
private final EnergyGridCache gsc;
|
||||
private final IEnergyWatcherHost myObject;
|
||||
private final HashSet<EnergyThreshold> myInterests = new HashSet<EnergyThreshold>();
|
||||
|
||||
public EnergyWatcher( final EnergyGridCache cache, final IEnergyWatcherHost host )
|
||||
{
|
||||
@@ -99,14 +99,14 @@ public class EnergyWatcher implements IEnergyWatcher
|
||||
}
|
||||
|
||||
final EnergyThreshold eh = new EnergyThreshold( e, this );
|
||||
return this.gsc.interests.add( eh ) && this.myInterests.add( eh );
|
||||
return this.gsc.getInterests().add( eh ) && this.myInterests.add( eh );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove( final Object o )
|
||||
{
|
||||
final EnergyThreshold eh = new EnergyThreshold( (Double) o, this );
|
||||
return this.myInterests.remove( eh ) && this.gsc.interests.remove( eh );
|
||||
return this.myInterests.remove( eh ) && this.gsc.getInterests().remove( eh );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -163,17 +163,17 @@ public class EnergyWatcher implements IEnergyWatcher
|
||||
final Iterator<EnergyThreshold> i = this.myInterests.iterator();
|
||||
while( i.hasNext() )
|
||||
{
|
||||
this.gsc.interests.remove( i.next() );
|
||||
this.gsc.getInterests().remove( i.next() );
|
||||
i.remove();
|
||||
}
|
||||
}
|
||||
|
||||
class EnergyWatcherIterator implements Iterator<Double>
|
||||
private class EnergyWatcherIterator implements Iterator<Double>
|
||||
{
|
||||
|
||||
final EnergyWatcher watcher;
|
||||
final Iterator<EnergyThreshold> interestIterator;
|
||||
EnergyThreshold myLast;
|
||||
private final EnergyWatcher watcher;
|
||||
private final Iterator<EnergyThreshold> interestIterator;
|
||||
private EnergyThreshold myLast;
|
||||
|
||||
public EnergyWatcherIterator( final EnergyWatcher parent, final Iterator<EnergyThreshold> i )
|
||||
{
|
||||
@@ -191,13 +191,13 @@ public class EnergyWatcher implements IEnergyWatcher
|
||||
public Double next()
|
||||
{
|
||||
this.myLast = this.interestIterator.next();
|
||||
return this.myLast.Limit;
|
||||
return this.myLast.getLimit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove()
|
||||
{
|
||||
EnergyWatcher.this.gsc.interests.remove( this.myLast );
|
||||
EnergyWatcher.this.gsc.getInterests().remove( this.myLast );
|
||||
this.interestIterator.remove();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user