Ignore:
Timestamp:
09/22/22 03:14:04 (2 years ago)
Author:
Marko <Marko@…>
Branches:
master
Children:
436e0da
Parents:
d66b8eb
Message:

Specification filters logic implemented

File:
1 edited

Legend:

Unmodified
Added
Removed
  • phonelux-backend/src/main/java/finki/it/phoneluxbackend/services/PhoneOfferService.java

    rd66b8eb r34950c6  
    231231                .map(cpu -> cpu.split("\n")[0].stripIndent().replaceAll("\n",""))
    232232                .filter(cpu -> !cpu.contains("Snapdragon") && !cpu.contains("Exynos"))
     233                .filter(cpu -> Character.isAlphabetic(cpu.charAt(0)))
    233234                .distinct()
    234235                .sorted()
     
    252253        List<PhoneOffer> offers = phoneOfferRepository.findAll();
    253254
    254         return offers.stream()
     255        List<String> cameras = offers.stream()
    255256                .map(PhoneOffer::getBack_camera)
    256257                .filter(camera -> camera != null && !camera.equals("") && !camera.equals("/"))
    257258                .map(camera -> camera.split("[\n,]")[0].replaceAll("\t",""))
    258                 .distinct()
    259                 .sorted()
    260                 .collect(Collectors.toList());
     259                .flatMap(camera -> Arrays.stream(camera.split("[+/]")))
     260                .map(camera -> camera.replaceAll("MP","").stripIndent())
     261                .distinct()
     262                .sorted()
     263                .collect(Collectors.toList());
     264
     265        cameras.stream()
     266                .forEach(camera -> {
     267                    if(Character.isDigit(camera.charAt(0)))
     268                    cameras.set(cameras.indexOf(camera), camera+"MP");
     269
     270                });
     271
     272        return cameras;
    261273    }
    262274
     
    267279                .map(PhoneOffer::getBattery)
    268280                .filter(battery -> battery != null && !battery.equals("") && !battery.equals("/"))
    269                 .map(battery -> battery.split(",")[0].stripIndent())
     281                .map(battery -> battery.split(",")[0]
     282                        .split("\n")[0]
     283                        .replaceAll("'","")
     284                        .replaceAll("\t"," ")
     285                        .stripIndent())
     286                .map(battery -> battery.replaceAll("battery", "").stripIndent())
    270287                .distinct()
    271288                .sorted(Comparator.reverseOrder())
Note: See TracChangeset for help on using the changeset viewer.