Browse Source

Esta mal

master
Cristobal Bernal Mayordomo 2 years ago
parent
commit
4af2e505f2
3 changed files with 62 additions and 6 deletions
  1. +4
    -6
      src/main/java/com/cristobalbernal/loladvisor/service/LolQueryService.java
  2. +47
    -0
      src/main/java/com/cristobalbernal/loladvisor/service/LolQueryServices.java
  3. +11
    -0
      src/main/java/com/cristobalbernal/loladvisor/service/LolService.java

+ 4
- 6
src/main/java/com/cristobalbernal/loladvisor/service/LolQueryService.java View File

@ -5,10 +5,8 @@ import com.cristobalbernal.loladvisor.model.Lol;
import java.util.Collection;
public interface LolQueryService {
public Collection<Lol> exec();
public LolQueryService anyGenre(String... genres);
public LolQueryService allGenres(String... genres);
public LolQueryService year(String name);
public LolQueryService betweenYears(String from, String to);
public LolQueryService titleContains(String title);
public LolQueryService exec();
public LolQueryService anyDificultad(String... dificultad);
public LolQueryService anyRol(String... rol);
}

+ 47
- 0
src/main/java/com/cristobalbernal/loladvisor/service/LolQueryServices.java View File

@ -0,0 +1,47 @@
package com.cristobalbernal.loladvisor.service;
import com.cristobalbernal.loladvisor.dao.LolDao;
import com.cristobalbernal.loladvisor.model.Lol;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.function.Predicate;
import java.util.stream.Collectors;
@Service
public class LolQueryServices implements LolQueryService {
private LolDao dao;
private Predicate<Lol> predicate;
public void init(){
predicate = null;
}
@Override
public LolQueryService exec() {
return (LolQueryService) dao.findAll()
.stream()
.filter(predicate)
.collect(Collectors.toList());
}
@Override
public LolQueryService anyDificultad(String... dificultad) {
Predicate<Lol> lolPredicate = (lol -> Arrays.stream(dificultad).anyMatch(lol.getNombre()::contains));
predicate = (predicate == null) ? lolPredicate : predicate.and(lolPredicate);
return this;
}
@Override
public LolQueryService anyRol(String... rol) {
Predicate<Lol> pAllGenres = (lol -> Arrays.stream(rol).allMatch(lol.getRol()::contains));
predicate = (predicate == null) ? pAllGenres : predicate.and(pAllGenres);
return this;
}
}

+ 11
- 0
src/main/java/com/cristobalbernal/loladvisor/service/LolService.java View File

@ -0,0 +1,11 @@
package com.cristobalbernal.loladvisor.service;
import com.cristobalbernal.loladvisor.dao.LolDao;
public class LolService {
LolDao filmDao;
LolQueryService queryService;
}

Loading…
Cancel
Save