Skip to content

Commit

Permalink
Use Checkstyle WhitespaceAfter
Browse files Browse the repository at this point in the history
  • Loading branch information
garydgregory committed May 4, 2024
1 parent 4c63e89 commit d8775a1
Show file tree
Hide file tree
Showing 26 changed files with 123 additions and 121 deletions.
7 changes: 7 additions & 0 deletions .checkstyle
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>

<fileset-config file-format-version="1.2.0" simple-config="true" sync-formatter="false">
<fileset name="all" enabled="true" check-config-name="Google Checks" local="false">
<file-match-pattern match-pattern="." include-pattern="true"/>
</fileset>
</fileset-config>
1 change: 1 addition & 0 deletions src/conf/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@
<property name="separated" value="true"/>
</module>
<module name="WhitespaceAround"/>
<module name="WhitespaceAfter"/>
<module name="TypecastParenPad"/>
<module name="SingleSpaceSeparator"/>
</module>
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/org/apache/commons/validator/Form.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import java.util.List;
import java.util.Map;

import org.apache.commons.collections.FastHashMap;// DEPRECATED
import org.apache.commons.collections.FastHashMap; // DEPRECATED

/**
* <p>
Expand Down Expand Up @@ -213,16 +213,16 @@ protected void process(final Map<String, String> globalConstants, final Map<Stri
return;
}

int n = 0;//we want the fields from its parent first
int n = 0; //we want the fields from its parent first
if (isExtending()) {
final Form parent = forms.get(inherit);
if (parent != null) {
if (!parent.isProcessed()) {
//we want to go all the way up the tree
// we want to go all the way up the tree
parent.process(constants, globalConstants, forms);
}
for (final Field f : parent.getFields()) {
//we want to be able to override any fields we like
// we want to be able to override any fields we like
if (getFieldMap().get(f.getKey()) == null) {
lFields.add(n, f);
getFieldMap().put(f.getKey(), f);
Expand All @@ -232,7 +232,7 @@ protected void process(final Map<String, String> globalConstants, final Map<Stri
}
}
hFields.setFast(true);
//no need to reprocess parent's fields, we iterate from 'n'
// no need to reprocess parent's fields, we iterate from 'n'
for (final Iterator<Field> i = lFields.listIterator(n); i.hasNext(); ) {
final Field f = i.next();
f.process(globalConstants, constants);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@
* // no error
* } else {
* // number of errors for first name
* int errors = ((Integer)results.get("firstName")).intValue();
* int errors = ((Integer) results.get("firstName")).intValue();
* }
* </pre>
* <a id="doc.Usage.pluggableValidator"></a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ protected String format(Object value, final Format formatter) {
return null;
}
if (value instanceof Calendar) {
value = ((Calendar)value).getTime();
value = ((Calendar) value).getTime();
}
return formatter.format(value);
}
Expand All @@ -256,7 +256,7 @@ protected String format(Object value, final Format formatter) {
* @return The value formatted as a <code>String</code>.
*/
public String format(final Object value, final Locale locale, final TimeZone timeZone) {
return format(value, (String)null, locale, timeZone);
return format(value, (String) null, locale, timeZone);
}

/**
Expand All @@ -270,7 +270,7 @@ public String format(final Object value, final Locale locale, final TimeZone tim
*/
@Override
public String format(final Object value, final String pattern, final Locale locale) {
return format(value, pattern, locale, (TimeZone)null);
return format(value, pattern, locale, (TimeZone) null);
}

/**
Expand All @@ -285,11 +285,11 @@ public String format(final Object value, final String pattern, final Locale loca
* @return The value formatted as a <code>String</code>.
*/
public String format(final Object value, final String pattern, final Locale locale, final TimeZone timeZone) {
final DateFormat formatter = (DateFormat)getFormat(pattern, locale);
final DateFormat formatter = (DateFormat) getFormat(pattern, locale);
if (timeZone != null) {
formatter.setTimeZone(timeZone);
} else if (value instanceof Calendar) {
formatter.setTimeZone(((Calendar)value).getTimeZone());
formatter.setTimeZone(((Calendar) value).getTimeZone());
}
return format(value, formatter);
}
Expand All @@ -305,7 +305,7 @@ public String format(final Object value, final String pattern, final Locale loca
* @return The value formatted as a <code>String</code>.
*/
public String format(final Object value, final String pattern, final TimeZone timeZone) {
return format(value, pattern, (Locale)null, timeZone);
return format(value, pattern, (Locale) null, timeZone);
}

/**
Expand All @@ -318,7 +318,7 @@ public String format(final Object value, final String pattern, final TimeZone ti
* @return The value formatted as a <code>String</code>.
*/
public String format(final Object value, final TimeZone timeZone) {
return format(value, (String)null, (Locale)null, timeZone);
return format(value, (String) null, (Locale) null, timeZone);
}

/**
Expand All @@ -329,7 +329,6 @@ public String format(final Object value, final TimeZone timeZone) {
* @return The <code>DateFormat</code> to created.
*/
protected Format getFormat(final Locale locale) {

DateFormat formatter;
if (dateStyle >= 0 && timeStyle >= 0) {
if (locale == null) {
Expand Down Expand Up @@ -370,7 +369,7 @@ protected Format getFormat(final String pattern, final Locale locale) {
DateFormat formatter;
final boolean usePattern = pattern != null && !pattern.isEmpty();
if (!usePattern) {
formatter = (DateFormat)getFormat(locale);
formatter = (DateFormat) getFormat(locale);
} else if (locale == null) {
formatter = new SimpleDateFormat(pattern);
} else {
Expand All @@ -391,7 +390,7 @@ protected Format getFormat(final String pattern, final Locale locale) {
*/
@Override
public boolean isValid(final String value, final String pattern, final Locale locale) {
final Object parsedValue = parse(value, pattern, locale, (TimeZone)null);
final Object parsedValue = parse(value, pattern, locale, (TimeZone) null);
return parsedValue == null ? false : true;
}

Expand All @@ -411,7 +410,7 @@ protected Object parse(String value, final String pattern, final Locale locale,
if (value == null || value.isEmpty()) {
return null;
}
final DateFormat formatter = (DateFormat)getFormat(pattern, locale);
final DateFormat formatter = (DateFormat) getFormat(pattern, locale);
if (timeZone != null) {
formatter.setTimeZone(timeZone);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public AbstractFormatValidator(final boolean strict) {
* @return The value formatted as a <code>String</code>.
*/
public String format(final Object value) {
return format(value, (String)null, (Locale)null);
return format(value, (String) null, (Locale) null);
}

/**
Expand All @@ -79,7 +79,7 @@ protected String format(final Object value, final Format formatter) {
* @return The value formatted as a <code>String</code>.
*/
public String format(final Object value, final Locale locale) {
return format(value, (String)null, locale);
return format(value, (String) null, locale);
}

/**
Expand All @@ -91,7 +91,7 @@ public String format(final Object value, final Locale locale) {
* @return The value formatted as a <code>String</code>.
*/
public String format(final Object value, final String pattern) {
return format(value, pattern, (Locale)null);
return format(value, pattern, (Locale) null);
}

/**
Expand Down Expand Up @@ -147,7 +147,7 @@ public boolean isStrict() {
* @return {@code true} if the value is valid.
*/
public boolean isValid(final String value) {
return isValid(value, (String)null, (Locale)null);
return isValid(value, (String) null, (Locale) null);
}

/**
Expand All @@ -158,7 +158,7 @@ public boolean isValid(final String value) {
* @return {@code true} if the value is valid.
*/
public boolean isValid(final String value, final Locale locale) {
return isValid(value, (String)null, locale);
return isValid(value, (String) null, locale);
}

/**
Expand All @@ -169,7 +169,7 @@ public boolean isValid(final String value, final Locale locale) {
* @return {@code true} if the value is valid.
*/
public boolean isValid(final String value, final String pattern) {
return isValid(value, pattern, (Locale)null);
return isValid(value, pattern, (Locale) null);
}

/**
Expand All @@ -190,21 +190,17 @@ public boolean isValid(final String value, final String pattern) {
* @return The parsed value if valid or {@code null} if invalid.
*/
protected Object parse(final String value, final Format formatter) {

final ParsePosition pos = new ParsePosition(0);
Object parsedValue = formatter.parseObject(value, pos);
if (pos.getErrorIndex() > -1) {
return null;
}

if (isStrict() && pos.getIndex() < value.length()) {
return null;
}

if (parsedValue != null) {
parsedValue = processParsedValue(parsedValue, formatter);
}

return parsedValue;

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,12 @@ public boolean minValue(final BigDecimal value, final double min) {
protected Object processParsedValue(final Object value, final Format formatter) {
BigDecimal decimal;
if (value instanceof Long) {
decimal = BigDecimal.valueOf(((Long)value).longValue());
decimal = BigDecimal.valueOf(((Long) value).longValue());
} else {
decimal = new BigDecimal(value.toString());
}

final int scale = determineScale((NumberFormat)formatter);
final int scale = determineScale((NumberFormat) formatter);
if (scale >= 0) {
decimal = decimal.setScale(scale, BigDecimal.ROUND_DOWN);
}
Expand All @@ -195,7 +195,7 @@ protected Object processParsedValue(final Object value, final Format formatter)
* if invalid.
*/
public BigDecimal validate(final String value) {
return (BigDecimal)parse(value, (String)null, (Locale)null);
return (BigDecimal) parse(value, (String) null, (Locale) null);
}

/**
Expand All @@ -207,7 +207,7 @@ public BigDecimal validate(final String value) {
* @return The parsed <code>BigDecimal</code> if valid or {@code null} if invalid.
*/
public BigDecimal validate(final String value, final Locale locale) {
return (BigDecimal)parse(value, (String)null, locale);
return (BigDecimal) parse(value, (String) null, locale);
}

/**
Expand All @@ -220,7 +220,7 @@ public BigDecimal validate(final String value, final Locale locale) {
* @return The parsed <code>BigDecimal</code> if valid or {@code null} if invalid.
*/
public BigDecimal validate(final String value, final String pattern) {
return (BigDecimal)parse(value, pattern, (Locale)null);
return (BigDecimal) parse(value, pattern, (Locale) null);
}

/**
Expand All @@ -234,6 +234,6 @@ public BigDecimal validate(final String value, final String pattern) {
* @return The parsed <code>BigDecimal</code> if valid or {@code null} if invalid.
*/
public BigDecimal validate(final String value, final String pattern, final Locale locale) {
return (BigDecimal)parse(value, pattern, locale);
return (BigDecimal) parse(value, pattern, locale);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public boolean minValue(final BigInteger value, final long min) {
*/
@Override
protected Object processParsedValue(final Object value, final Format formatter) {
return BigInteger.valueOf(((Number)value).longValue());
return BigInteger.valueOf(((Number) value).longValue());
}

/**
Expand All @@ -167,7 +167,7 @@ protected Object processParsedValue(final Object value, final Format formatter)
* if invalid.
*/
public BigInteger validate(final String value) {
return (BigInteger)parse(value, (String)null, (Locale)null);
return (BigInteger) parse(value, (String) null, (Locale) null);
}

/**
Expand All @@ -179,7 +179,7 @@ public BigInteger validate(final String value) {
* @return The parsed <code>BigInteger</code> if valid or {@code null} if invalid.
*/
public BigInteger validate(final String value, final Locale locale) {
return (BigInteger)parse(value, (String)null, locale);
return (BigInteger) parse(value, (String) null, locale);
}

/**
Expand All @@ -191,7 +191,7 @@ public BigInteger validate(final String value, final Locale locale) {
* @return The parsed <code>BigInteger</code> if valid or {@code null} if invalid.
*/
public BigInteger validate(final String value, final String pattern) {
return (BigInteger)parse(value, pattern, (Locale)null);
return (BigInteger) parse(value, pattern, (Locale) null);
}

/**
Expand All @@ -205,6 +205,6 @@ public BigInteger validate(final String value, final String pattern) {
* @return The parsed <code>BigInteger</code> if valid or {@code null} if invalid.
*/
public BigInteger validate(final String value, final String pattern, final Locale locale) {
return (BigInteger)parse(value, pattern, locale);
return (BigInteger) parse(value, pattern, locale);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,10 @@ protected Object processParsedValue(final Object value, final Format formatter)

// Parsed value will be Long if it fits in a long and is not fractional
if (value instanceof Long) {
final long longValue = ((Long)value).longValue();
final long longValue = ((Long) value).longValue();
if (longValue >= Byte.MIN_VALUE &&
longValue <= Byte.MAX_VALUE) {
return Byte.valueOf((byte)longValue);
return Byte.valueOf((byte) longValue);
}
}
return null;
Expand All @@ -213,7 +213,7 @@ protected Object processParsedValue(final Object value, final Format formatter)
* if invalid.
*/
public Byte validate(final String value) {
return (Byte)parse(value, (String)null, (Locale)null);
return (Byte) parse(value, (String) null, (Locale) null);
}

/**
Expand All @@ -225,7 +225,7 @@ public Byte validate(final String value) {
* @return The parsed <code>Byte</code> if valid or {@code null} if invalid.
*/
public Byte validate(final String value, final Locale locale) {
return (Byte)parse(value, (String)null, locale);
return (Byte) parse(value, (String) null, locale);
}

/**
Expand All @@ -237,7 +237,7 @@ public Byte validate(final String value, final Locale locale) {
* @return The parsed <code>Byte</code> if valid or {@code null} if invalid.
*/
public Byte validate(final String value, final String pattern) {
return (Byte)parse(value, pattern, (Locale)null);
return (Byte) parse(value, pattern, (Locale) null);
}

/**
Expand All @@ -251,7 +251,7 @@ public Byte validate(final String value, final String pattern) {
* @return The parsed <code>Byte</code> if valid or {@code null} if invalid.
*/
public Byte validate(final String value, final String pattern, final Locale locale) {
return (Byte)parse(value, pattern, locale);
return (Byte) parse(value, pattern, locale);
}

}
Loading

0 comments on commit d8775a1

Please sign in to comment.