-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMain.java
43 lines (32 loc) · 1.28 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
package br.com.examples.example2;
import br.com.csvbuilder.CsvBuilder;
import br.com.examples.model.Person;
import br.com.examples.model.SomeRandomClass;
import java.util.ArrayList;
import java.util.List;
public class Main {
public static void main(String[] args) {
List<SomeRandomClass> listOfRandomClass = randomClasses(5);
String csv = new CsvBuilder<SomeRandomClass>()
.forElements(listOfRandomClass)
.column(randomClass -> randomClass.getRandomStringValue())
.column(randomClass -> randomClass.getRandomIntegerValue().toString())
.column(randomClass -> randomClass.getRandomDoubleValue().toString())
.toString();
System.out.println(csv);
}
private static List<SomeRandomClass> randomClasses(Integer size) {
List<SomeRandomClass> people = new ArrayList<>();
for (int i = 0; i < size; i++) {
people.add(radomClass(i));
}
return people;
}
private static SomeRandomClass radomClass(Integer value) {
return SomeRandomClass.builder()
.randomStringValue(value + "_Value")
.randomIntegerValue(value)
.randomDoubleValue(value.doubleValue())
.build();
}
}