• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ObjectFilter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ParallelComputer类代码示例发布时间:2022-05-22
下一篇:
Java PutRepositoryResponse类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap