package com.kyleduo.rabbits;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;

/**
 * Config object for Rabbits
 * Created by kyleduo on 2017/5/10.
 */

@SuppressWarnings("WeakerAccess")
public final class RabbitConfig {
    private List<String> mSchemes;
    private List<String> mDomains;
    private boolean mDebug;

    public static RabbitConfig get() {
        return new RabbitConfig();
    }

    public RabbitConfig schemes(String... schemes) {
        mSchemes = new ArrayList<>(new HashSet<>(Arrays.asList(schemes)));
        return this;
    }

    public RabbitConfig domains(String... domains) {
        mDomains = new ArrayList<>(new HashSet<>(Arrays.asList(domains)));
        return this;
    }

    public RabbitConfig debug(boolean debug) {
        mDebug = debug;
        return this;
    }

    public boolean valid() {
        return mSchemes != null && mSchemes.size() > 0 && mDomains != null && mDomains.size() > 0;
    }

    public List<String> getSchemes() {
        return mSchemes;
    }

    public List<String> getDomains() {
        return mDomains;
    }

    public boolean isDebug() {
        return mDebug;
    }
}

@@ -55,59 +55,8 @@
 st;%0A
-import java.util.Arrays;%0Aimport java.util.HashSet;%0A
 impo
@@ -246,24 +246,44 @@
 ng%3E mSchemes
+ = new ArrayList%3C%3E()
 ;%0A    privat
@@ -301,24 +301,44 @@
 ng%3E mDomains
+ = new ArrayList%3C%3E()
 ;%0A    privat
@@ -510,66 +510,226 @@
 emes
- = new ArrayList%3C%3E(new HashSet%3C%3E(Arrays.asList
+.clear();%0A        if (schemes != null) %7B%0A            for (String scheme : schemes) %7B%0A                if (!mSchemes.contains
 (scheme
-s
 ))
-);
+ %7B%0A                    mSchemes.add(scheme);%0A                %7D%0A            %7D%0A        %7D
 %0A   
@@ -826,66 +826,226 @@
 ains
- = new ArrayList%3C%3E(new HashSet%3C%3E(Arrays.asList
+.clear();%0A        if (domains != null) %7B%0A            for (String domain : domains) %7B%0A                if (!mDomains.contains
 (domain
-s
 ))
-);
+ %7B%0A                    mDomains.add(domain);%0A                %7D%0A            %7D%0A        %7D
 %0A   

fix config disorder