CollectionStream.java
/**
* Copyright 2010,2021 Nikolas S Boyd.
Permission is granted to copy this work provided this copyright statement is retained in all copies.
*/
package Hoot.Streams;
import Hoot.Runtime.Functions.*;
import Hoot.Runtime.Faces.*;
import Hoot.Runtime.Values.*;
import Hoot.Runtime.Blocks.*;
import Smalltalk.Core.*;
import Smalltalk.Blocks.*;
import Smalltalk.Magnitudes.*;
import Hoot.Behaviors.*;
import Hoot.Behaviors.Nil;
import Hoot.Behaviors.Object;
import Hoot.Behaviors.True;
import Hoot.Behaviors.False;
import Hoot.Behaviors.Boolean;
import Hoot.Magnitudes.*;
import Hoot.Magnitudes.Integer;
import Hoot.Magnitudes.Character;
import Hoot.Magnitudes.Float;
import Hoot.Magnitudes.Double;
import Hoot.Collections.*;
import Hoot.Collections.String;
import Hoot.Magnitudes.Integer;
import Hoot.Collections.OrderedCollection;
import Smalltalk.Streams.*;
import Smalltalk.Core.Subject;
import Smalltalk.Magnitudes.Ordinal;
import Smalltalk.Collections.*;
public abstract class CollectionStream<ElementType extends Object> extends Object implements StreamedSequence<ElementType>
{
public static Metaclass type() { return (Metaclass)Metaclass.$class; }
@Override public Metaclass $class() { return (Metaclass)Metaclass.$class; }
public static class Metaclass extends Object.Metaclass implements StreamedSequence.Metatype
{
static final CollectionStream.Metaclass $class = new CollectionStream.Metaclass();
public Metaclass() {
this(CollectionStream.Metaclass.class);
}
public Metaclass(java.lang.Class aClass) {
super(aClass);
}
@Override public java.lang.Class outerClass() { return CollectionStream.class; }
}
protected Integer position = SmallInteger.from(0);
protected Collected<ElementType> contents;
/**
*
*/
protected CollectionStream(final Collected<ElementType> aCollection)
{
java.lang.String exitID = "CollectionStream>>CollectionStream";
Frame f0 = new Frame(exitID);
contents = aCollection;
}
/**
* @return
*/
public Collected<ElementType> contents()
{
java.lang.String exitID = "CollectionStream>>contents";
Frame f0 = new Frame(exitID);
return (Collected<ElementType>)contents;
}
/**
* @return
*/
public OrderedCollection<ElementType> orderedContents()
{
java.lang.String exitID = "CollectionStream>>orderedContents";
Frame f0 = new Frame(exitID);
return (OrderedCollection<ElementType>)((OrderedCollection)this.contents());
}
/**
* @return
*/
public Boolean collectsElements(final Object element)
{
java.lang.String exitID = "CollectionStream>>collectsElements";
Frame f0 = new Frame(exitID);
return (Boolean)this.orderedContents().collectsElements(element);
}
/**
* @return
*/
public Boolean atEnd()
{
java.lang.String exitID = "CollectionStream>>atEnd";
Frame f0 = new Frame(exitID);
return (Boolean)(position.equals(contents.size()));
}
/**
* @return
*/
public Boolean _isEmpty()
{
java.lang.String exitID = "CollectionStream>>_isEmpty";
Frame f0 = new Frame(exitID);
return (Boolean)contents._isEmpty();
}
/**
* @return
*/
public CollectionStream close()
{
java.lang.String exitID = "CollectionStream>>close";
Frame f0 = new Frame(exitID);
return (CollectionStream)this.setToEnd();
}
/**
* @return
*/
public SmallInteger position()
{
java.lang.String exitID = "CollectionStream>>position";
Frame f0 = new Frame(exitID);
return (SmallInteger)position;
}
/**
* @return
*/
public CollectionStream position(final Ordinal aPosition)
{
java.lang.String exitID = "CollectionStream>>position";
Frame f0 = new Frame(exitID);
position = ((SmallInteger)aPosition);
return (CollectionStream)this;
}
/**
* @return
*/
public CollectionStream reset()
{
java.lang.String exitID = "CollectionStream>>reset";
Frame f0 = new Frame(exitID);
this.position(SmallInteger.from(0));
return (CollectionStream)this;
}
/**
* @return
*/
public CollectionStream setToEnd()
{
java.lang.String exitID = "CollectionStream>>setToEnd";
Frame f0 = new Frame(exitID);
position = ((SmallInteger)contents.size());
return (CollectionStream)this;
}
}