package s3.core.domain;
import ovm.core.domain.Code;
import ovm.core.domain.Method;
import s3.core.S3Base;

/**
 * @author Krzysztof Palacz
 * 
 * 
 **/
public abstract class S3Code 
    extends S3Base 
    implements Code {
 
    protected final S3Method itsMethod;

    private S3Code next_ = null;

    protected S3Code(S3Method method) {
        this.itsMethod = method;
    }

    public void addCode(S3Code newCode) {
        S3Code oldCode = this;
        if (oldCode.equals(newCode)) {
            return;
        }
        while (oldCode.next_ != null) {
            oldCode = oldCode.next_;
            if (oldCode.equals(newCode)) {
                return;
            }
        }
        oldCode.next_ = newCode;
    }

    public Method getMethod() {
        return itsMethod;
    }

    S3Code next() {
        return next_;
    }

    void setNext(S3Code next) {
        this.next_ = next;
    }

}
