package pl.openrest.filters.predicate.registry;

import java.lang.reflect.Method;
import java.util.Collections;
import java.util.List;

import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;
import pl.openrest.filters.predicate.annotation.Predicate;
import pl.openrest.filters.predicate.annotation.Predicate.PredicateType;
import pl.openrest.filters.query.registry.JoinInformation;

@Getter
@ToString
@EqualsAndHashCode
public class PredicateInformation {

    private final String name;
    private final Method method;
    private final PredicateType type;
    private final boolean defaultedPageable;
    private final List<JoinInformation> joins;

    public PredicateInformation(Method method, Predicate predicateAnn, List<JoinInformation> joins) {
        this.name = predicateAnn.name();
        this.method = method;
        this.type = predicateAnn.type();
        this.defaultedPageable = predicateAnn.defaultedPageable();
        this.joins = joins;
    }

    public PredicateInformation(Method method, Predicate predicateAnn) {
        this(method, predicateAnn, Collections.EMPTY_LIST);
    }

}

@@ -92,27 +92,25 @@
 va.util.
-Collections
+ArrayList
 ;%0Aimport
@@ -338,16 +338,66 @@
 teType;%0A
+import pl.openrest.filters.query.annotation.Join;%0A
 import p
@@ -446,16 +446,82 @@
 rmation;
+%0Aimport pl.openrest.filters.query.registry.JoinInformationBuilder;
 %0A%0A@Gette
@@ -858,35 +858,27 @@
 nn, 
-List%3CJoinInformation%3E joins
+Class%3C?%3E entityType
 ) %7B%0A
@@ -1068,166 +1068,252 @@
     
-this.joins = joins
+List%3CJoinInformation%3E joins = new ArrayList%3C%3E()
 ;%0A    
-%7D%0A%0A
     
-public PredicateInformation(Method method, Predicate predicateAnn) %7B%0A        this(method, predicateAnn, Collections.EMPTY_LIST)
+for (Join join : predicateAnn.joins()) %7B%0A            joins.addAll(JoinInformationBuilder.getJoinsInformation(join.value(), entityType, join.fetch()));%0A        %7D%0A        this.joins = joins
 ;%0A  

Add joinsInformation creation to PredicateInformation constructor