本文整理汇总了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);
}
示例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);
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例9: getObjects
import org.kie.api.runtime.ObjectFilter; //导入依赖的package包/类
public Collection<? extends Object> getObjects(ObjectFilter filter) {
return kieSession.getObjects(filter);
}
示例10: getFactHandles
import org.kie.api.runtime.ObjectFilter; //导入依赖的package包/类
public <T extends FactHandle> Collection<T> getFactHandles(
ObjectFilter filter) {
return kieSession.getFactHandles(filter);
}
示例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);
}
}
示例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);
}