ch.lambdaj.Lambda.selectUnique()方法的使用及代码示例

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

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

Lambda.selectUnique介绍

[英]Selects the unique object in the given iterable that matches the given hamcrest Matcher 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 Lambda#forEach(Iterable).
[中]在给定的iterable中选择唯一的对象,该对象与给定的hamcrest Matcher匹配,实际上它还通过收集其值来处理映射、数组和迭代器。请注意,此方法接受一个对象,以便与Lambda#forEach(Iterable)一起使用。

代码示例

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

/**
 * Selects the unique object in this iterable that matches the given hamcrest Matcher
 * @param matcher The hamcrest Matcher used to retain the given iterable
 * @return The only object in the given iterable that matches the given hamcrest Matcher or null if there is no such object
 * @throws RuntimeException if there is more than one object that matches the given hamcrest Matcher
 */
public T unique(Matcher<?> matcher) {
  return (T)Lambda.selectUnique(getInner(), matcher);
}

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

private File getJammJar(File[] cassandraJars) {
  File jammJar = selectUnique(cassandraJars, having(on(File.class).getName(), startsWith("jamm")));
  return jammJar;
}

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

private File getJammJar(File[] cassandraJars) {
  File jammJar = selectUnique(cassandraJars, having(on(File.class).getName(), startsWith("jamm")));
  return jammJar;
}

代码示例来源: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-cassandra

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: 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: kpelykh/docker-java

@Test
public void testDiff() throws DockerException {
  ContainerConfig containerConfig = new ContainerConfig();
  containerConfig.setImage("busybox");
  containerConfig.setCmd(new String[] { "touch", "/test" });
  ContainerCreateResponse container = dockerClient
      .createContainer(containerConfig);
  LOG.info("Created container: {}", container.toString());
  assertThat(container.getId(), not(isEmptyString()));
  dockerClient.startContainer(container.getId());
  boolean add = tmpContainers.add(container.getId());
  int exitCode = dockerClient.waitContainer(container.getId());
  assertThat(exitCode, equalTo(0));
  List filesystemDiff = dockerClient.containerDiff(container.getId());
  LOG.info("Container DIFF: {}", filesystemDiff.toString());
  assertThat(filesystemDiff.size(), equalTo(1));
  ChangeLog testChangeLog = selectUnique(filesystemDiff,
      hasField("path", equalTo("/test")));
  assertThat(testChangeLog, hasField("path", equalTo("/test")));
  assertThat(testChangeLog, hasField("kind", equalTo(1)));
}

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

public static Person createPerson(MRSPerson person, List<PersonAttributeType> allPersonAttributeTypes) {
  Person converted = new Person();
  if (person.getDateOfBirth() != null) {
    converted.setBirthdate(person.getDateOfBirth().toDate());
  }
  if (person.getDeathDate() != null) {
    converted.setDeathDate(person.getDeathDate().toDate());
  }
  converted.setBirthdateEstimated((Boolean) ObjectUtils.defaultIfNull(person.getBirthDateEstimated(), false));
  converted.setDead(person.isDead());
  converted.setGender(person.getGender());
  converted.addName(new PersonName(person.getFirstName(), person.getMiddleName(), person.getLastName()));
  if (person.getAddress() != null) {
    PersonAddress personAddress = new PersonAddress();
    personAddress.setAddress1(person.getAddress());
    converted.addAddress(personAddress);
  }
  for (MRSAttribute attribute : person.getAttributes()) {
    PersonAttributeType attributeType = (PersonAttributeType) selectUnique(allPersonAttributeTypes,
        having(on(PersonAttributeType.class).getName(), equalTo(attribute.getName())));
    converted.addAttribute(new PersonAttribute(attributeType, attribute.getValue()));
  }
  return converted;
}

相关文章