[LANG-1626] Correction in Javadoc of some methods. (#673)

1) Found Javadoc examples in ArrayUtils.addFirst() incorrectly refer to add() at 9 places.
2) Basic code format in 3 files from time package.
This commit is contained in:
Kanak Sony 2020-12-11 10:33:30 +05:30 committed by GitHub
parent 55e0776408
commit efbfd2de97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 48 additions and 48 deletions

View File

@ -1099,9 +1099,9 @@ public class ArrayUtils {
* </p> * </p>
* *
* <pre> * <pre>
* ArrayUtils.add(null, true) = [true] * ArrayUtils.addFirst(null, true) = [true]
* ArrayUtils.add([true], false) = [false, true] * ArrayUtils.addFirst([true], false) = [false, true]
* ArrayUtils.add([true, false], true) = [true, true, false] * ArrayUtils.addFirst([true, false], true) = [true, true, false]
* </pre> * </pre>
* *
* @param array the array to "add" the element to, may be {@code null}. * @param array the array to "add" the element to, may be {@code null}.
@ -1128,9 +1128,9 @@ public class ArrayUtils {
* </p> * </p>
* *
* <pre> * <pre>
* ArrayUtils.add(null, 1) = [1] * ArrayUtils.addFirst(null, 1) = [1]
* ArrayUtils.add([1], 0) = [0, 1] * ArrayUtils.addFirst([1], 0) = [0, 1]
* ArrayUtils.add([1, 0], 1) = [1, 1, 0] * ArrayUtils.addFirst([1, 0], 1) = [1, 1, 0]
* </pre> * </pre>
* *
* @param array the array to "add" the element to, may be {@code null}. * @param array the array to "add" the element to, may be {@code null}.
@ -1157,9 +1157,9 @@ public class ArrayUtils {
* </p> * </p>
* *
* <pre> * <pre>
* ArrayUtils.add(null, '1') = ['1'] * ArrayUtils.addFirst(null, '1') = ['1']
* ArrayUtils.add(['1'], '0') = ['0', '1'] * ArrayUtils.addFirst(['1'], '0') = ['0', '1']
* ArrayUtils.add(['1', '0'], '1') = ['1', '1', '0'] * ArrayUtils.addFirst(['1', '0'], '1') = ['1', '1', '0']
* </pre> * </pre>
* *
* @param array the array to "add" the element to, may be {@code null}. * @param array the array to "add" the element to, may be {@code null}.
@ -1186,9 +1186,9 @@ public class ArrayUtils {
* </p> * </p>
* *
* <pre> * <pre>
* ArrayUtils.add(null, 1) = [1] * ArrayUtils.addFirst(null, 1) = [1]
* ArrayUtils.add([1], 0) = [0, 1] * ArrayUtils.addFirst([1], 0) = [0, 1]
* ArrayUtils.add([1, 0], 1) = [1, 1, 0] * ArrayUtils.addFirst([1, 0], 1) = [1, 1, 0]
* </pre> * </pre>
* *
* @param array the array to "add" the element to, may be {@code null}. * @param array the array to "add" the element to, may be {@code null}.
@ -1215,9 +1215,9 @@ public class ArrayUtils {
* </p> * </p>
* *
* <pre> * <pre>
* ArrayUtils.add(null, 1) = [1] * ArrayUtils.addFirst(null, 1) = [1]
* ArrayUtils.add([1], 0) = [0, 1] * ArrayUtils.addFirst([1], 0) = [0, 1]
* ArrayUtils.add([1, 0], 1) = [1, 1, 0] * ArrayUtils.addFirst([1, 0], 1) = [1, 1, 0]
* </pre> * </pre>
* *
* @param array the array to "add" the element to, may be {@code null}. * @param array the array to "add" the element to, may be {@code null}.
@ -1244,9 +1244,9 @@ public class ArrayUtils {
* </p> * </p>
* *
* <pre> * <pre>
* ArrayUtils.add(null, 1) = [1] * ArrayUtils.addFirst(null, 1) = [1]
* ArrayUtils.add([1], 0) = [0, 1] * ArrayUtils.addFirst([1], 0) = [0, 1]
* ArrayUtils.add([1, 0], 1) = [1, 1, 0] * ArrayUtils.addFirst([1, 0], 1) = [1, 1, 0]
* </pre> * </pre>
* *
* @param array the array to "add" the element to, may be {@code null}. * @param array the array to "add" the element to, may be {@code null}.
@ -1273,9 +1273,9 @@ public class ArrayUtils {
* </p> * </p>
* *
* <pre> * <pre>
* ArrayUtils.add(null, 1) = [1] * ArrayUtils.addFirst(null, 1) = [1]
* ArrayUtils.add([1], 0) = [0, 1] * ArrayUtils.addFirst([1], 0) = [0, 1]
* ArrayUtils.add([1, 0], 1) = [1, 1, 0] * ArrayUtils.addFirst([1, 0], 1) = [1, 1, 0]
* </pre> * </pre>
* *
* @param array the array to "add" the element to, may be {@code null}. * @param array the array to "add" the element to, may be {@code null}.
@ -1302,9 +1302,9 @@ public class ArrayUtils {
* </p> * </p>
* *
* <pre> * <pre>
* ArrayUtils.add(null, 1) = [1] * ArrayUtils.addFirst(null, 1) = [1]
* ArrayUtils.add([1], 0) = [0, 1] * ArrayUtils.addFirst([1], 0) = [0, 1]
* ArrayUtils.add([1, 0], 1) = [1, 1, 0] * ArrayUtils.addFirst([1, 0], 1) = [1, 1, 0]
* </pre> * </pre>
* *
* @param array the array to "add" the element to, may be {@code null}. * @param array the array to "add" the element to, may be {@code null}.
@ -1331,11 +1331,11 @@ public class ArrayUtils {
* </p> * </p>
* *
* <pre> * <pre>
* ArrayUtils.add(null, null) = IllegalArgumentException * ArrayUtils.addFirst(null, null) = IllegalArgumentException
* ArrayUtils.add(null, "a") = ["a"] * ArrayUtils.addFirst(null, "a") = ["a"]
* ArrayUtils.add(["a"], null) = [null, "a"] * ArrayUtils.addFirst(["a"], null) = [null, "a"]
* ArrayUtils.add(["a"], "b") = ["b", "a"] * ArrayUtils.addFirst(["a"], "b") = ["b", "a"]
* ArrayUtils.add(["a", "b"], "c") = ["c", "a", "b"] * ArrayUtils.addFirst(["a", "b"], "c") = ["c", "a", "b"]
* </pre> * </pre>
* *
* @param <T> the component type of the array * @param <T> the component type of the array

View File

@ -99,7 +99,7 @@ public class FastDateFormat extends Format implements DateParser, DatePrinter {
*/ */
public static final int SHORT = DateFormat.SHORT; public static final int SHORT = DateFormat.SHORT;
private static final FormatCache<FastDateFormat> cache= new FormatCache<FastDateFormat>() { private static final FormatCache<FastDateFormat> cache = new FormatCache<FastDateFormat>() {
@Override @Override
protected FastDateFormat createInstance(final String pattern, final TimeZone timeZone, final Locale locale) { protected FastDateFormat createInstance(final String pattern, final TimeZone timeZone, final Locale locale) {
return new FastDateFormat(pattern, timeZone, locale); return new FastDateFormat(pattern, timeZone, locale);
@ -395,8 +395,8 @@ public class FastDateFormat extends Format implements DateParser, DatePrinter {
* @throws NullPointerException if pattern, timeZone, or locale is null. * @throws NullPointerException if pattern, timeZone, or locale is null.
*/ */
protected FastDateFormat(final String pattern, final TimeZone timeZone, final Locale locale, final Date centuryStart) { protected FastDateFormat(final String pattern, final TimeZone timeZone, final Locale locale, final Date centuryStart) {
printer= new FastDatePrinter(pattern, timeZone, locale); printer = new FastDatePrinter(pattern, timeZone, locale);
parser= new FastDateParser(pattern, timeZone, locale, centuryStart); parser = new FastDateParser(pattern, timeZone, locale, centuryStart);
} }
// Format methods // Format methods

View File

@ -132,16 +132,16 @@ public class FastDateParser implements DateParser, Serializable {
int centuryStartYear; int centuryStartYear;
if (centuryStart!=null) { if (centuryStart!=null) {
definingCalendar.setTime(centuryStart); definingCalendar.setTime(centuryStart);
centuryStartYear= definingCalendar.get(Calendar.YEAR); centuryStartYear = definingCalendar.get(Calendar.YEAR);
} else if (locale.equals(JAPANESE_IMPERIAL)) { } else if (locale.equals(JAPANESE_IMPERIAL)) {
centuryStartYear= 0; centuryStartYear = 0;
} else { } else {
// from 80 years ago to 20 years from now // from 80 years ago to 20 years from now
definingCalendar.setTime(new Date()); definingCalendar.setTime(new Date());
centuryStartYear= definingCalendar.get(Calendar.YEAR)-80; centuryStartYear = definingCalendar.get(Calendar.YEAR)-80;
} }
century= centuryStartYear / 100 * 100; century = centuryStartYear / 100 * 100;
startYear= centuryStartYear - century; startYear = centuryStartYear - century;
init(definingCalendar); init(definingCalendar);
} }
@ -351,7 +351,7 @@ public class FastDateParser implements DateParser, Serializable {
@Override @Override
public Date parse(final String source) throws ParseException { public Date parse(final String source) throws ParseException {
final ParsePosition pp = new ParsePosition(0); final ParsePosition pp = new ParsePosition(0);
final Date date= parse(source, pp); final Date date = parse(source, pp);
if (date == null) { if (date == null) {
// Add a note re supported date range // Add a note re supported date range
if (locale.equals(JAPANESE_IMPERIAL)) { if (locale.equals(JAPANESE_IMPERIAL)) {
@ -387,7 +387,7 @@ public class FastDateParser implements DateParser, Serializable {
@Override @Override
public Date parse(final String source, final ParsePosition pos) { public Date parse(final String source, final ParsePosition pos) {
// timing tests indicate getting new instance is 19% faster than cloning // timing tests indicate getting new instance is 19% faster than cloning
final Calendar cal= Calendar.getInstance(timeZone, locale); final Calendar cal = Calendar.getInstance(timeZone, locale);
cal.clear(); cal.clear();
return parse(source, pos, cal) ? cal.getTime() : null; return parse(source, pos, cal) ? cal.getTime() : null;

View File

@ -38,7 +38,7 @@ abstract class FormatCache<F extends Format> {
/** /**
* No date or no time. Used in same parameters as DateFormat.SHORT or DateFormat.LONG * No date or no time. Used in same parameters as DateFormat.SHORT or DateFormat.LONG
*/ */
static final int NONE= -1; static final int NONE = -1;
private final ConcurrentMap<MultipartKey, F> cInstanceCache private final ConcurrentMap<MultipartKey, F> cInstanceCache
= new ConcurrentHashMap<>(7); = new ConcurrentHashMap<>(7);
@ -80,11 +80,11 @@ abstract class FormatCache<F extends Format> {
F format = cInstanceCache.get(key); F format = cInstanceCache.get(key);
if (format == null) { if (format == null) {
format = createInstance(pattern, timeZone, locale); format = createInstance(pattern, timeZone, locale);
final F previousValue= cInstanceCache.putIfAbsent(key, format); final F previousValue = cInstanceCache.putIfAbsent(key, format);
if (previousValue != null) { if (previousValue != null) {
// another thread snuck in and did the same work // another thread snuck in and did the same work
// we should return the instance that is in ConcurrentMap // we should return the instance that is in ConcurrentMap
format= previousValue; format = previousValue;
} }
} }
return format; return format;
@ -207,7 +207,7 @@ abstract class FormatCache<F extends Format> {
// even though it doesn't matter if another thread put the pattern // even though it doesn't matter if another thread put the pattern
// it's still good practice to return the String instance that is // it's still good practice to return the String instance that is
// actually in the ConcurrentMap // actually in the ConcurrentMap
pattern= previous; pattern = previous;
} }
} catch (final ClassCastException ex) { } catch (final ClassCastException ex) {
throw new IllegalArgumentException("No date time pattern for locale: " + locale); throw new IllegalArgumentException("No date time pattern for locale: " + locale);
@ -248,14 +248,14 @@ abstract class FormatCache<F extends Format> {
*/ */
@Override @Override
public int hashCode() { public int hashCode() {
if (hashCode==0) { if (hashCode == 0) {
int rc= 0; int rc = 0;
for (final Object key : keys) { for (final Object key : keys) {
if (key!=null) { if (key != null) {
rc= rc*7 + key.hashCode(); rc = rc * 7 + key.hashCode();
} }
} }
hashCode= rc; hashCode = rc;
} }
return hashCode; return hashCode;
} }