Code cleanup

Added missing this, annotations, etc.
This commit is contained in:
yueh
2018-08-30 20:33:08 +02:00
parent fed12cb99f
commit a2091d10fe
77 changed files with 227 additions and 270 deletions
+15 -34
View File
@@ -92,26 +92,11 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
{
private static final ExecutorService CRAFTING_POOL;
private static final Comparator<ICraftingPatternDetails> COMPARATOR = new Comparator<ICraftingPatternDetails>()
{
@Override
public int compare( final ICraftingPatternDetails firstDetail, final ICraftingPatternDetails nextDetail )
{
return nextDetail.getPriority() - firstDetail.getPriority();
}
};
private static final Comparator<ICraftingPatternDetails> COMPARATOR = ( firstDetail, nextDetail ) -> nextDetail.getPriority() - firstDetail.getPriority();
static
{
final ThreadFactory factory = new ThreadFactory()
{
@Override
public Thread newThread( final Runnable ar )
{
return new Thread( ar, "AE Crafting Calculator" );
}
};
final ThreadFactory factory = ar -> new Thread( ar, "AE Crafting Calculator" );
CRAFTING_POOL = Executors.newCachedThreadPool( factory );
}
@@ -542,28 +527,24 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
}
}
Collections.sort( validCpusClusters, new Comparator<CraftingCPUCluster>()
Collections.sort( validCpusClusters, ( firstCluster, nextCluster ) ->
{
@Override
public int compare( final CraftingCPUCluster firstCluster, final CraftingCPUCluster nextCluster )
if( prioritizePower )
{
if( prioritizePower )
final int comparison1 = Long.compare( nextCluster.getCoProcessors(), firstCluster.getCoProcessors() );
if( comparison1 != 0 )
{
final int comparison = Long.compare( nextCluster.getCoProcessors(), firstCluster.getCoProcessors() );
if( comparison != 0 )
{
return comparison;
}
return Long.compare( nextCluster.getAvailableStorage(), firstCluster.getAvailableStorage() );
return comparison1;
}
final int comparison = Long.compare( firstCluster.getCoProcessors(), nextCluster.getCoProcessors() );
if( comparison != 0 )
{
return comparison;
}
return Long.compare( firstCluster.getAvailableStorage(), nextCluster.getAvailableStorage() );
return Long.compare( nextCluster.getAvailableStorage(), firstCluster.getAvailableStorage() );
}
final int comparison2 = Long.compare( firstCluster.getCoProcessors(), nextCluster.getCoProcessors() );
if( comparison2 != 0 )
{
return comparison2;
}
return Long.compare( firstCluster.getAvailableStorage(), nextCluster.getAvailableStorage() );
} );
if( !validCpusClusters.isEmpty() )
+1 -1
View File
@@ -487,7 +487,7 @@ public class EnergyGridCache implements IEnergyGrid
{
if( machine instanceof IEnergyGridProvider )
{
this.energyGridProviders.remove( (IEnergyGridProvider) machine );
this.energyGridProviders.remove( machine );
}
// idle draw.
@@ -97,7 +97,7 @@ public abstract class AbstractCellInventory<T extends IAEStack<T>> implements IC
{
if( this.cellItems == null )
{
this.cellItems = getChannel().createList();
this.cellItems = this.getChannel().createList();
this.loadCellItems();
}
@@ -186,7 +186,7 @@ public abstract class AbstractCellInventory<T extends IAEStack<T>> implements IC
{
if( this.cellItems == null )
{
this.cellItems = getChannel().createList();
this.cellItems = this.getChannel().createList();
}
this.cellItems.resetStatus(); // clears totals and stuff.
@@ -299,14 +299,14 @@ public abstract class AbstractCellInventory<T extends IAEStack<T>> implements IC
@Override
public long getUsedBytes()
{
final long bytesForItemCount = ( this.getStoredItemCount() + this.getUnusedItemCount() ) / itemsPerByte;
final long bytesForItemCount = ( this.getStoredItemCount() + this.getUnusedItemCount() ) / this.itemsPerByte;
return this.getStoredItemTypes() * this.getBytesPerType() + bytesForItemCount;
}
@Override
public long getRemainingItemCount()
{
final long remaining = this.getFreeBytes() * itemsPerByte + this.getUnusedItemCount();
final long remaining = this.getFreeBytes() * this.itemsPerByte + this.getUnusedItemCount();
return remaining > 0 ? remaining : 0;
}
@@ -320,7 +320,7 @@ public abstract class AbstractCellInventory<T extends IAEStack<T>> implements IC
return 0;
}
return itemsPerByte - div;
return this.itemsPerByte - div;
}
@Override
@@ -183,7 +183,7 @@ public class BasicCellInventory<T extends IAEStack<T>> extends AbstractCellInven
if( this.canHoldNewItem() ) // room for new type, and for at least one item!
{
final int remainingItemCount = (int) this.getRemainingItemCount() - this.getBytesPerType() * itemsPerByte;
final int remainingItemCount = (int) this.getRemainingItemCount() - this.getBytesPerType() * this.itemsPerByte;
if( remainingItemCount > 0 )
{
if( input.getStackSize() > remainingItemCount )
@@ -267,7 +267,7 @@ public class BasicCellInventory<T extends IAEStack<T>> extends AbstractCellInven
final T t;
try
{
t = getChannel().createFromNBT( compoundTag );
t = this.getChannel().createFromNBT( compoundTag );
if( t == null )
{
AELog.warn( "Removing item " + compoundTag + " from storage cell because the associated item type couldn't be found." );
@@ -64,7 +64,7 @@ public class ItemWatcher implements IStackWatcher
@Override
public boolean remove( final IAEStack o )
{
return this.myInterests.remove( o ) && this.gsc.getInterestManager().remove( (IAEStack) o, this );
return this.myInterests.remove( o ) && this.gsc.getInterestManager().remove( o, this );
}
@Override