当前位置: 首页>>代码示例>>Java>>正文


Java ObjectFilter类代码示例

本文整理汇总了Java中org.kie.api.runtime.ObjectFilter的典型用法代码示例。如果您正苦于以下问题:Java ObjectFilter类的具体用法?Java ObjectFilter怎么用?Java ObjectFilter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ObjectFilter类属于org.kie.api.runtime包,在下文中一共展示了ObjectFilter类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findpayPass

import org.kie.api.runtime.ObjectFilter; //导入依赖的package包/类
/**
 * Search the {@link KieSession} for pay passes.
 */
private RoutingInfo findpayPass(KieSession kieSession) {
    
    // Find all PayStylePass facts and 1st generation child classes of PayStylePass.
    ObjectFilter payPassFilter = new ObjectFilter() {
        @Override
        public boolean accept(Object object) {
            if (RoutingInfo.class.equals(object.getClass())) return true;
            if (RoutingInfo.class.equals(object.getClass().getSuperclass())) return true;
            return false;
        }
    };

    // printFactsMessage(kieSession);
    
    List<RoutingInfo> facts = new ArrayList<RoutingInfo>();
    for (FactHandle handle : kieSession.getFactHandles(payPassFilter)) {
        facts.add((RoutingInfo) kieSession.getObject(handle));
    }
    if (facts.size() == 0) {
        return null;
    }
    // Assumes that the rules will always be generating a single pay pass.
    return facts.get(0);
}
 
开发者ID:IBYoung,项目名称:vert.3x-gateway,代码行数:28,代码来源:RoutingPassService.java

示例2: findBusPass

import org.kie.api.runtime.ObjectFilter; //导入依赖的package包/类
/**
 * Search the {@link KieSession} for bus passes.
 */
private BusPass findBusPass(KieSession kieSession) {
    
    // Find all BusPass facts and 1st generation child classes of BusPass.
    ObjectFilter busPassFilter = new ObjectFilter() {
        @Override
        public boolean accept(Object object) {
            if (BusPass.class.equals(object.getClass())) return true;
            if (BusPass.class.equals(object.getClass().getSuperclass())) return true;
            return false;
        }
    };

    // printFactsMessage(kieSession);
    
    List<BusPass> facts = new ArrayList<BusPass>();
    for (FactHandle handle : kieSession.getFactHandles(busPassFilter)) {
        facts.add((BusPass) kieSession.getObject(handle));
    }
    if (facts.size() == 0) {
        return null;
    }
    // Assumes that the rules will always be generating a single bus pass. 
    return facts.get(0);
}
 
开发者ID:gratiartis,项目名称:buspass-ws,代码行数:28,代码来源:BusPassService.java

示例3: removeFacts

import org.kie.api.runtime.ObjectFilter; //导入依赖的package包/类
@Override
public void removeFacts(Predicate<Object> factFilter) {
    Collection<FactHandle> handles = kSession.getFactHandles(new ObjectFilter() {
        @Override
        public boolean accept(Object object) {
            return factFilter.test(object);
        }
    });

    if (null == handles) {
        return;
    }

    for (FactHandle h : handles) {
        removeFact(h);
    }
}
 
开发者ID:hawkular,项目名称:hawkular-alerts,代码行数:18,代码来源:DroolsRulesEngineImpl.java

示例4: findFacts

import org.kie.api.runtime.ObjectFilter; //导入依赖的package包/类
public static Collection<Object> findFacts(StatefulKnowledgeSession session, final String className) {

        ObjectFilter filter = new ObjectFilter() {
            @Override
            public boolean accept(Object object) {
                return true;
            }
        };

        Collection<FactHandle> factHandles = session.getFactHandles();
        Collection<Object> facts = new ArrayList<Object>();
        for (FactHandle handle : factHandles) {
            Object fact = session.getObject(handle);
            facts.add(fact);
        }
        return facts;
    }
 
开发者ID:eternnoir,项目名称:RulEST,代码行数:18,代码来源:FactHelper.java

示例5: findFacts

import org.kie.api.runtime.ObjectFilter; //导入依赖的package包/类
/**
 * An assertion that a fact of the expected class with specified properties
 * is in working memory.
 * 
 * @param session
 *            A {@link KnowledgeSession} in which we are looking for the
 *            fact.
 * @param factClass
 *            The simple name of the class of the fact we're looking for.
 * @param expectedProperties
 *            A sequence of expected property name/value pairs.
 * @throws IllegalAccessException
 * @throws InvocationTargetException
 * @throws NoSuchMethodException
 */
@SuppressWarnings("unchecked")
public List<T> findFacts(final KieSession session, final BeanPropertyFilter... expectedProperties) {

    ObjectFilter filter = new ObjectFilter() {
        @Override
        public boolean accept(Object object) {
            return object.getClass().equals(classToFind) 
                    && beanMatcher.matches(object, expectedProperties);
        }
    };

    Collection<FactHandle> factHandles = session.getFactHandles(filter);
    List<T> facts = new ArrayList<T>();
    for (FactHandle handle : factHandles) {
        facts.add((T) session.getObject(handle));
    }
    return facts;
}
 
开发者ID:gratiartis,项目名称:qzr,代码行数:34,代码来源:FactFinder.java

示例6: findFacts

import org.kie.api.runtime.ObjectFilter; //导入依赖的package包/类
/**
 * An assertion that a fact of the expected class with specified properties
 * is in working memory.
 * 
 * @param session
 *            A {@link KnowledgeSession} in which we are looking for the
 *            fact.
 * @param factClass
 *            The simple name of the class of the fact we're looking for.
 * @param expectedProperties
 *            A sequence of expected property name/value pairs.
 * @throws IllegalAccessException
 * @throws InvocationTargetException
 * @throws NoSuchMethodException
 */
@SuppressWarnings("unchecked")
public Collection<T> findFacts(final KieSession session, final BeanPropertyFilter... expectedProperties) {

    ObjectFilter filter = new ObjectFilter() {
        @Override
        public boolean accept(Object object) {
            return object.getClass().equals(classToFind) 
                    && beanMatcher.matches(object, expectedProperties);
        }
    };

    Collection<FactHandle> factHandles = session.getFactHandles(filter);
    Collection<T> facts = new ArrayList<T>();
    for (FactHandle handle : factHandles) {
        facts.add((T) session.getObject(handle));
    }
    return facts;
}
 
开发者ID:deepu105,项目名称:drools-demo,代码行数:34,代码来源:FactFinder.java

示例7: listAlerts

import org.kie.api.runtime.ObjectFilter; //导入依赖的package包/类
public List<Alert<?>> listAlerts() {
	List<Alert<?>> ret = new ArrayList<Alert<?>>();
	@SuppressWarnings("unchecked")
	Collection<Alert<?>> sessionObjects = (Collection<Alert<?>>) kieSession.getObjects(new ObjectFilter() {
		@Override
		public boolean accept(Object arg0) {
			return (arg0 instanceof Alert) ? true : false;
		}
	});
	ret.addAll(sessionObjects);
	return ret;
}
 
开发者ID:tarilabs,项目名称:reex2014,代码行数:13,代码来源:PseudoRealtimeRuleEngine.java

示例8: deleteFacts

import org.kie.api.runtime.ObjectFilter; //导入依赖的package包/类
public void deleteFacts(final KieSession session, final BeanPropertyFilter... expectedProperties) {

        ObjectFilter filter = new ObjectFilter() {
            @Override
            public boolean accept(Object object) {
                return object.getClass().equals(classToFind) 
                        && beanMatcher.matches(object, expectedProperties);
            }
        };

        Collection<FactHandle> factHandles = session.getFactHandles(filter);
        for (FactHandle handle : factHandles) {
            session.delete(handle);
        }
    }
 
开发者ID:gratiartis,项目名称:qzr,代码行数:16,代码来源:FactFinder.java

示例9: getObjects

import org.kie.api.runtime.ObjectFilter; //导入依赖的package包/类
public Collection<? extends Object> getObjects(ObjectFilter filter) {
    return kieSession.getObjects(filter);
}
 
开发者ID:deepu105,项目名称:drools-demo,代码行数:4,代码来源:DefaultKieSessionBean.java

示例10: getFactHandles

import org.kie.api.runtime.ObjectFilter; //导入依赖的package包/类
public <T extends FactHandle> Collection<T> getFactHandles(
        ObjectFilter filter) {
    return kieSession.getFactHandles(filter);
}
 
开发者ID:deepu105,项目名称:drools-demo,代码行数:5,代码来源:DefaultKieSessionBean.java

示例11: retractAll

import org.kie.api.runtime.ObjectFilter; //导入依赖的package包/类
/**
 * Retract all fact handles from working memory, which match an
 * {@link ObjectFilter}. For example, to retract all facts of a 
 * class called "MyObject":
 * 
 * <pre>
 * retractAll(new ObjectFilter() {
 *     public boolean accept(Object object) {
 *         return object.getClass().getSimpleName()
 *                 .equals(MyObject.class.getSimpleName());
 *     }
 * });
 * </pre>
 * 
 * @param filter
 *            The {@link ObjectFilter}.
 */
public static void retractAll(KieSession ksession, ObjectFilter filter) {
    log.info("Retracting all facts matching filter...");
    for (FactHandle handle : getFactHandles(ksession, filter)) {
        retract(ksession, handle);
    }
}
 
开发者ID:gratiartis,项目名称:qzr,代码行数:24,代码来源:DroolsUtil.java

示例12: getFactHandles

import org.kie.api.runtime.ObjectFilter; //导入依赖的package包/类
/**
 * Find all handles to facts in working memory matching an
 * {@link ObjectFilter}. For example, to find all facts of a class called
 * "MyObject":
 * 
 * <pre>
 * getFactHandles(new ObjectFilter() {
 *     public boolean accept(Object object) {
 *         return object.getClass().getSimpleName()
 *                 .equals(MyObject.class.getSimpleName());
 *     }
 * });
 * </pre>
 * 
 * @param filter
 *            The {@link ObjectFilter}.
 * @return A collection of facts matching the filter.
 */
public static Collection<FactHandle> getFactHandles(KieSession ksession, ObjectFilter filter) {
    return ksession.getFactHandles(filter);
}
 
开发者ID:gratiartis,项目名称:qzr,代码行数:22,代码来源:DroolsUtil.java


注:本文中的org.kie.api.runtime.ObjectFilter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。