本文整理了Java中ch.lambdaj.Lambda.project()
方法的一些代码示例,展示了Lambda.project()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Lambda.project()
方法的具体详情如下:
包路径:ch.lambdaj.Lambda
类名称:Lambda
方法名:project
[英]Converts the objects in the given iterable in objects of the given target Class. The objects are created by invoking its constructor passing to it the values taken from the object to be converted using the given arguments. 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中的对象。这些对象是通过调用其构造函数来创建的,该构造函数将从要使用给定参数转换的对象中获取的值传递给对象。实际上,它还通过收集映射、数组和迭代器的值来处理它们。请注意,此方法接受一个对象,以便与Lambda#forEach(Iterable)一起使用。
代码示例来源:origin: mariofusco/lambdaj
<V> List<V> doProject(Class<V> targetClass, Object... arguments) {
return Lambda.project(innerIterable, targetClass, arguments);
}
代码示例来源:origin: jtalks-org/jcommune
/**
* Converts branch list into branch dto array.
*
* @param branches branch list
* @return branch dto array
*/
private BranchDto[] convertBranchesListToBranchDtoArray(List<Branch> branches) {
List<BranchDto> dtos = project(branches, BranchDto.class,
on(Branch.class).getId(),
on(Branch.class).getName());
return dtos.toArray(new BranchDto[dtos.size()]);
}
代码示例来源:origin: jtalks-org/jcommune
/**
* Provides all available for move topic sections as a JSON array.
*
* @param currentTopicId id of topic that we want to move
* @return sections list
*/
@RequestMapping(value = "/sections/json/{currentTopicId}", method = RequestMethod.GET)
@ResponseBody
public SectionDto[] sectionList(@PathVariable("currentTopicId") long currentTopicId) {
List<Section> sections = sectionService.getAllAvailableSections(currentTopicId);
List<SectionDto> dtos = project(sections, SectionDto.class,
on(Section.class).getId(),
on(Section.class).getName());
return dtos.toArray(new SectionDto[dtos.size()]);
}
代码示例来源:origin: org.motechproject/motech-openmrs-api
public static OpenMRSPerson openMRSToMRSPerson(Person person) {
Set<PersonName> personNames = person.getNames();
PersonName personName = getFirstName(personNames);
final List<OpenMRSAttribute> attributes = project(person.getAttributes(), OpenMRSAttribute.class,
on(PersonAttribute.class).getAttributeType().toString(), on(PersonAttribute.class).getValue());
List<MRSAttribute> personAttributes = new ArrayList<MRSAttribute>();
personAttributes.addAll(attributes);
OpenMRSPerson mrsPerson = new OpenMRSPerson().firstName(personName.getGivenName()).middleName(personName.getMiddleName())
.lastName(personName.getFamilyName()).birthDateEstimated(person.getBirthdateEstimated()).gender(person.getGender()).age(person.getAge())
.address(getAddress(person)).attributes(personAttributes).dateOfBirth(new DateTime(person.getBirthdate())).dead(person.isDead()).deathDate(new DateTime(person.getDeathDate()));
if (person.getId() != null) {
mrsPerson.id(Integer.toString(person.getId()));
}
return mrsPerson;
}
内容来源于网络,如有侵权,请联系作者删除!