pick 97420a31d The big reformat of 2020
This commit is contained in:
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.util.item;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
@@ -28,173 +27,145 @@ import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
|
||||
abstract class AbstractItemList implements IItemList<IAEItemStack> {
|
||||
|
||||
abstract class AbstractItemList implements IItemList<IAEItemStack>
|
||||
{
|
||||
@Override
|
||||
public void add(final IAEItemStack option) {
|
||||
if (option == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add( final IAEItemStack option )
|
||||
{
|
||||
if( option == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
final IAEItemStack st = this.getRecords().get(((AEItemStack) option).getSharedStack());
|
||||
|
||||
final IAEItemStack st = this.getRecords().get( ( (AEItemStack) option ).getSharedStack() );
|
||||
if (st != null) {
|
||||
st.add(option);
|
||||
return;
|
||||
}
|
||||
|
||||
if( st != null )
|
||||
{
|
||||
st.add( option );
|
||||
return;
|
||||
}
|
||||
final IAEItemStack opt = option.copy();
|
||||
|
||||
final IAEItemStack opt = option.copy();
|
||||
this.putItemRecord(opt);
|
||||
}
|
||||
|
||||
this.putItemRecord( opt );
|
||||
}
|
||||
@Override
|
||||
public IAEItemStack findPrecise(final IAEItemStack itemStack) {
|
||||
if (itemStack == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack findPrecise( final IAEItemStack itemStack )
|
||||
{
|
||||
if( itemStack == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return this.getRecords().get(((AEItemStack) itemStack).getSharedStack());
|
||||
}
|
||||
|
||||
return this.getRecords().get( ( (AEItemStack) itemStack ).getSharedStack() );
|
||||
}
|
||||
@Override
|
||||
public Collection<IAEItemStack> findFuzzy(final IAEItemStack filter, final FuzzyMode fuzzy) {
|
||||
if (filter == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<IAEItemStack> findFuzzy( final IAEItemStack filter, final FuzzyMode fuzzy )
|
||||
{
|
||||
if( filter == null )
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return this.getRecords().values();
|
||||
}
|
||||
|
||||
return this.getRecords().values();
|
||||
}
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return !this.iterator().hasNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return !this.iterator().hasNext();
|
||||
}
|
||||
@Override
|
||||
public void addStorage(final IAEItemStack option) {
|
||||
if (option == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addStorage( final IAEItemStack option )
|
||||
{
|
||||
if( option == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
final IAEItemStack st = this.getRecords().get(((AEItemStack) option).getSharedStack());
|
||||
|
||||
final IAEItemStack st = this.getRecords().get( ( (AEItemStack) option ).getSharedStack() );
|
||||
if (st != null) {
|
||||
st.incStackSize(option.getStackSize());
|
||||
return;
|
||||
}
|
||||
|
||||
if( st != null )
|
||||
{
|
||||
st.incStackSize( option.getStackSize() );
|
||||
return;
|
||||
}
|
||||
final IAEItemStack opt = option.copy();
|
||||
|
||||
final IAEItemStack opt = option.copy();
|
||||
this.putItemRecord(opt);
|
||||
}
|
||||
|
||||
this.putItemRecord( opt );
|
||||
}
|
||||
@Override
|
||||
public void addCrafting(final IAEItemStack option) {
|
||||
if (option == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCrafting( final IAEItemStack option )
|
||||
{
|
||||
if( option == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
final IAEItemStack st = this.getRecords().get(((AEItemStack) option).getSharedStack());
|
||||
|
||||
final IAEItemStack st = this.getRecords().get( ( (AEItemStack) option ).getSharedStack() );
|
||||
if (st != null) {
|
||||
st.setCraftable(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if( st != null )
|
||||
{
|
||||
st.setCraftable( true );
|
||||
return;
|
||||
}
|
||||
final IAEItemStack opt = option.copy();
|
||||
opt.setStackSize(0);
|
||||
opt.setCraftable(true);
|
||||
|
||||
final IAEItemStack opt = option.copy();
|
||||
opt.setStackSize( 0 );
|
||||
opt.setCraftable( true );
|
||||
this.putItemRecord(opt);
|
||||
}
|
||||
|
||||
this.putItemRecord( opt );
|
||||
}
|
||||
@Override
|
||||
public void addRequestable(final IAEItemStack option) {
|
||||
if (option == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRequestable( final IAEItemStack option )
|
||||
{
|
||||
if( option == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
final IAEItemStack st = this.getRecords().get(((AEItemStack) option).getSharedStack());
|
||||
|
||||
final IAEItemStack st = this.getRecords().get( ( (AEItemStack) option ).getSharedStack() );
|
||||
if (st != null) {
|
||||
st.setCountRequestable(st.getCountRequestable() + option.getCountRequestable());
|
||||
return;
|
||||
}
|
||||
|
||||
if( st != null )
|
||||
{
|
||||
st.setCountRequestable( st.getCountRequestable() + option.getCountRequestable() );
|
||||
return;
|
||||
}
|
||||
final IAEItemStack opt = option.copy();
|
||||
opt.setStackSize(0);
|
||||
opt.setCraftable(false);
|
||||
opt.setCountRequestable(option.getCountRequestable());
|
||||
|
||||
final IAEItemStack opt = option.copy();
|
||||
opt.setStackSize( 0 );
|
||||
opt.setCraftable( false );
|
||||
opt.setCountRequestable( option.getCountRequestable() );
|
||||
this.putItemRecord(opt);
|
||||
}
|
||||
|
||||
this.putItemRecord( opt );
|
||||
}
|
||||
@Override
|
||||
public IAEItemStack getFirstItem() {
|
||||
for (final IAEItemStack stackType : this) {
|
||||
return stackType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack getFirstItem()
|
||||
{
|
||||
for( final IAEItemStack stackType : this )
|
||||
{
|
||||
return stackType;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public int size() {
|
||||
int size = 0;
|
||||
for (IAEItemStack entry : getRecords().values()) {
|
||||
if (entry.isMeaningful()) {
|
||||
size++;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size()
|
||||
{
|
||||
int size = 0;
|
||||
for( IAEItemStack entry : getRecords().values() )
|
||||
{
|
||||
if( entry.isMeaningful() )
|
||||
{
|
||||
size++;
|
||||
}
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
@Override
|
||||
public Iterator<IAEItemStack> iterator() {
|
||||
return new MeaningfulItemIterator<>(this.getRecords().values());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<IAEItemStack> iterator()
|
||||
{
|
||||
return new MeaningfulItemIterator<>( this.getRecords().values() );
|
||||
}
|
||||
@Override
|
||||
public void resetStatus() {
|
||||
for (final IAEItemStack i : this) {
|
||||
i.reset();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetStatus()
|
||||
{
|
||||
for( final IAEItemStack i : this )
|
||||
{
|
||||
i.reset();
|
||||
}
|
||||
}
|
||||
abstract Map<AESharedItemStack, IAEItemStack> getRecords();
|
||||
|
||||
abstract Map<AESharedItemStack, IAEItemStack> getRecords();
|
||||
|
||||
private IAEItemStack putItemRecord( final IAEItemStack itemStack )
|
||||
{
|
||||
return this.getRecords().put( ( (AEItemStack) itemStack ).getSharedStack(), itemStack );
|
||||
}
|
||||
private IAEItemStack putItemRecord(final IAEItemStack itemStack) {
|
||||
return this.getRecords().put(((AEItemStack) itemStack).getSharedStack(), itemStack);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user