Java Code Examples for org.apache.commons.collections4.ListUtils#indexOf()
The following examples show how to use
org.apache.commons.collections4.ListUtils#indexOf() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DataViewMessageBodyWriter.java From ameba with MIT License | 6 votes |
/** * {@inheritDoc} */ @Override public boolean isWriteable(final Class<?> type, final Type genericType, final Annotation[] annotations, final MediaType mediaType) { String[] p; return !dataViewDisabled && -1 != ListUtils.indexOf(requestProvider.get().getAcceptableMediaTypes(), this::isSupportMediaType) && ((p = TemplateHelper.getProduces(annotations)) == null || -1 != ArrayUtils.indexOf(p, (Predicate<String>) stringType -> { if (stringType.equals(MediaType.WILDCARD)) return true; MediaType mediaType1 = MediaType.valueOf(stringType); return isSupportMediaType(mediaType1); })); }
Example 2
Source File: TargetedContentStoreAdapterDecorator.java From engine with GNU General Public License v3.0 | 4 votes |
protected boolean containsItem(final List<Item> list, final Item item) { int idx = ListUtils.indexOf(list, it -> it.getName().equals(item.getName())); return idx >= 0; }
Example 3
Source File: CollectionsUtil.java From feilong-core with Apache License 2.0 | 2 votes |
/** * 在<code>list</code>中,查找第一个属性 <code>propertyName</code> 值是指定值 <code>propertyValue</code> 对象的索引位置. * * <h3>示例:</h3> * * <blockquote> * * <pre class="code"> * List{@code <User>} list = new ArrayList{@code <>}(); * list.add(new User("张飞", 23)); * list.add(new User("关羽", 24)); * list.add(new User("刘备", 25)); * * CollectionsUtil.indexOf(list, "name", "张飞") = 0 * * CollectionsUtil.indexOf(null, "age", 24) = -1 * CollectionsUtil.indexOf(new ArrayList{@code <User>}(), "age", 24) = -1 * </pre> * * </blockquote> * * <h3>说明:</h3> * <blockquote> * <ol> * <li>常用于 浏览历史记录,当前的商品id是否在历史记录中第一条位置,如果是,可能就不会操作Cookie,诸如此类的操作</li> * </ol> * </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 * 指定属性的属性值 * @return 如果 <code>list</code>是null 或者 empty,返回 -1<br> * 如果指定属性<code>propertyName</code>的值 <code>propertyValue</code>在 list 查找不到,返回 -1<br> * @throws NullPointerException * 如果 <code>propertyName</code> 是null * @throws IllegalArgumentException * 如果 <code>propertyName</code> 是blank * @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)); }