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

package ch.randelshofer.fastdoubleparser.bte;

import java.nio.charset.StandardCharsets;
import java.util.Set;

final class ByteTrieOfOneSingleByte implements ByteTrie
{
    private final byte ch;
    
    public ByteTrieOfOneSingleByte(final Set<String> set) {
        if (set.size() != 1) {
            throw new IllegalArgumentException("set size must be 1, size=" + set.size());
        }
        final byte[] chars = set.iterator().next().getBytes(StandardCharsets.UTF_8);
        if (chars.length != 1) {
            throw new IllegalArgumentException("char size must be 1, size=" + set.size());
        }
        this.ch = chars[0];
    }
    
    public ByteTrieOfOneSingleByte(final byte ch) {
        this.ch = ch;
    }
    
    @Override
    public int match(final byte[] str) {
        return this.match(str, 0, str.length);
    }
    
    @Override
    public int match(final byte[] str, final int startIndex, final int endIndex) {
        return (startIndex < endIndex && str[startIndex] == this.ch) ? 1 : 0;
    }
}
