package lan.dk.podcastserver.utils.facade;

import lan.dk.podcastserver.entity.Tag;
import org.apache.commons.lang3.StringUtils;
import org.springframework.data.domain.Sort;

import java.util.ArrayList;
import java.util.List;

import static java.util.Objects.nonNull;

/**
 * Created by kevin on 08/06/2014 for Podcast Server
 */
public class SearchItemPageRequestWrapper extends PageRequestFacade {

    private List<Tag> tags = new ArrayList<>();
    private String term;
    private Boolean downloaded;

    public SearchItemPageRequestWrapper() {
        this.orders.add(new OrderFacade(Sort.Direction.DESC.toString(), "pubdate"));
        this.downloaded = Boolean.TRUE;
    }

    public List<Tag> getTags() {
        return tags;
    }
    public SearchItemPageRequestWrapper setTags(List<Tag> tags) {
        this.tags = tags;
        return this;
    }

    public String getTerm() {
        return term;
    }
    public SearchItemPageRequestWrapper setTerm(String term) {
        this.term = term;
        return this;
    }

    public SearchItemPageRequestWrapper downloaded(Boolean downloaded) {
        this.downloaded = downloaded;
        return this;
    }

    public Boolean getDownloaded() {
        return downloaded;
    }

    public Boolean isSearch() {
        return !StringUtils.isEmpty(term) || !tags.isEmpty() || nonNull(downloaded);
    }
}

@@ -77,16 +77,98 @@
 ty.Tag;%0A
+import lombok.Getter;%0Aimport lombok.Setter;%0Aimport lombok.experimental.Accessors;%0A
 import o
@@ -204,16 +204,16 @@
 gUtils;%0A
-
 import o
@@ -405,16 +405,57 @@
 ver%0A */%0A
+@Getter @Setter%0A@Accessors(chain = true)%0A
 public c
@@ -752,16 +752,16 @@
 ate%22));%0A
+
         
@@ -803,572 +803,8 @@
  %7D%0A%0A
-    public List%3CTag%3E getTags() %7B%0A        return tags;%0A    %7D%0A    public SearchItemPageRequestWrapper setTags(List%3CTag%3E tags) %7B%0A        this.tags = tags;%0A        return this;%0A    %7D%0A%0A    public String getTerm() %7B%0A        return term;%0A    %7D%0A    public SearchItemPageRequestWrapper setTerm(String term) %7B%0A        this.term = term;%0A        return this;%0A    %7D%0A%0A    public SearchItemPageRequestWrapper downloaded(Boolean downloaded) %7B%0A        this.downloaded = downloaded;%0A        return this;%0A    %7D%0A%0A    public Boolean getDownloaded() %7B%0A        return downloaded;%0A    %7D%0A%0A
     

use getter and setter from lombok project to simplify code