CPD Results

The following document contains the results of PMD's CPD 4.2.2.

Duplications

File Project Line
org/mod4j/runtime/validation/BusinessRuleUtils.java mod4j-runtime-common 117
org/mod4j/runtime/validation/MinValueValidator.java mod4j-runtime-common 34
    public void validate(Object target, Errors errors) {

        Long value = null;

        if (errors.getFieldValue(field) instanceof Integer) {
            value = ((Integer) errors.getFieldValue(field)).longValue();
        } else if (errors.getFieldValue(field) instanceof Long) {
            value = ((Long) errors.getFieldValue(field));
        }

        if (value != null) {
            Assert.notNull(value);
            if (value < min) {
                errors.rejectValue(field, "field.value.min", new Long[] { new Long(min), new Long(value) }, field
                        + " should be at least " + min + ", but was " + value);
            }
        }
    }
}

File Project Line
org/mod4j/runtime/validation/MaxValueValidator.java mod4j-runtime-common 27
org/mod4j/runtime/validation/MinValueValidator.java mod4j-runtime-common 27
    }

    @SuppressWarnings("unchecked")
    public boolean supports(Class clazz) {
        return this.clazz.isAssignableFrom(clazz);
    }

    public void validate(Object target, Errors errors) {

        Long value = null;

        if (errors.getFieldValue(field) instanceof Integer) {
            value = ((Integer) errors.getFieldValue(field)).longValue();
        } else if (errors.getFieldValue(field) instanceof Long) {
            value = ((Long) errors.getFieldValue(field));
        }

        if (value != null) {
            Assert.notNull(value);
            if (value < min) {

File Project Line
org/mod4j/dslcommon/generator/helpers/StringHelpers.java mod4j-common 81
org/mod4j/dslcommon/generator/helpers/StringHelpers.java mod4j-common 97
    static public StringBuffer indent(StringBuffer in, int level) {
        StringBuffer result = new StringBuffer();
        String newIndent = "";
        for (int i = 0; i < level; i++) {
            newIndent = newIndent + "\t";
        }
        String temp = in.toString();
        temp = temp.trim(); // remove all whitespace from begin and end
        temp = newIndent + StringHelpers.replaceAllSubstrings(temp, "\n", "\n" + newIndent);
        result.append(temp);
        if (result.charAt(result.length() - 1) == '\t') {
            result.deleteCharAt(result.length() - 1);
        }
        return result;