Applied-Energistics-2-tiler.../me/cache/helpers/TunnelCollection.java
AlgorithmX2 e1d3fdb8d7 Fixed Bug: #0641 - Redstone P2P Crash
Fixed an issue where tunnels would de-register if linked a certain way.
2014-07-14 23:47:07 -05:00

47 lines
887 B
Java

package appeng.me.cache.helpers;
import java.util.Collection;
import java.util.Iterator;
import appeng.parts.p2p.PartP2PTunnel;
import appeng.util.iterators.NullIterator;
public class TunnelCollection<T extends PartP2PTunnel> implements Iterable<T>
{
final Class clz;
Collection<T> tunnelsource;
public TunnelCollection(Collection<T> src, Class c) {
tunnelsource = src;
clz = c;
}
@Override
public Iterator<T> iterator()
{
if ( tunnelsource == null )
return new NullIterator();
return new TunnelIterator( tunnelsource, clz );
}
public void setSource(Collection<T> c)
{
tunnelsource = c;
}
public boolean isEmpty()
{
return !iterator().hasNext();
}
public boolean matches(Class<? extends PartP2PTunnel> c)
{
return clz == c;
}
public Class<? extends PartP2PTunnel> getClz()
{
return clz;
}
}