List of usage examples for org.apache.commons.collections4 ListUtils indexOf
public static <E> int indexOf(final List<E> list, final Predicate<E> predicate)
From source file:com.feilong.core.util.CollectionsUtil.java
/** * list, <code>propertyName</code> <code>value</code>?. * //from ww w. jav a 2 s . co m * <h3>:</h3> * * <blockquote> * * <pre class="code"> * * List{@code <User>} list = new ArrayList{@code <User>}(); * list.add(new User("", 23)); * list.add(new User("", 24)); * list.add(new User("", 25)); * * assertEquals(0, CollectionsUtil.indexOf(list, "name", "")); * </pre> * * </blockquote> * * @param <O> * the generic type * @param <V> * the generic type * @param list * the list * @param propertyName * O??,Possibly indexed and/or nested name of the property to be modified,?? * <a href="../bean/BeanUtil.html#propertyName">propertyName</a> * @param propertyValue * the value * @return listnull empty, -1<br> * <code>propertyName</code> <code>value</code> list ? -1<br> * @see org.apache.commons.collections4.ListUtils#indexOf(List, Predicate) * @see BeanPredicateUtil#equalPredicate(String, Object) * @since 1.5.5 */ public static <O, V> int indexOf(List<O> list, String propertyName, V propertyValue) { return ListUtils.indexOf(list, BeanPredicateUtil.<O, V>equalPredicate(propertyName, propertyValue)); }
From source file:org.craftercms.engine.targeting.impl.TargetedContentStoreAdapter.java
protected boolean containsItem(final List<Item> list, final Item item) { int idx = ListUtils.indexOf(list, new Predicate<Item>() { @Override/* w w w .ja va 2 s. c om*/ public boolean evaluate(Item it) { return it.getName().equals(item.getName()); } }); return idx >= 0; }
From source file:org.peercast.pecaport.WanConnectionsAdapter.java
/**??WanConnection??????????-1*/ public int getConnectedPosition() { return ListUtils.indexOf(mConnections, new Predicate<WanConnection>() { @Override/*w w w. j a v a 2 s. c o m*/ public boolean evaluate(WanConnection conn) { return conn.getStatus() == Connection.Status.Connected; } }); }