package com.rollbar.payload.data;

import com.rollbar.payload.utilities.Extensible;

import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;

public class Server extends Extensible<Server> {
    public static final String HOST_KEY = "host";
    public static final String ROOT_KEY = "root";
    public static final String BRANCH_KEY = "branch";
    public static final String CODE_VERSION_KEY = "code_version";

    @Override
    protected Set<String> getKnownMembers() {
        Set<String> result = new HashSet<String>(4);
        Collections.addAll(result, HOST_KEY, ROOT_KEY, BRANCH_KEY, CODE_VERSION_KEY);
        return result;
    }

    @Override
    public Server copy() {
        return new Server(members);
    }

    private Server(HashMap<String, Object> members) {
        super(members);
    }

    public Server() {
        this(null, null, null, null, null);
    }

    public Server(String host, String root, String branch, String codeVersion) {
        this(host, root, branch, codeVersion, new HashMap<String, Object>());
    }

    public Server(String host, String root, String branch, String codeVersion, HashMap<String, Object> members) {
        super(members);
        this.members.put(HOST_KEY, host);
        this.members.put(ROOT_KEY, root);
        this.members.put(BRANCH_KEY, branch);
        this.members.put(CODE_VERSION_KEY, codeVersion);
    }

    public String host() {
        return (String) get(HOST_KEY);
    }

    public Server host(String host) {
        return new Server(host, root(), branch(), codeVersion(), members);
    }

    public String root() {
        return (String) get(ROOT_KEY);
    }

    public Server root(String root) {
        return new Server(host(), root, branch(), codeVersion(), members);
    }

    public String branch() {
        return (String) get(BRANCH_KEY);
    }

    public Server branch(String branch) {
        return new Server(host(), root(), branch, codeVersion(), members);
    }

    public String codeVersion() {
        return (String) get(CODE_VERSION_KEY);
    }

    public Server codeVersion(String codeVersion) {
        return new Server(host(), root(), branch(), codeVersion, members);
    }
}

@@ -183,16 +183,72 @@
 l.Set;%0A%0A
+/**%0A * Represents the server object sent to Rollbar%0A */%0A
 public c
@@ -899,32 +899,87 @@
 embers);%0A    %7D%0A%0A
+    /**%0A     * Constructor for an empty server%0A     */%0A
     public Serve
@@ -1043,169 +1043,682 @@
     
-public Server(String host, String root, String branch, String codeVersion) %7B%0A        this(host, root, branch, codeVersion, new HashMap%3CString, Object%3E());%0A    %7D%0A
+/**%0A     * Constructor%0A     * @param host the host%0A     * @param root the file system root%0A     * @param branch the current source control branch%0A     * @param codeVersion the current source control version (SHA, or name)%0A     */%0A    public Server(String host, String root, String branch, String codeVersion) %7B%0A        this(host, root, branch, codeVersion, new HashMap%3CString, Object%3E());%0A    %7D%0A%0A    /**%0A     * Constructor%0A     * @param host the host%0A     * @param root the file system root%0A     * @param branch the current source control branch%0A     * @param codeVersion the current source control version (SHA, or name)%0A     * @param members the extensible members%0A     */
 %0A   
@@ -2038,32 +2038,102 @@
 ersion);%0A    %7D%0A%0A
+    /**%0A     * The host the code is running on%0A     * @return%0A     */%0A
     public Strin
@@ -2181,32 +2181,171 @@
 ST_KEY);%0A    %7D%0A%0A
+    /**%0A     * Set the host the code is running on.%0A     * @param host the new host%0A     * @return the server with host overridden%0A     */%0A
     public Serve
@@ -2440,32 +2440,72 @@
 embers);%0A    %7D%0A%0A
+    /**%0A     * @return the root%0A     */%0A
     public Strin
@@ -2553,32 +2553,147 @@
 OT_KEY);%0A    %7D%0A%0A
+    /**%0A     * Set the root%0A     * @param root the new host%0A     * @return the server with root overridden%0A     */%0A
     public Serve
@@ -2788,32 +2788,74 @@
 embers);%0A    %7D%0A%0A
+    /**%0A     * @return the branch%0A     */%0A
     public Strin
@@ -2907,32 +2907,153 @@
 CH_KEY);%0A    %7D%0A%0A
+    /**%0A     * Set the branch%0A     * @param branch the new host%0A     * @return the server with branch overridden%0A     */%0A
     public Serve
@@ -3152,32 +3152,80 @@
 embers);%0A    %7D%0A%0A
+    /**%0A     * @return the code version%0A     */%0A
     public Strin
@@ -3292,24 +3292,170 @@
 EY);%0A    %7D%0A%0A
+    /**%0A     * Set the code version%0A     * @param codeVersion the new code version%0A     * @return the server with code version overridden%0A     */%0A
     public S

Document Server