org.apache.commons.collections.CollectionUtils.exists()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(9.0k)|赞(0)|评价(0)|浏览(367)

本文整理了Java中org.apache.commons.collections.CollectionUtils.exists()方法的一些代码示例,展示了CollectionUtils.exists()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。CollectionUtils.exists()方法的具体详情如下:
包路径:org.apache.commons.collections.CollectionUtils
类名称:CollectionUtils
方法名:exists

CollectionUtils.exists介绍

[英]Answers true if a predicate is true for at least one element of a collection.

A null collection or predicate returns false.
[中]如果集合中至少有一个元素的谓词为true,则回答true。
null集合或谓词返回false。

代码示例

代码示例来源:origin: BroadleafCommerce/BroadleafCommerce

public boolean hasSpecialFilterValue() {
  // We want values that ARE special
  return CollectionUtils.exists(filterValues, getPredicateForSpecialValues(true));
}

代码示例来源:origin: commons-collections/commons-collections

public void testExists() {
  List list = new ArrayList();
  assertEquals(false, CollectionUtils.exists(null, null));
  assertEquals(false, CollectionUtils.exists(list, null));
  assertEquals(false, CollectionUtils.exists(null, EQUALS_TWO));
  assertEquals(false, CollectionUtils.exists(list, EQUALS_TWO));
  list.add("One");
  list.add("Three");
  list.add("Four");
  assertEquals(false, CollectionUtils.exists(list, EQUALS_TWO));
  list.add("Two");
  assertEquals(true, CollectionUtils.exists(list, EQUALS_TWO));
}

代码示例来源:origin: pentaho/mondrian

@SuppressWarnings("unchecked")
    public boolean evaluate(Object o) {
      return !exists((List<Member>) o, memberInaccessible);
    }};
}

代码示例来源:origin: pentaho/mondrian

private boolean needsFiltering(TupleList tupleList) {
  return tupleList.size() > 0
      && exists(tupleList.get(0), needsFilterPredicate());
}

代码示例来源:origin: org.mule.modules/mule-module-http

private boolean equalsIgnoredProperty(final String outboundProperty)
{
  return CollectionUtils.exists(ignoredProperties, new Predicate()
  {
    @Override
    public boolean evaluate(Object propertyName)
    {
      return outboundProperty.equalsIgnoreCase((String) propertyName);
    }
  });
}

代码示例来源:origin: org.andromda.translationlibraries/andromda-ocl-validation-library

/**
 * Returns true if a predicate is true for at least one element of a collection. <p/>A null collection or predicate
 * returns false.
 * @param collection
 * @param predicate
 * @return CollectionUtils.exists(collection, predicate)
 */
public static boolean exists(
    final Collection collection,
    final Predicate predicate)
{
  return CollectionUtils.exists(collection, predicate);
}

代码示例来源:origin: org.motechproject/motech-platform-server-bundle

private boolean containsConfig(List<ModuleConfig> configuration, final String name) {
  return CollectionUtils.exists(configuration, new Predicate() {
    @Override
    public boolean evaluate(Object object) {
      boolean match = object instanceof ModuleConfig;
      if (match) {
        ModuleConfig config = (ModuleConfig) object;
        match = equalsIgnoreCase(name, config.getName());
      }
      return match;
    }
  });
}

代码示例来源:origin: eBay/YiDB

private boolean evalEq(final List<?> fieldValues, final Object criteriaValue) {
  Predicate eqPre = new Predicate() {
    @Override
    public boolean evaluate(Object object) {
      if (criteriaValue instanceof Long && object instanceof Integer) {
        Long value = Long.valueOf((Integer) object);
        return criteriaValue.equals(value);
      } else {
        return criteriaValue.equals(object);
      }
    }
  };
  return CollectionUtils.exists(fieldValues, eqPre);
}

代码示例来源:origin: eBay/YiDB

private boolean evalNotEq(final List<?> fieldValues, final Object criteriaValue) {
  if (fieldValues == null || fieldValues.isEmpty()) {
    return true;
  }
  
  Predicate notEqPre = new Predicate() {
    @Override
    public boolean evaluate(Object object) {
      if (criteriaValue instanceof Long && object instanceof Integer) {
        Long value = Long.valueOf((Integer) object);
        return !criteriaValue.equals(value);
      } else {
        return !criteriaValue.equals(object);
      }
    }
  };
  return CollectionUtils.exists(fieldValues, notEqPre);
}

代码示例来源:origin: tacitknowledge/flip

/**
 * Determines whether provided <code>list</code> contains item 
 * of a given type <code>klass</code>
 * 
 * @param list {@link List} to process
 * @param klass item type to look for
 * @return <code>true</code> in case there is an existent item of a given type within
 *  provided list, <code>false</code> - otherwise
 */
protected boolean isListHasItemOfType(final List<?> list, final Class<?> klass)
{
  return CollectionUtils.exists(list, InstanceofPredicate.getInstance(klass));
}

代码示例来源:origin: org.jboss.dashboard-builder/dashboard-provider-core

protected Double calculateScalar(Interval interval, DataProperty property, ScalarFunction function) {
  Collection values = interval.getValues(property);
  if (!CollectionUtils.exists(values, NON_NULL_ELEMENTS)) {
    return new Double(0);
  } else {
    double value = function.scalar(values);
    // Check constraints every time an scalar calculation is carried out.
    ProfilerHelper.checkRuntimeConstraints();
    return new Double(value);
  }
}

代码示例来源:origin: org.unitils/unitils-dbunit

public void addColumn(Column column) {
  if (!CollectionUtils.exists(columnNames, new FindColumnPredicate(column.getColumnName()))) {
    boolean added = columns.add(column);
    if (added) {
      columnNames.add(column.getColumnName());
    }
  }
  }

代码示例来源:origin: net.sourceforge.wurfl/wng

public boolean containsStyle(String selector) {
  
  Validate.notEmpty(selector);
  
  return CollectionUtils.exists(styles, new SelectorEqualsPredicate(selector));
}

代码示例来源:origin: org.jboss.dashboard-builder/dashboard-provider-core

protected Double calculateScalar(int column, String functionCode) {
  DataSet dataSet = columnIndex.getDataSetIndex().dataSet;
  List targetValues = new ArrayList();
  List columnValues = dataSet.getValuesAt(column);
  for (Integer targetRow : rows) {
    targetValues.add(columnValues.get(targetRow));
  }
  ScalarFunctionManager scalarFunctionManager = DataProviderServices.lookup().getScalarFunctionManager();
  ScalarFunction function = scalarFunctionManager.getScalarFunctionByCode(functionCode);
  if (!CollectionUtils.exists(targetValues, NON_NULL_ELEMENTS)) {
    return new Double(0);
  } else {
    double value = function.scalar(targetValues);
    return new Double(value);
  }
}

代码示例来源:origin: org.wso2.carbon.appmgt/org.wso2.carbon.appmgt.impl

if(!CollectionUtils.exists(uriTemplates, new Predicate() {
  @Override
  public boolean evaluate(Object o) {

代码示例来源:origin: de.matrixweb.smaller/pipeline

@Deprecated
private boolean validate(final Task task) {
 if (CollectionUtils.exists(
   CollectionUtils.getCardinalityMap(
     CollectionUtils.collect(Arrays.asList(task.getOut()),
       new Transformer() {
        @Override
        public Object transform(final Object input) {
         return FilenameUtils.getExtension(input.toString());
        }
       })).values(), new Predicate() {
    @Override
    public boolean evaluate(final Object object) {
     return ((Integer) object).intValue() > 1;
    }
   })) {
  throw new SmallerException("Each output type must exist only once");
 }
 final String[] processors = task.getProcessor().toLowerCase().split(",");
 boolean cssembedFound = false;
 for (final String processor : processors) {
  if (processor.equals("cssembed")) {
   cssembedFound = true;
  } else if (processor.equals("yuicompressor") && cssembedFound) {
   throw new SmallerException("yuiCompressor must run before cssembed");
  }
 }
 return true;
}

代码示例来源:origin: org.andromda.cartridges/andromda-ejb3-cartridge

CollectionUtils.exists(
    this.getBusinessOperations(),
    new Predicate()
CollectionUtils.exists(
    this.getBusinessOperations(),
    new Predicate()

代码示例来源:origin: org.apache.carbondata/carbondata-bloom

BloomDataMapWriter(String tablePath, String dataMapName, List<CarbonColumn> indexColumns,
  Segment segment, String shardName, SegmentProperties segmentProperties,
  int bloomFilterSize, double bloomFilterFpp, boolean compressBloom)
  throws IOException {
 super(tablePath, dataMapName, indexColumns, segment, shardName, segmentProperties,
   bloomFilterSize, bloomFilterFpp, compressBloom);
 columnarSplitter = segmentProperties.getFixedLengthKeySplitter();
 this.indexCol2MdkIdx = new HashMap<>();
 int idx = 0;
 for (final CarbonDimension dimension : segmentProperties.getDimensions()) {
  if (!dimension.isGlobalDictionaryEncoding() && !dimension.isDirectDictionaryEncoding()) {
   continue;
  }
  boolean isExistInIndex = CollectionUtils.exists(indexColumns, new Predicate() {
   @Override public boolean evaluate(Object object) {
    return ((CarbonColumn) object).getColName().equalsIgnoreCase(dimension.getColName());
   }
  });
  if (isExistInIndex) {
   this.indexCol2MdkIdx.put(dimension.getColName(), idx);
  }
  idx++;
 }
}

代码示例来源:origin: org.apache.maven.archiva/archiva-scheduled

public boolean isProcessingRepositoryTask( String repositoryId )
  throws ArchivaException
{
  List<? extends Task> queue = null;
  try
  {
    queue = repositoryScanningQueue.getQueueSnapshot();
  }
  catch ( TaskQueueException e )
  {
    throw new ArchivaException( "Unable to get repository scanning queue:" + e.getMessage(), e );
  }
  return CollectionUtils.exists( queue, new RepositoryTaskSelectionPredicate( repositoryId ) );
}

代码示例来源:origin: com.atlassian.jira/jira-core

@Override
protected void doValidation()
{
  super.doValidation();
  if (CollectionUtils.exists(issueTypeSchemeManager.getAllSchemes(), new FieldConfigPredicate(getSchemeId(), getName())))
  {
    addError("name", getText("admin.errors.issuetypes.duplicate.name"));
  }
  if ((getSelectedOptions() != null) && (getSelectedOptions().length > 0))
  {
    boolean hasNormalIssueType = false;
    for (int i = 0; i < getSelectedOptions().length; i++)
    {
      final String id = getSelectedOptions()[i];
      final IssueType issueType = constantsManager.getIssueTypeObject(id);
      if (!issueType.isSubTask())
      {
        hasNormalIssueType = true;
        break;
      }
    }
    if (!hasNormalIssueType)
    {
      addErrorMessage(getText("admin.errors.issuetypes.must.select.standard.issue.type"));
    }
  }
}

相关文章