Search in sources :

Example 1 with Dwarf

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();
}
Also used : IntStream(java.util.stream.IntStream) Role(com.tms.homework.pavelgrigoryev.task16.ironforged.Role) List(java.util.List) Stream(java.util.stream.Stream) Dwarf(com.tms.homework.pavelgrigoryev.task16.ironforged.Dwarf) Map(java.util.Map) IntSummaryStatistics(java.util.IntSummaryStatistics) Comparator(java.util.Comparator) Collectors(java.util.stream.Collectors) Dwarf(com.tms.homework.pavelgrigoryev.task16.ironforged.Dwarf) IntSummaryStatistics(java.util.IntSummaryStatistics)

Example 2 with Dwarf

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();
}
Also used : User(com.tms.homework.astakhnovich.task17.User) Houses(com.tms.homework.nikitaelenski.task14.Houses) Dwarf(com.tms.homework.pavelgrigoryev.task16.ironforged.Dwarf) FileWriter(java.io.FileWriter) ArrayList(java.util.ArrayList) Gnome(com.tms.homework.pavelgrigoryev.task18.jaxb.Gnome) IronMan(com.tms.homework.han.task18.hero.IronMan) Tank(com.tms.homework.pavelgrigoryev.task6.Tank) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

Dwarf (com.tms.homework.pavelgrigoryev.task16.ironforged.Dwarf)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 User (com.tms.homework.astakhnovich.task17.User)1 IronMan (com.tms.homework.han.task18.hero.IronMan)1 Houses (com.tms.homework.nikitaelenski.task14.Houses)1 Role (com.tms.homework.pavelgrigoryev.task16.ironforged.Role)1 Gnome (com.tms.homework.pavelgrigoryev.task18.jaxb.Gnome)1 Tank (com.tms.homework.pavelgrigoryev.task6.Tank)1 FileWriter (java.io.FileWriter)1 ArrayList (java.util.ArrayList)1 Comparator (java.util.Comparator)1 IntSummaryStatistics (java.util.IntSummaryStatistics)1 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 IntStream (java.util.stream.IntStream)1 Stream (java.util.stream.Stream)1