class CheckDigitWeightedMod11Verifier implements CheckDigitVerifier {

    public boolean isValid(String id) {
        int totalWeight = 0;
        int wIndex = 0;
        byte[] digits = id.getBytes();
        for (int i = 0; i < digits.length; i++) {
            byte digit = digits[i];
            if (!Character.isDigit(digit)) {
                return false;
            }
            digit -= 48; // get number value
            int weightToUse = i == digits.length - 1 ? 1 : weights[wIndex];
            totalWeight += digit * weightToUse;
            if (++wIndex >= weights.length) wIndex = 0;
        }

        return totalWeight % 11 == 0;
    }

    private  CheckDigitWeightedMod11Verifier(int[] weights);

}