本文整理汇总了Java中org.apache.commons.collections4.PredicateUtils类的典型用法代码示例。如果您正苦于以下问题:Java PredicateUtils类的具体用法?Java PredicateUtils怎么用?Java PredicateUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PredicateUtils类属于org.apache.commons.collections4包,在下文中一共展示了PredicateUtils类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: withSymbolEpsilonOrSubmachineFromSourceState
import org.apache.commons.collections4.PredicateUtils; //导入依赖的package包/类
/**
* Consulta transições com o consumo de um símbolo específico, em vazio ou
* com chamadas de submáquina a partir do estado de origem informado.
* @param state Estado de origem.
* @param symbol Símbolo a ser consumido.
* @return Transições com o consumo de um símbolo específico, em vazio ou
* com chamadas de submáquina a partir do estado de origem informado.
*/
public List<Transition> withSymbolEpsilonOrSubmachineFromSourceState(
State state, Symbol symbol) {
Predicate[] chain = {
new EpsilonPredicate(),
new SubmachineCallPredicate(),
new SymbolPredicate(symbol)
};
Collection<Transition> result = CollectionUtils.select(
CollectionUtils.select(
transitions,
new SourceStatePredicate(state)),
PredicateUtils.anyPredicate(chain)
);
return new ArrayList<>(result);
}
开发者ID:cereda,项目名称:aa,代码行数:24,代码来源:Mapping.java
示例2: getAllFieldList
import org.apache.commons.collections4.PredicateUtils; //导入依赖的package包/类
/**
* 获得 <code>klass</code> 排除某些 <code>excludeFieldNames</code> 之后的字段list.
*
* <h3>说明:</h3>
* <blockquote>
* <ol>
* <li>是所有字段的值(<b>不是属性</b>)</li>
* <li>自动过滤私有并且静态的字段,比如 LOGGER serialVersionUID</li>
* </ol>
* </blockquote>
*
* @param klass
* the klass
* @param excludeFieldNames
* 需要排除的field names,如果传递过来是null或者empty 那么不会判断
* @return 如果 <code>obj</code> 是null,抛出 {@link NullPointerException}<br>
* 如果 <code>excludeFieldNames</code> 是null或者empty,解析所有的field<br>
* 如果 {@link FieldUtils#getAllFieldsList(Class)} 是null或者empty,返回 {@link Collections#emptyList()}<br>
* 如果 <code>obj</code>没有字段或者字段都被参数 <code>excludeFieldNames</code> 排除掉了,返回 {@link Collections#emptyMap()}<br>
* @see FieldUtils#getAllFieldsList(Class)
* @since 1.7.1
*/
public static List<Field> getAllFieldList(final Class<?> klass,String...excludeFieldNames){
Validate.notNull(klass, "klass can't be null!");
//获得给定类的所有声明字段 {@link Field},包括所有的parents,包括 public/protect/private/inherited...
List<Field> fieldList = FieldUtils.getAllFieldsList(klass);
if (isNullOrEmpty(fieldList)){
return emptyList();
}
//---------------------------------------------------------------
Predicate<Field> excludeFieldPredicate = BeanPredicateUtil.containsPredicate("name", excludeFieldNames);
Predicate<Field> staticPredicate = new Predicate<Field>(){
@Override
public boolean evaluate(Field field){
int modifiers = field.getModifiers();
// 私有并且静态 一般是log 或者 serialVersionUID
boolean isStatic = Modifier.isStatic(modifiers);
String pattern = "[{}.{}],modifiers:[{}]{}";
LOGGER.trace(pattern, klass.getSimpleName(), field.getName(), modifiers, isStatic ? " [isStatic]" : EMPTY);
return isStatic;
}
};
return selectRejected(fieldList, PredicateUtils.orPredicate(excludeFieldPredicate, staticPredicate));
}
开发者ID:venusdrogon,项目名称:feilong-core,代码行数:48,代码来源:FieldUtil.java
示例3: testIgnoreCaseFind2
import org.apache.commons.collections4.PredicateUtils; //导入依赖的package包/类
/**
* Test ignore case find 2.
*/
@Test
public void testIgnoreCaseFind2(){
User guanyu30 = new User("guanYu", 30);
List<User> list = toList(//
new User("张飞", 23),
new User("guanyu1", 24),
new User("刘备", 25),
guanyu30);
Predicate<User> predicate = PredicateUtils.andPredicate(
BeanPredicateUtil.equalIgnoreCasePredicate("name", "guanyu"),
BeanPredicateUtil.equalPredicate("age", 30));
assertEquals(guanyu30, CollectionsUtil.find(list, predicate));
}
开发者ID:venusdrogon,项目名称:feilong-core,代码行数:19,代码来源:EqualIgnoreCasePredicateTest.java
示例4: testSum3
import org.apache.commons.collections4.PredicateUtils; //导入依赖的package包/类
/**
* Test sum3.
*/
@Test
public void testSum3(){
User liubei = new User(10L);
liubei.setName("刘备");
liubei.setAge(50);
User guanyu = new User(20L);
liubei.setName("关羽");
guanyu.setAge(50);
User zhangfei = new User(100L);
zhangfei.setName("张飞");
zhangfei.setAge(null);
User zhaoyun = new User((Long) null);
zhaoyun.setName("赵云");
zhaoyun.setAge(100);
List<User> list = toList(liubei, guanyu, zhangfei, zhaoyun);
Predicate<User> notPredicate = PredicateUtils.notPredicate(BeanPredicateUtil.equalPredicate("name", "张飞"));
Map<String, BigDecimal> map = AggregateUtil.sum(list, toArray("id", "age"), notPredicate);
assertThat(map, allOf(hasEntry("id", toBigDecimal(30)), hasEntry("age", toBigDecimal(200))));
}
开发者ID:venusdrogon,项目名称:feilong-core,代码行数:29,代码来源:SumPredicateTest.java
示例5: withSourceStateAndSymbol
import org.apache.commons.collections4.PredicateUtils; //导入依赖的package包/类
/**
* Consulta transições que consomem o símbolo informado a partir do estado
* de origem também informado.
* @param state Estado de origem.
* @param symbol Símbolo a ser consumido.
* @return Transições que consomem o símbolo informado a partir do estado
* de origem também informado.
*/
public List<Transition> withSourceStateAndSymbol(State state,
Symbol symbol) {
Predicate[] chain = {
new SourceStatePredicate(state),
new SymbolPredicate(symbol)
};
Collection<Transition> result = CollectionUtils.select(
transitions,
PredicateUtils.allPredicate(chain)
);
return new ArrayList<>(result);
}
开发者ID:cereda,项目名称:aa,代码行数:21,代码来源:Mapping.java
示例6: withSourceAndTargetStates
import org.apache.commons.collections4.PredicateUtils; //导入依赖的package包/类
/**
* Consulta transições que partem do estado de origem informado e seguem até
* o estado de destino também informado.
* @param state1 Estado de origem.
* @param state2 Estado de destino.
* @return Transições que partem do estado de origem informado e seguem até
* o estado de destino também informado.
*/
public List<Transition> withSourceAndTargetStates(State state1,
State state2) {
Predicate[] chain = {
new SourceStatePredicate(state1),
new TargetStatePredicate(state2)
};
Collection<Transition> result = CollectionUtils.select(
transitions,
PredicateUtils.allPredicate(chain)
);
return new ArrayList<>(result);
}
开发者ID:cereda,项目名称:aa,代码行数:21,代码来源:Mapping.java
示例7: withSourceStateSymbolAndTargetState
import org.apache.commons.collections4.PredicateUtils; //导入依赖的package包/类
/**
* Consulta quais transições partem de um estado de origem, consomem o
* símbolo e chegam até um estado de destino.
* @param state1 Estado de origem.
* @param symbol Símbolo a ser consumido.
* @param state2 Estado de destino.
* @return Transições partem de um estado de origem, consomem o símbolo e
* chegam até um estado de destino.
*/
public List<Transition> withSourceStateSymbolAndTargetState(State state1,
Symbol symbol, State state2) {
Predicate[] chain = {
new SourceStatePredicate(state1),
new SymbolPredicate(symbol),
new TargetStatePredicate(state2)
};
Collection<Transition> result = CollectionUtils.select(
transitions,
PredicateUtils.allPredicate(chain)
);
return new ArrayList<>(result);
}
开发者ID:cereda,项目名称:aa,代码行数:23,代码来源:Mapping.java
示例8: withSourceStateAndSumbmachine
import org.apache.commons.collections4.PredicateUtils; //导入依赖的package包/类
/**
* Consulta transições que partem de um estado de origem e chamam uma
* determinada submáquina.
* @param state Estado de origem.
* @param submachine Nome da submáquina.
* @return Transições que partem de um estado de origem e chamam uma
* determinada submáquina.
*/
public List<Transition> withSourceStateAndSumbmachine(State state,
String submachine) {
Predicate[] chain = {
new SourceStatePredicate(state),
new SubmachinePredicate(submachine)
};
Collection<Transition> result = CollectionUtils.select(
transitions,
PredicateUtils.allPredicate(chain)
);
return new ArrayList<>(result);
}
开发者ID:cereda,项目名称:aa,代码行数:21,代码来源:Mapping.java
示例9: withEpsilonFromSourceState
import org.apache.commons.collections4.PredicateUtils; //导入依赖的package包/类
/**
* Consulta transições em vazio a partir do estado de origem.
* @param state Estado de origem.
* @return Transições em vazio a partir do estado de origem.
*/
public List<Transition> withEpsilonFromSourceState(State state) {
Predicate[] chain = {
new SourceStatePredicate(state),
new EpsilonPredicate()
};
Collection<Transition> result = CollectionUtils.select(
transitions,
PredicateUtils.allPredicate(chain)
);
return new ArrayList<>(result);
}
开发者ID:cereda,项目名称:aa,代码行数:17,代码来源:Mapping.java
示例10: withEpsilonOrSubmachineFromSourceState
import org.apache.commons.collections4.PredicateUtils; //导入依赖的package包/类
/**
* Consulta transições em vazio ou com chamadas de submáquina a partir do
* estado de origem informado.
* @param state Estado de origem.
* @return Transições em vazio ou com chamadas de submáquina a partir do
* estado de origem informado.
*/
public List<Transition> withEpsilonOrSubmachineFromSourceState(
State state) {
Predicate[] chain = {
new EpsilonPredicate(),
new SubmachineCallPredicate()
};
Collection<Transition> result = CollectionUtils.select(
CollectionUtils.select(
transitions, new SourceStatePredicate(state)
),
PredicateUtils.anyPredicate(chain)
);
return new ArrayList<>(result);
}
开发者ID:cereda,项目名称:aa,代码行数:22,代码来源:Mapping.java
示例11: withSymbolAndTargetState
import org.apache.commons.collections4.PredicateUtils; //导入依赖的package包/类
/**
* Consulta transições que consomem um determinado símbolo e chegam até o
* estado de destino especificado.
* @param symbol Símbolo a ser consumido.
* @param state Estado de destino.
* @return Transições que consomem um determinado símbolo e chegam até o
* estado de destino especificado.
*/
public List<Transition> withSymbolAndTargetState(Symbol symbol,
State state) {
Predicate[] chain = {
new SymbolPredicate(symbol),
new TargetStatePredicate(state)
};
Collection<Transition> result = CollectionUtils.select(
transitions,
PredicateUtils.allPredicate(chain)
);
return new ArrayList<>(result);
}
开发者ID:cereda,项目名称:aa,代码行数:21,代码来源:Mapping.java
示例12: testFind2
import org.apache.commons.collections4.PredicateUtils; //导入依赖的package包/类
/**
* Test find2.
*/
@Test
public void testFind2(){
User guanyu30 = new User("关羽", 30);
List<User> list = toList(//
new User("张飞", 23),
new User("关羽", 24),
new User("刘备", 25),
guanyu30);
Predicate<User> predicate = PredicateUtils
.andPredicate(BeanPredicateUtil.equalPredicate("name", "关羽"), BeanPredicateUtil.equalPredicate("age", 30));
assertEquals(guanyu30, CollectionsUtil.find(list, predicate));
}
开发者ID:venusdrogon,项目名称:feilong-core,代码行数:18,代码来源:EqualPredicateTest.java
示例13: testContainsPredicate12
import org.apache.commons.collections4.PredicateUtils; //导入依赖的package包/类
@Test
public void testContainsPredicate12(){
User guanyu30 = new User("关羽", 30);
Predicate<User> predicate = PredicateUtils.andPredicate(
BeanPredicateUtil.containsPredicate("name", toList("关羽", "刘备")),
BeanPredicateUtil.containsPredicate("age", toList(30)));
assertEquals(true, predicate.evaluate(guanyu30));
}
开发者ID:venusdrogon,项目名称:feilong-core,代码行数:11,代码来源:ContainsPredicateListTest.java
示例14: testContainsPredicate12
import org.apache.commons.collections4.PredicateUtils; //导入依赖的package包/类
@Test
public void testContainsPredicate12(){
User guanyu30 = new User("关羽", 30);
Predicate<User> predicate = PredicateUtils.andPredicate(
BeanPredicateUtil.containsPredicate("name", "关羽", "刘备"),
BeanPredicateUtil.containsPredicate("age", 30));
assertEquals(true, predicate.evaluate(guanyu30));
}
开发者ID:venusdrogon,项目名称:feilong-core,代码行数:11,代码来源:ContainsPredicateTest.java
示例15: test
import org.apache.commons.collections4.PredicateUtils; //导入依赖的package包/类
@Test
public void test(){
User user = new User("feilong");
Predicate<User> predicate = new BeanPredicate<>("name", PredicateUtils.equalPredicate("feilong"));
assertTrue(predicate.evaluate(user));
}
开发者ID:venusdrogon,项目名称:feilong-core,代码行数:9,代码来源:BeanPredicateTest.java
示例16: testSum3111
import org.apache.commons.collections4.PredicateUtils; //导入依赖的package包/类
/**
* Test sum 3111.
*/
@Test
public void testSum3111(){
User zhangfei = new User(100L);
zhangfei.setName("张飞");
zhangfei.setAge(null);
List<User> list = toList(zhangfei);
Predicate<User> notPredicate = PredicateUtils.notPredicate(BeanPredicateUtil.equalPredicate("name", "张飞"));
Map<String, BigDecimal> map = AggregateUtil.sum(list, toArray("id", "age"), notPredicate);
assertEquals(true, isNullOrEmpty(map));
}
开发者ID:venusdrogon,项目名称:feilong-core,代码行数:17,代码来源:SumPredicateTest.java
示例17: FilterPredicate
import org.apache.commons.collections4.PredicateUtils; //导入依赖的package包/类
private FilterPredicate(Settings settings, Set<WiFiBand> wiFiBands) {
Predicate<WiFiDetail> ssidPredicate = makeSSIDPredicate(settings.getSSIDs());
Predicate<WiFiDetail> wiFiBandPredicate = EnumUtils.predicate(WiFiBand.class, wiFiBands, new WiFiBandTransformer());
Predicate<WiFiDetail> strengthPredicate = EnumUtils.predicate(Strength.class, settings.getStrengths(), new StrengthTransformer());
Predicate<WiFiDetail> securityPredicate = EnumUtils.predicate(Security.class, settings.getSecurities(), new SecurityTransformer());
List<Predicate<WiFiDetail>> predicates = Arrays.asList(ssidPredicate, wiFiBandPredicate, strengthPredicate, securityPredicate);
this.predicate = PredicateUtils.allPredicate(CollectionUtils.select(predicates, new NoTruePredicate()));
}
开发者ID:VREMSoftwareDevelopment,项目名称:WiFiAnalyzer,代码行数:9,代码来源:FilterPredicate.java
示例18: findVendors
import org.apache.commons.collections4.PredicateUtils; //导入依赖的package包/类
@NonNull
@Override
public List<String> findVendors(@NonNull String filter) {
Predicate<String> predicate =
PredicateUtils.anyPredicate(new StringContains(filter), new MacContains(filter));
return new ArrayList<>(CollectionUtils.select(getVendors().keySet(), predicate));
}
开发者ID:VREMSoftwareDevelopment,项目名称:WiFiAnalyzer,代码行数:8,代码来源:VendorDB.java
示例19: testFindUsingPredicate
import org.apache.commons.collections4.PredicateUtils; //导入依赖的package包/类
@Test
public void testFindUsingPredicate() throws Exception {
// setup
final TestObject expected = TestObject.VALUE3;
Predicate<TestObject> predicate = PredicateUtils.equalPredicate(expected);
// execute
TestObject actual = EnumUtils.find(TestObject.class, predicate, TestObject.VALUE2);
// validate
assertEquals(expected, actual);
}
开发者ID:VREMSoftwareDevelopment,项目名称:WiFiAnalyzer,代码行数:11,代码来源:EnumUtilsTest.java
示例20: testFindUsingPredicateWhenNothingFound
import org.apache.commons.collections4.PredicateUtils; //导入依赖的package包/类
@Test
public void testFindUsingPredicateWhenNothingFound() throws Exception {
// setup
TestObject expected = TestObject.VALUE2;
Predicate<TestObject> predicate = PredicateUtils.falsePredicate();
// execute
TestObject actual = EnumUtils.find(TestObject.class, predicate, expected);
// validate
assertEquals(expected, actual);
}
开发者ID:VREMSoftwareDevelopment,项目名称:WiFiAnalyzer,代码行数:11,代码来源:EnumUtilsTest.java
注:本文中的org.apache.commons.collections4.PredicateUtils类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论