use of com.tms.homework.pavelgrigoryev.task16.ironforged.Dwarf in project tms by igor-nasibyants.
the class Streams method real.
public void real() {
Stream<Dwarf> dwarfStream = dwarves.stream().filter(dwarf -> dwarf.getAge() <= 30 && dwarf.getRole() != Role.MELEE_DAMAGE_DEALER).sorted(Comparator.comparing(Dwarf::getLastName));
print(dwarfStream);
Stream<Dwarf> sorted = dwarves.stream().filter(dwarf -> dwarf.getAge() > 40).sorted((o1, o2) -> o2.getAge() - o1.getAge()).limit(4);
print(sorted);
IntSummaryStatistics statistics = dwarves.stream().mapToInt(Dwarf::getAge).summaryStatistics();
System.out.println(statistics);
sep();
}
use of com.tms.homework.pavelgrigoryev.task16.ironforged.Dwarf in project tms by igor-nasibyants.
the class MichaelJackson method toJackson.
public static void toJackson() throws IOException {
Gnome gnome = new Gnome();
gnome.setId(20);
gnome.setName("Shtepsel");
gnome.setAge(48);
ArrayList<Object> stupidList = new ArrayList<>();
stupidList.add(gnome);
stupidList.add(new Dwarf("Brann", "BronzeBeard", 17, 35, Role.MELEE_DAMAGE_DEALER));
stupidList.add(new Tank("T-14", "Армата", 2015, "military", 159644948965.46465));
stupidList.add(new IronMan("Tony Stark", 48, 1, "Money", 1000));
stupidList.add(new User(11, "Lolka", "lolka1576-13.lolka@apple.com", "lolk35aLOL1567"));
stupidList.add(new Houses(6, 99, 13, 70, "Переулок.Святого Антона"));
ObjectMapper mapper = new ObjectMapper();
String stupidListToJson = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(stupidList);
System.out.println(stupidListToJson);
FileWriter fileWriter = new FileWriter("json//MichaelJackson.json");
fileWriter.write(stupidListToJson);
fileWriter.close();
}
Aggregations