package es.sandwatch.trim;

import java.util.HashMap;
import java.util.Map;


/**
 * Represents an API endpoint.
 *
 * @author Ismael Alonso
 * @version 1.0.0
 */
public class Endpoint{
    private String url;
    private Class model;
    private Map<String, String> headers;


    /**
     * Creates an endpoint without endpoint-specific headers.
     *
     * @param url the endpoint url.
     * @param model the model associated to the endpoint.
     */
    public Endpoint(String url, Class model){
        this.url = url;
        this.model = model;
        this.headers = new HashMap<>();
    }

    /**
     * Creates an endpoint with endpoint-specific headers.
     *
     * @param url the url of the endpoint.
     * @param model the model associated to the endpoint.
     * @param headers the additional headers this endpoint should be queried with.
     */
    public Endpoint(String url, Class model, Map<String, String> headers){
        this.url = url;
        this.model = model;
        this.headers = headers;
    }

    /**
     * Adds a header to this endpoint if the endpoint doesn't already have it.
     *
     * @param header the header to be added.
     * @param value the value of the header to be added.
     * @return this Endpoint.
     */
    Endpoint addHeader(String header, String value){
        if (!headers.containsKey(header)){
            headers.put(header, value);
        }
        return this;
    }

    /**
     * Url getter.
     *
     * @return the endpoint's url.
     */
    String getUrl(){
        return url;
    }

    /**
     * Model getter.
     *
     * @return the model associated to the endpoint.
     */
    Class getModel(){
        return model;
    }

    /**
     * Headers getter.
     *
     * @return the endpoint's additional headers.
     */
    Map<String, String> getHeaders(){
        return headers;
    }

    @Override
    public String toString(){
        return model.getName() + " -> " + url;
    }
}

@@ -21,16 +21,59 @@
 .trim;%0A%0A
+import org.jetbrains.annotations.NotNull;%0A%0A
 import j
@@ -90,16 +90,16 @@
 ashMap;%0A
-
 import j
@@ -505,32 +505,41 @@
 public Endpoint(
+@NotNull 
 String url, Clas
@@ -525,32 +525,41 @@
 Null String url,
+ @NotNull
  Class model)%7B%0A 
@@ -573,70 +573,20 @@
 this
-.url = url;%0A        this.model = model;%0A        this.headers =
+(url, model,
  new
@@ -597,16 +597,17 @@
 hMap%3C%3E()
+)
 ;%0A    %7D%0A
@@ -893,16 +893,25 @@
 ndpoint(
+@NotNull 
 String u
@@ -913,16 +913,25 @@
 ing url,
+ @NotNull
  Class m
@@ -935,16 +935,25 @@
 s model,
+ @NotNull
  Map%3CStr
@@ -1304,16 +1304,25 @@
  */%0A    
+@NotNull 
 Endpoint
@@ -1332,16 +1332,25 @@
 dHeader(
+@NotNull 
 String h
@@ -1355,16 +1355,25 @@
  header,
+ @NotNull
  String 
@@ -1582,16 +1582,25 @@
  */%0A    
+@NotNull 
 String g
@@ -1736,16 +1736,25 @@
  */%0A    
+@NotNull 
 Class ge
@@ -1888,20 +1888,29 @@
      */%0A
-
     
+@NotNull 
 Map%3CStri

Annotate Endpoint class