leapsrulehandle.java

来自「jboss规则引擎」· Java 代码 · 共 85 行

JAVA
85
字号
package org.drools.leaps;

/*
 * Copyright 2005 JBoss Inc
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import org.drools.common.DefaultFactHandle;

/**
 * class container for rules. Re-using defaultfact handle 
 * 
 * class container for rules used in the system. Handle is created for each
 * leaps rule, dominant position (column/ce position), dominant position type
 * (class at the column/ce position) or indicator if handle is for asserted or
 * retracted tuple combination
 * 
 * @author Alexander Bagerman
 * 
 */
public class LeapsRuleHandle extends DefaultFactHandle {

    // ce position for which handle is created
    private final int         dominantPosition;

    public LeapsRuleHandle(final long id, final LeapsRule rule,
                           final int dominantPosition) {
        super( id, rule );
        this.dominantPosition = dominantPosition;
    }

    /**
     * @return leaps wrapped rule
     */
    public LeapsRule getLeapsRule() {
        return (LeapsRule) this.getObject();
    }

    /**
     * @return base column / ce position
     */
    public int getDominantPosition() {
        return this.dominantPosition;
    }

    /**
     * @see org.drools.rule.Rule
     */
    public int getRuleComplexity() {
        return this.getLeapsRule().getRule().getDeclarations().length;
    }

    /**
     * @see org.drools.rule.Rule
     */
    public int getSalience() {
        return this.getLeapsRule().getRule().getSalience();
    }

    /**
     * @see java.lang.Object
     */
    public boolean equals(final Object that) {
        return super.equals( that ) && (this.getDominantPosition() == ((LeapsRuleHandle) that).getDominantPosition());
    }

    /**
     * @see java.lang.Object
     */
    public String toString() {
        return "R-" + this.getId() + " \"" + this.getLeapsRule().toString() + "\" [pos - " + this.dominantPosition + "]";
    }
}

⌨️ 快捷键说明

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