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


Java PredicateUtils.equalPredicate方法代码示例

本文整理汇总了Java中org.apache.commons.collections4.PredicateUtils.equalPredicate方法的典型用法代码示例。如果您正苦于以下问题:Java PredicateUtils.equalPredicate方法的具体用法?Java PredicateUtils.equalPredicate怎么用?Java PredicateUtils.equalPredicate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.collections4.PredicateUtils的用法示例。


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

示例1: 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

示例2: 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

示例3: equalPredicate

import org.apache.commons.collections4.PredicateUtils; //导入方法依赖的package包/类
/**
 * 用来指定 <code>T</code> 对象的特定属性 <code>propertyName</code> equals 指定的 <code>propertyValue</code>.
 * 
 * <h3>说明:</h3>
 * <blockquote>
 * <ol>
 * <li>
 * 常用于解析集合,如 {@link CollectionsUtil#select(Iterable, Predicate) select},{@link CollectionsUtil#find(Iterable, Predicate) find},
 * {@link CollectionsUtil#selectRejected(Iterable, Predicate) selectRejected},
 * {@link CollectionsUtil#group(Iterable, String, Predicate) group},
 * {@link AggregateUtil#groupCount(Iterable, String, Predicate) groupCount},
 * {@link AggregateUtil#sum(Iterable, String, Predicate) sum} 等方法.
 * </li>
 * </ol>
 * </blockquote>
 * 
 * <h3>示例:</h3>
 * 
 * <blockquote>
 * 
 * <p>
 * <b>场景:</b> 在list中查找 名字是 关羽,并且 年龄是30 的user
 * </p>
 * 
 * <pre class="code">
 * 
 * User guanyu30 = new User("关羽", 30);
 * List{@code <User>} list = toList(//
 *                 new User("张飞", 23),
 *                 new User("关羽", 24),
 *                 new User("刘备", 25),
 *                 guanyu30);
 * 
 * Predicate{@code <User>} predicate = PredicateUtils
 *                 .andPredicate(BeanPredicateUtil.equalPredicate("name", "关羽"), BeanPredicateUtil.equalPredicate("age", 30));
 * 
 * assertEquals(guanyu30, CollectionsUtil.find(list, predicate));
 * 
 * </pre>
 * 
 * </blockquote>
 * 
 * @param <T>
 *            the generic type
 * @param <V>
 *            the value type
 * @param propertyName
 *            泛型T对象指定的属性名称,Possibly indexed and/or nested name of the property to be modified,参见
 *            <a href="../../bean/BeanUtil.html#propertyName">propertyName</a>
 * @param propertyValue
 *            the property value
 * @return 如果 <code>propertyName</code> 是null,抛出 {@link NullPointerException}<br>
 *         如果 <code>propertyName</code> 是blank,抛出 {@link IllegalArgumentException}<br>
 * @see org.apache.commons.collections4.PredicateUtils#equalPredicate(Object)
 */
public static <T, V> Predicate<T> equalPredicate(String propertyName,V propertyValue){
    Validate.notBlank(propertyName, "propertyName can't be blank!");
    return new BeanPredicate<>(propertyName, PredicateUtils.equalPredicate(propertyValue));
}
 
开发者ID:venusdrogon,项目名称:feilong-core,代码行数:60,代码来源:BeanPredicateUtil.java


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