public void validate()

in c3r-sdk-core/src/main/java/com/amazonaws/c3r/config/Pad.java [65:100]


    public void validate() {
        // If pad doesn't exist (type and length are null), there's nothing to validate
        if (type == null && length == null) {
            return;
        } else if (type == null) {
            throw new C3rIllegalArgumentException("A pad type is required if a pad length is specified but only a pad length was " +
                    "provided.");
        }

        // When a padLength is provided, a valid PadType must be sealed
        switch (type) {
            case NONE:
                if (length != null) {
                    throw new C3rIllegalArgumentException("A pad length was provided with an invalid pad type "
                            + type + ". A pad length is only permitted when the pad type is 'fixed' or 'max'.");
                }
                return;
            case MAX:
            case FIXED:
                if (length == null) {
                    throw new C3rIllegalArgumentException("A pad length must be provided when pad type is not 'none'.");
                } else {
                    if (length < 0 || length > PadUtil.MAX_PAD_BYTES) {
                        throw new C3rIllegalArgumentException(
                                "A pad length of " + length
                                        + " was provided provided for padded column. A pad length "
                                        + "between 0 and " + PadUtil.MAX_PAD_BYTES
                                        + " must be used when pad type is not 'none'.");
                    }
                }
                break;
            default:
                final String badType = type.toString();
                throw new C3rIllegalArgumentException("Unknown padding type " + badType + ".");
        }
    }