⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 comparablecondition.java

📁 JAVA实现的有限状态自动机。该软件适合Linux环境下安装运行。
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    }    /**     * Constructs a new ComparableCondition with the default type of     * EQUALS_TO.     *     * @param state      The target state for this condition.     * @param comparable The Comparable object to compare against.     */    public ComparableCondition(State state, byte comparable) {	super(state);	createSelf(new Byte(comparable), type);    }    /**     * Constructs a new ComparableCondition with the default type of     * EQUALS_TO.     *     * @param state      The target state for this condition.     * @param comparable The Comparable object to compare against.     * @param type       The type of comparison to be done.     */    public ComparableCondition(State state, byte comparable, int type) {	super(state);	createSelf(new Byte(comparable), type);    }    /**     * Constructs a new ComparableCondition with the default type of     * EQUALS_TO.     *     * @param state      The target state for this condition.     * @param comparable The Comparable object to compare against.     */    public ComparableCondition(State state, char comparable) {	super(state);	createSelf(new Character(comparable), type);    }    /**     * Constructs a new ComparableCondition with the default type of     * EQUALS_TO.     *     * @param state      The target state for this condition.     * @param comparable The Comparable object to compare against.     * @param type       The type of comparison to be done.     */    public ComparableCondition(State state, char comparable, int type) {	super(state);	createSelf(new Character(comparable), type);    }    /**     * Constructs a new ComparableCondition with the default type of     * EQUALS_TO.     *     * @param state      The target state for this condition.     * @param comparable The Comparable object to compare against.     */    public ComparableCondition(State state, double comparable) {	super(state);	createSelf(new Double(comparable), type);    }    /**     * Constructs a new ComparableCondition with the default type of     * EQUALS_TO.     *     * @param state      The target state for this condition.     * @param comparable The Comparable object to compare against.     * @param type       The type of comparison to be done.     */    public ComparableCondition(State state, double comparable, int type) {	super(state);	createSelf(new Double(comparable), type);    }    /**     * Constructs a new ComparableCondition with the default type of     * EQUALS_TO.     *     * @param state      The target state for this condition.     * @param comparable The Comparable object to compare against.     */    public ComparableCondition(State state, float comparable) {	super(state);	createSelf(new Float(comparable), type);    }    /**     * Constructs a new ComparableCondition with the default type of     * EQUALS_TO.     *     * @param state      The target state for this condition.     * @param comparable The Comparable object to compare against.     * @param type       The type of comparison to be done.     */    public ComparableCondition(State state, float comparable, int type) {	super(state);	createSelf(new Float(comparable), type);    }    /**     * Constructs a new ComparableCondition with the default type of     * EQUALS_TO.     *     * @param state      The target state for this condition.     * @param comparable The Comparable object to compare against.     */    public ComparableCondition(State state, int comparable) {	super(state);	createSelf(new Integer(comparable), type);    }    /**     * Constructs a new ComparableCondition with the default type of     * EQUALS_TO.     *     * @param comparable The Comparable object to compare against.     * @param type       The type of comparison to be done.     */    public ComparableCondition(State state, int comparable, int type) {	super(state);	createSelf(new Integer(comparable), type);    }    /**     * Constructs a new ComparableCondition with the default type of     * EQUALS_TO.     *     * @param state      The target state for this condition.     * @param comparable The Comparable object to compare against.     */    public ComparableCondition(State state, long comparable) {	super(state);	createSelf(new Long(comparable), type);    }    /**     * Constructs a new ComparableCondition with the default type of     * EQUALS_TO.     *     * @param state      The target state for this condition.     * @param comparable The Comparable object to compare against.     * @param type       The type of comparison to be done.     */    public ComparableCondition(State state, long comparable, int type) {	super(state);	createSelf(new Long(comparable), type);    }    /**     * Constructs a new ComparableCondition with the default type of     * EQUALS_TO.     *     * @param state      The target state for this condition.     * @param comparable The Comparable object to compare against.     */    public ComparableCondition(State state, short comparable) {	super(state);	createSelf(new Short(comparable), type);    }    /**     * Constructs a new ComparableCondition with the default type of     * EQUALS_TO.     *     * @param state      The target state for this condition.     * @param comparable The Comparable object to compare against.     * @param type       The type of comparison to be done.     */    public ComparableCondition(State state, short comparable, int type) {	super(state);	createSelf(new Short(comparable), type);    }    /**     * Does the actual creation of a ComparableCondition.     *     * @param comparable The Comparable object to compare against.     * @param type       The type of comparison to be done.     */    private final void createSelf(Comparable comparable, int type) {	if(comparable == null)	    throw new NullPointerException("null Comparable");	this.comparable = comparable;	this.type = type;    }    /**     * Sets the type of ComparableCondition this is.     *     * @param type The new type of this condition.     */    public final void setType(int type) {	if((type < EQUAL_TO) ||	   (type > LESS_THAN_OR_EQUAL_TO))	    throw new IndexOutOfBoundsException("Type is invalid: " + type);	this.type = type;    }    /**     * Returns the type of ComparableCondition this is.     *     * @return An int representation of the type of ComparableCondition this     *         is.     */    public final int getType() {	return type;    }    /**     * Implemented method for the Condition interface.     *     * Called to check if the conditional meets the criteria defined by this     * state.  This is the only method to implement in order to used this     * interface.     *     * @param conditional The object to check.     * @return Implementors should return <code>true</code> if this condition     *         is met by the Object <code>conditional</code> and     *         <code>false</code> otherwise.     */    public final boolean satisfiedBy(Object conditional) {	if(conditional instanceof Comparable) {	    Comparable cond = (Comparable)conditional;	    int checkType = type;	    switch(checkType) {	    case EQ:		return (cond.compareTo(comparable) == 0);	    case NE:		return (cond.compareTo(comparable) != 0);	    case GT:		return (cond.compareTo(comparable) >  0);	    case LT:		return (cond.compareTo(comparable) <  0);	    case GTE:		return (cond.compareTo(comparable) >= 0);	    case LTE:		return (cond.compareTo(comparable) <= 0);	    default:		System.err.println("ComparableCondition.satisfiedBy: WARNING" +				   ": invalid type: " + checkType);	    }	}	return false;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -