ch.lambdaj.Lambda类的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(9.1k)|赞(0)|评价(0)|浏览(202)

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

Lambda介绍

[英]This class consists exclusively of static methods that allow to use all the core features of the lambdaj library.
[中]这个类只包含允许使用lambdaj库的所有核心特性的静态方法。

代码示例

代码示例来源:origin: lordofthejars/nosql-unit

public ManagedMongoDbLifecycleManager getStartedServer(int port) {
  return selectFirst(
      this.servers,
      having(on(ManagedMongoDbLifecycleManager.class).getPort(),
          is(port)).and(having(on(ManagedMongoDbLifecycleManager.class).isReady(), is(true))));
}

代码示例来源:origin: org.motechproject/motech-mrs-couchdb

public void addDependantObservation(MRSObservation mrsObservation) {
  List<? extends MRSObservation> existingObservationList = Lambda.filter(having(on(CouchObservation.class).getConceptName(), is(equalTo(mrsObservation.getConceptName()))), dependantObservations);
  if (!existingObservationList.isEmpty()) {
    dependantObservations.remove(existingObservationList.get(0));
  }
  dependantObservations.add(convertObservationToCouchObservation(mrsObservation));
}

代码示例来源:origin: org.motechproject/motech-mobileforms-api

public String getMessage() {
    return "Errors:" + join(convert(formErrors, new Converter<FormError, String>() {
      @Override
      public String convert(FormError formError) {
        return formError.getParameter() + "=" + formError.getError();
      }
    }), "\n");
  }
}

代码示例来源:origin: mariofusco/lambdaj

/**
 * Counts the number of occurrencies of the argument's value in the objects of the given iterable
 * Actually it handles also Maps, Arrays and Iterator by collecting their values.
 * Note that this method accepts an Object in order to be used in conjunction with the {@link Lambda#forEach(Iterable)}.
 * @param iterable The iterable of objects' arguments to be counted
 * @param argument An argument defined using the {@link Lambda#on(Class)} method
 * @return A map having as values the number of occurrencies of the corresponding object's argument in the given iterable
 */
public static <A> Map<A, Integer> count(Object iterable, A argument) {
  return count(extract(iterable, argument));
}

代码示例来源:origin: net.thucydides/thucydides-core

/**
 * @return The total number of nested steps in these test outcomes.
 */
public int getStepCount() {
  return sum(extract(outcomes, on(TestOutcome.class).getNestedStepCount())).intValue();
}

代码示例来源:origin: net.thucydides/thucydides-core

@Override
public boolean matches(Object matchee) {
  TestOutcome testOutcome =  (TestOutcome) matchee;
  return exists(testOutcome.getTags(), having(on(TestTag.class), is(expectedTag)));
}

代码示例来源:origin: org.motechproject/motech-openmrs-api

private static PersonName getFirstName(Set<PersonName> names) {
  List<PersonName> personNames = filter(having(on(PersonName.class).isPreferred(), is(false)), names);
  if (CollectionUtils.isEmpty(personNames)) {
    personNames = filter(having(on(PersonName.class).isPreferred(), is(true)), names);
  }
  return (!personNames.isEmpty()) ? personNames.get(0) : null;
}

代码示例来源:origin: CloudSlang/cloud-slang

private LanguageEventData selectByEventType(List<LanguageEventData> data, String eventType) {
  return selectFirst(data, having(on(LanguageEventData.class).getEventType(), equalTo(eventType)));
}

代码示例来源:origin: lordofthejars/nosql-unit

private SelectiveMatcher findSelectiveMatcherByConnectionIdentifier(
    SelectiveMatcher[] selectiveMatchers) {
  return selectFirst(
      selectiveMatchers,
      having(on(SelectiveMatcher.class).identifier(),
          equalTo(identifier)).and(
          having(on(SelectiveMatcher.class).location(),
              notNullValue())));
}

代码示例来源:origin: org.motechproject/motech-alerts-api

@Override
  public List<Alert> filter(List<Alert> alerts, AlertCriteria alertCriteria) {
    return Lambda.filter(having(on(Alert.class).getStatus(), equalTo(alertCriteria.alertStatus())), alerts);
  }
},

代码示例来源:origin: lordofthejars/nosql-unit

private static ColumnFamilyDefinition checkColumnFamilyName(List<ColumnFamilyDefinition> columnFamilyDefinitions,
    ColumnFamilyModel expectedColumnFamilyModel) throws Error {
  ColumnFamilyDefinition columnFamily = selectUnique(columnFamilyDefinitions,
      having(on(ColumnFamilyDefinition.class).getName(), equalTo(expectedColumnFamilyModel.getName())));
  if (columnFamily == null) {
    throw FailureHandler.createFailure("Expected name of column family is %s but was not found.",
        expectedColumnFamilyModel.getName());
  }
  return columnFamily;
}

代码示例来源:origin: com.lordofthejars/nosqlunit-neo4j

@Override
public boolean compare(Neo4jConnectionCallback connection, InputStream dataset) throws NoSqlAssertionError,
    Throwable {
  DataParser dataParser = new DataParser();
  List<Object> expectedObjects = dataParser.readValues(dataset);
  Multimap<Class<?>, Object> expectedGroupByClass = groupByClass(expectedObjects);
  Set<Class<?>> expectedClasses = expectedGroupByClass.keySet();
  for (Class<?> expectedClass : expectedClasses) {
    Collection<Object> expectedObjectsByClass = expectedGroupByClass.get(expectedClass);
    List<Object> insertedObjects = findAndFetchAllEntitiesByClass(neo4jTemplate(connection), expectedClass);
    for (Object expectedObject : expectedObjectsByClass) {
      
      Object selectFirst = selectFirst(insertedObjects, equalTo(expectedObject));
      
      if(selectFirst == null) {
        throw new NoSqlAssertionError(String.format("Object %s is not found in graph.", expectedObject.toString()));
      }
      
    }
    
  }
  return true;
}

代码示例来源:origin: org.motechproject/motech-openmrs-api

private void setPersonAttributes(MRSPatient patient, Patient openMRSPatient,
                   List<PersonAttributeType> allPersonAttributeTypes) {
    MRSPerson mrsPerson = patient.getPerson();
    if (CollectionUtils.isNotEmpty(mrsPerson.getAttributes())) {
      for (MRSAttribute attribute : mrsPerson.getAttributes()) {
        PersonAttributeType attributeType = (PersonAttributeType) selectUnique(allPersonAttributeTypes,
            having(on(PersonAttributeType.class).getName(), equalTo(attribute.getName())));
        openMRSPatient.addAttribute(new PersonAttribute(attributeType, attribute.getValue()));
      }
    }
  }
}

代码示例来源:origin: io.cloudslang/score-orchestrator-impl

private <T extends Serializable> void dispatch(List<? extends Serializable> messages, Class<T> messageClass, Handler<T> handler){
  @SuppressWarnings("unchecked")
  List<T> filteredMessages = (List<T>) filter(Matchers.instanceOf(messageClass), messages);
  if (!messages.isEmpty()){
    handler.handle(filteredMessages);
  }
}

代码示例来源:origin: org.motechproject/motech-alerts-api

@Override
  public List<Alert> filter(List<Alert> alerts, AlertCriteria alertCriteria) {
    List<Alert> greaterThanFromDateAlerts = Lambda.filter(having(on(Alert.class).getDateTimeInMillis(), greaterThanOrEqualTo(alertCriteria.fromDate().getMillis())), alerts);
    return Lambda.filter(having(on(Alert.class).getDateTimeInMillis(), lessThanOrEqualTo(alertCriteria.toDate().getMillis())), greaterThanFromDateAlerts);
  }
};

代码示例来源:origin: net.thucydides/thucydides-core

private List<TestOutcome> outcomesForRelease(List<? extends TestOutcome> outcomes,
                         String releaseName) {
    releaseManager.enrichOutcomesWithReleaseTags(outcomes);
    return (List<TestOutcome>) filter(having(on(TestOutcome.class).getVersions(), hasItem(releaseName)), outcomes);
  }
}

代码示例来源:origin: io.openscore.lang/score-lang-api

@Override
public CompilationArtifact compile(SlangSource source, Set<SlangSource> dependencies) {
  Validate.notNull(source, "Source can not be null");
  Set<SlangSource> dependencySources = new HashSet<>(filter(notNullValue(), dependencies));
  try {
    return compiler.compile(source, dependencySources);
  } catch (Exception e) {
    logger.error("Failed compilation for source : " + source.getName() + " ,Exception is : " + e.getMessage());
    throw new RuntimeException(e);
  }
}

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

public static List<AttributePathHelper> prepareAttributePathHelpers(final List<AttributePathHelper> attributePaths,
                                  final int level) {
  // only relevant attribute paths
  final List<AttributePathHelper> filteredAttributePaths = Lambda.filter(
      Lambda.having(Lambda.on(AttributePathHelper.class).length(), Matchers.greaterThanOrEqualTo(level)), attributePaths);
  if (filteredAttributePaths == null || filteredAttributePaths.isEmpty()) {
    return null;
  }
  // sort
  return Lambda.sort(filteredAttributePaths, Lambda.on(AttributePathHelper.class).length());
}

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

public static List<AttributePathHelper> getNextAttributePathHelpersForLevelRootAttributePath(final List<AttributePathHelper> attributePaths,
                                               final String levelRootAttributePath,
                                               final int level) {
  // only attribute paths for level root attribute path
  final List<AttributePathHelper> levelRootAttributePaths = Lambda.filter(
      Lambda.having(Lambda.on(AttributePathHelper.class).toString(), Matchers.startsWith(levelRootAttributePath)), attributePaths);
  if (levelRootAttributePaths == null || levelRootAttributePaths.isEmpty()) {
    return null;
  }
  // only level attribute paths for next level
  return AttributePathHelperHelper.prepareAttributePathHelpers(levelRootAttributePaths, level + 1);
}

代码示例来源:origin: net.serenity-bdd/core

private void addCustomPropertiesTo(Map<String, String> buildProperties) {
  List<String> sysInfoKeys = filter(startsWith("sysinfo."), environmentVariables.getKeys());
  for(String key : sysInfoKeys) {
    String simplifiedKey = key.replace("sysinfo.", "");
    String expression = environmentVariables.getProperty(key);
    String value = (isGroovyExpression(expression)) ? evaluateGroovyExpression(key, expression) : expression;
    buildProperties.put(humanizedFormOf(simplifiedKey), value);
  }
}

相关文章