// 
// Decompiled by Procyon v0.6.0
// 

package ch.randelshofer.fastdoubleparser;

import java.util.HashSet;
import java.util.Arrays;
import java.util.Collections;
import java.text.DecimalFormatSymbols;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.Collection;
import java.util.Objects;
import java.util.List;
import java.util.Set;

public final class NumberFormatSymbols
{
    private final Set<Character> decimalSeparator;
    private final Set<Character> groupingSeparator;
    private final Set<String> exponentSeparator;
    private final Set<Character> minusSign;
    private final Set<Character> plusSign;
    private final Set<String> infinity;
    private final Set<String> nan;
    private final List<Character> digits;
    
    public NumberFormatSymbols(final Set<Character> decimalSeparator, final Set<Character> groupingSeparator, final Set<String> exponentSeparator, final Set<Character> minusSign, final Set<Character> plusSign, final Set<String> infinity, final Set<String> nan, final List<Character> digits) {
        if (Objects.requireNonNull(digits, "digits").size() != 10) {
            throw new IllegalArgumentException("digits list must have size 10");
        }
        this.decimalSeparator = new LinkedHashSet<Character>(Objects.requireNonNull(decimalSeparator, "decimalSeparator"));
        this.groupingSeparator = new LinkedHashSet<Character>(Objects.requireNonNull(groupingSeparator, "groupingSeparator"));
        this.exponentSeparator = new LinkedHashSet<String>(Objects.requireNonNull(exponentSeparator, "exponentSeparator"));
        this.minusSign = new LinkedHashSet<Character>(Objects.requireNonNull(minusSign, "minusSign"));
        this.plusSign = new LinkedHashSet<Character>(Objects.requireNonNull(plusSign, "plusSign"));
        this.infinity = new LinkedHashSet<String>(Objects.requireNonNull(infinity, "infinity"));
        this.nan = new LinkedHashSet<String>(Objects.requireNonNull(nan, "nan"));
        this.digits = new ArrayList<Character>(digits);
    }
    
    public NumberFormatSymbols(final String decimalSeparators, final String groupingSeparators, final Collection<String> exponentSeparators, final String minusSigns, final String plusSigns, final Collection<String> infinity, final Collection<String> nan, final String digits) {
        this(toSet(decimalSeparators), toSet(groupingSeparators), new LinkedHashSet<String>(exponentSeparators), toSet(minusSigns), toSet(plusSigns), new LinkedHashSet<String>(infinity), new LinkedHashSet<String>(nan), toList(expandDigits(digits)));
    }
    
    private static String expandDigits(final String digits) {
        if (digits.length() == 10) {
            return digits;
        }
        if (digits.length() != 1) {
            throw new IllegalArgumentException("digits must have length 1 or 10, digits=\"" + digits + "\"");
        }
        final StringBuilder buf = new StringBuilder(10);
        final char zeroChar = digits.charAt(0);
        for (int i = 0; i < 10; ++i) {
            buf.append((char)(zeroChar + i));
        }
        return buf.toString();
    }
    
    public static NumberFormatSymbols fromDecimalFormatSymbols(final DecimalFormatSymbols symbols) {
        final List<Character> digits = new ArrayList<Character>(10);
        final char zeroDigit = symbols.getZeroDigit();
        for (int i = 0; i < 10; ++i) {
            digits.add((char)(zeroDigit + i));
        }
        return new NumberFormatSymbols(Collections.singleton(symbols.getDecimalSeparator()), Collections.singleton(symbols.getGroupingSeparator()), Collections.singleton(symbols.getExponentSeparator()), Collections.singleton(symbols.getMinusSign()), Collections.emptySet(), Collections.singleton(symbols.getInfinity()), Collections.singleton(symbols.getNaN()), digits);
    }
    
    public static NumberFormatSymbols fromDefault() {
        return new NumberFormatSymbols(Collections.singleton('.'), Collections.emptySet(), new HashSet<String>(Arrays.asList("e", "E")), Collections.singleton('-'), Collections.singleton('+'), Collections.singleton("Infinity"), Collections.singleton("NaN"), Arrays.asList('0', '1', '2', '3', '4', '5', '6', '7', '8', '9'));
    }
    
    private static List<Character> toList(final String chars) {
        final List<Character> set = new ArrayList<Character>(10);
        for (final char ch : chars.toCharArray()) {
            set.add(ch);
        }
        return set;
    }
    
    private static Set<Character> toSet(final String chars) {
        final Set<Character> set = new LinkedHashSet<Character>(chars.length() * 2);
        for (final char ch : chars.toCharArray()) {
            set.add(ch);
        }
        return set;
    }
    
    public Set<Character> decimalSeparator() {
        return this.decimalSeparator;
    }
    
    public List<Character> digits() {
        return this.digits;
    }
    
    @Override
    public boolean equals(final Object obj) {
        if (obj == this) {
            return true;
        }
        if (obj == null || obj.getClass() != this.getClass()) {
            return false;
        }
        final NumberFormatSymbols that = (NumberFormatSymbols)obj;
        return Objects.equals(this.decimalSeparator, that.decimalSeparator) && Objects.equals(this.groupingSeparator, that.groupingSeparator) && Objects.equals(this.exponentSeparator, that.exponentSeparator) && Objects.equals(this.minusSign, that.minusSign) && Objects.equals(this.plusSign, that.plusSign) && Objects.equals(this.infinity, that.infinity) && Objects.equals(this.nan, that.nan) && Objects.equals(this.digits, that.digits);
    }
    
    public Set<String> exponentSeparator() {
        return this.exponentSeparator;
    }
    
    public Set<Character> groupingSeparator() {
        return this.groupingSeparator;
    }
    
    @Override
    public int hashCode() {
        return Objects.hash(this.decimalSeparator, this.groupingSeparator, this.exponentSeparator, this.minusSign, this.plusSign, this.infinity, this.nan, this.digits);
    }
    
    public Set<String> infinity() {
        return this.infinity;
    }
    
    public Set<Character> minusSign() {
        return this.minusSign;
    }
    
    public Set<String> nan() {
        return this.nan;
    }
    
    public Set<Character> plusSign() {
        return this.plusSign;
    }
    
    @Override
    public String toString() {
        return "NumberFormatSymbols[decimalSeparator=" + this.decimalSeparator + ", groupingSeparator=" + this.groupingSeparator + ", exponentSeparator=" + this.exponentSeparator + ", minusSign=" + this.minusSign + ", plusSign=" + this.plusSign + ", infinity=" + this.infinity + ", nan=" + this.nan + ", digits=" + this.digits + ']';
    }
    
    public NumberFormatSymbols withDecimalSeparator(final Set<Character> newValue) {
        return new NumberFormatSymbols(newValue, this.groupingSeparator, this.exponentSeparator, this.minusSign, this.plusSign, this.infinity, this.nan, this.digits);
    }
    
    public NumberFormatSymbols withDigits(final List<Character> newValue) {
        return new NumberFormatSymbols(this.decimalSeparator, this.groupingSeparator, this.exponentSeparator, this.minusSign, this.plusSign, this.infinity, this.nan, newValue);
    }
    
    public NumberFormatSymbols withExponentSeparator(final Set<String> newValue) {
        return new NumberFormatSymbols(this.decimalSeparator, this.groupingSeparator, newValue, this.minusSign, this.plusSign, this.infinity, this.nan, this.digits);
    }
    
    public NumberFormatSymbols withGroupingSeparator(final Set<Character> newValue) {
        return new NumberFormatSymbols(this.decimalSeparator, newValue, this.exponentSeparator, this.minusSign, this.plusSign, this.infinity, this.nan, this.digits);
    }
    
    public NumberFormatSymbols withInfinity(final Set<String> newValue) {
        return new NumberFormatSymbols(this.decimalSeparator, this.groupingSeparator, this.exponentSeparator, this.minusSign, this.plusSign, newValue, this.nan, this.digits);
    }
    
    public NumberFormatSymbols withMinusSign(final Set<Character> newValue) {
        return new NumberFormatSymbols(this.decimalSeparator, this.groupingSeparator, this.exponentSeparator, newValue, this.plusSign, this.infinity, this.nan, this.digits);
    }
    
    public NumberFormatSymbols withNaN(final Set<String> newValue) {
        return new NumberFormatSymbols(this.decimalSeparator, this.groupingSeparator, this.exponentSeparator, this.minusSign, this.plusSign, this.infinity, newValue, this.digits);
    }
    
    public NumberFormatSymbols withPlusSign(final Set<Character> newValue) {
        return new NumberFormatSymbols(this.decimalSeparator, this.groupingSeparator, this.exponentSeparator, this.minusSign, newValue, this.infinity, this.nan, this.digits);
    }
}
