-
Notifications
You must be signed in to change notification settings - Fork 1
/
Main.java
45 lines (35 loc) · 1.15 KB
/
Main.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package br.com.examples.example3;
import br.com.csvbuilder.CsvBuilder;
import br.com.examples.model.Person;
import java.util.ArrayList;
import java.util.List;
public class Main {
public static void main(String[] args) {
List<Person> people = people(5);
String csv = new CsvBuilder<Person>()
.forElements(people)
.column(Person::getName)
.column(p -> p.getAge().toString())
.column(Person::getAddress)
.column(Person::getCity)
.column(Person::getState)
.toString();
System.out.println(csv);
}
private static List<Person> people(Integer size) {
List<Person> people = new ArrayList<>();
for (int i = 0; i < size; i++) {
people.add(buildPerson(i));
}
return people;
}
private static Person buildPerson(Integer value) {
return Person.builder()
.name("Name" + value)
.age(value)
.address("Address" + value)
.city("City" + value)
.state("State" + 1)
.build();
}
}