From 89cbfa54b041541077b8158b667ee3830a8abe5c Mon Sep 17 00:00:00 2001
From: pascalschumacher There are two ways to add a literal negation character ({@code ^}): Examples using the negation character:
- * Date[] someDates = (Date[])ArrayUtils.subarray(allDates, 2, 5);
+ * Date[] someDates = (Date[]) ArrayUtils.subarray(allDates, 2, 5);
*
*
* @param
*
*
*
- * (1, 0, 0, 0) is converted as follow: '8' (1,0,0,1,1,0,1,0) with srcPos = 3 is converted + * (1, 0, 0, 0) is converted as follow: '8' (1, 0, 0, 1, 1, 0, 1, 0) with srcPos = 3 is converted * to 'D' *
* @@ -407,7 +407,7 @@ public class Conversion { * bit ordering to a hexadecimal digit. * *- * (1, 0, 0, 0) is converted as follow: '8' (1,0,0,0,0,0,0,0, 0,0,0,0,0,1,0,0) is converted + * (1, 0, 0, 0) is converted as follow: '8' (1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0) is converted * to '4' *
* @@ -426,8 +426,8 @@ public class Conversion { * hexadecimal digit. * *- * (1, 0, 0, 0) with srcPos = 0 is converted as follow: '8' (1,0,0,0,0,0,0,0, - * 0,0,0,1,0,1,0,0) with srcPos = 2 is converted to '5' + * (1, 0, 0, 0) with srcPos = 0 is converted as follow: '8' (1, 0, 0, 0, 0, 0, 0, 0, + * 0, 0, 0, 1, 0, 1, 0, 0) with srcPos = 2 is converted to '5' *
* * @param src the binary to convert diff --git a/src/main/java/org/apache/commons/lang3/LocaleUtils.java b/src/main/java/org/apache/commons/lang3/LocaleUtils.java index d5b504327..703b33613 100644 --- a/src/main/java/org/apache/commons/lang3/LocaleUtils.java +++ b/src/main/java/org/apache/commons/lang3/LocaleUtils.java @@ -194,8 +194,8 @@ public class LocaleUtils { * a locale search. * *- * localeLookupList(Locale("fr","CA","xxx")) - * = [Locale("fr","CA","xxx"), Locale("fr","CA"), Locale("fr")] + * localeLookupList(Locale("fr", "CA", "xxx")) + * = [Locale("fr", "CA", "xxx"), Locale("fr", "CA"), Locale("fr")] ** * @param locale the locale to start from @@ -212,7 +212,7 @@ public class LocaleUtils { * *
* localeLookupList(Locale("fr", "CA", "xxx"), Locale("en")) - * = [Locale("fr","CA","xxx"), Locale("fr","CA"), Locale("fr"), Locale("en"] + * = [Locale("fr", "CA", "xxx"), Locale("fr", "CA"), Locale("fr"), Locale("en"] ** *
The result list begins with the most specific locale, then the diff --git a/src/main/java/org/apache/commons/lang3/SerializationUtils.java b/src/main/java/org/apache/commons/lang3/SerializationUtils.java index abe0331c3..8446f5885 100644 --- a/src/main/java/org/apache/commons/lang3/SerializationUtils.java +++ b/src/main/java/org/apache/commons/lang3/SerializationUtils.java @@ -134,7 +134,7 @@ public class SerializationUtils { */ public static void serialize(final Serializable obj, final OutputStream outputStream) { Validate.isTrue(outputStream != null, "The OutputStream must not be null"); - try (ObjectOutputStream out = new ObjectOutputStream(outputStream)){ + try (ObjectOutputStream out = new ObjectOutputStream(outputStream)) { out.writeObject(obj); } catch (final IOException ex) { throw new SerializationException(ex); diff --git a/src/main/java/org/apache/commons/lang3/StringEscapeUtils.java b/src/main/java/org/apache/commons/lang3/StringEscapeUtils.java index ce7eec524..64f1d5ddd 100644 --- a/src/main/java/org/apache/commons/lang3/StringEscapeUtils.java +++ b/src/main/java/org/apache/commons/lang3/StringEscapeUtils.java @@ -260,7 +260,7 @@ public class StringEscapeUtils { @Override public int translate(final CharSequence input, final int index, final Writer out) throws IOException { - if(index != 0) { + if (index != 0) { throw new IllegalStateException("CsvEscaper should never reach the [1] index"); } @@ -393,7 +393,7 @@ public class StringEscapeUtils { @Override public int translate(final CharSequence input, final int index, final Writer out) throws IOException { - if(index != 0) { + if (index != 0) { throw new IllegalStateException("CsvUnescaper should never reach the [1] index"); } diff --git a/src/main/java/org/apache/commons/lang3/StringUtils.java b/src/main/java/org/apache/commons/lang3/StringUtils.java index 12dfcdca7..a21e5a9ab 100644 --- a/src/main/java/org/apache/commons/lang3/StringUtils.java +++ b/src/main/java/org/apache/commons/lang3/StringUtils.java @@ -256,7 +256,7 @@ public class StringUtils { if (ArrayUtils.isEmpty(css)) { return false; } - for (final CharSequence cs : css){ + for (final CharSequence cs : css) { if (isEmpty(cs)) { return true; } @@ -400,7 +400,7 @@ public class StringUtils { if (ArrayUtils.isEmpty(css)) { return false; } - for (final CharSequence cs : css){ + for (final CharSequence cs : css) { if (isBlank(cs)) { return true; } @@ -952,10 +952,10 @@ public class StringUtils { */ // See also Lucene's ASCIIFoldingFilter (Lucene 2.9) that replaces accented characters by their unaccented equivalent (and uncommitted bug fix: https://issues.apache.org/jira/browse/LUCENE-1343?focusedCommentId=12858907&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#action_12858907). public static String stripAccents(final String input) { - if(input == null) { + if (input == null) { return null; } - final Pattern pattern = Pattern.compile("\\p{InCombiningDiacriticalMarks}+");//$NON-NLS-1$ + final Pattern pattern = Pattern.compile("\\p{InCombiningDiacriticalMarks}+"); //$NON-NLS-1$ final StringBuilder decomposed = new StringBuilder(Normalizer.normalize(input, Normalizer.Form.NFD)); convertRemainingAccentCharacters(decomposed); // Note that this doesn't correctly remove ligatures... @@ -1488,9 +1488,9 @@ public class StringUtils { * *
Matches may overlap:
*- * StringUtils.ordinalIndexOf("ababab","aba", 1) = 0 - * StringUtils.ordinalIndexOf("ababab","aba", 2) = 2 - * StringUtils.ordinalIndexOf("ababab","aba", 3) = -1 + * StringUtils.ordinalIndexOf("ababab", "aba", 1) = 0 + * StringUtils.ordinalIndexOf("ababab", "aba", 2) = 2 + * StringUtils.ordinalIndexOf("ababab", "aba", 3) = -1 * * StringUtils.ordinalIndexOf("abababab", "abab", 1) = 0 * StringUtils.ordinalIndexOf("abababab", "abab", 2) = 2 @@ -1530,7 +1530,7 @@ public class StringUtils { * @return the n-th index of the search CharSequence, * {@code -1} ({@code INDEX_NOT_FOUND}) if no match or {@code null} string input */ - // Shared code between ordinalIndexOf(String,String,int) and lastOrdinalIndexOf(String,String,int) + // Shared code between ordinalIndexOf(String, String, int) and lastOrdinalIndexOf(String, String, int) private static int ordinalIndexOf(final CharSequence str, final CharSequence searchStr, final int ordinal, final boolean lastIndex) { if (str == null || searchStr == null || ordinal <= 0) { return INDEX_NOT_FOUND; @@ -2057,13 +2057,13 @@ public class StringUtils { * A {@code null} or zero length search array will return {@code -1}. * ** * @param cs the CharSequence to check, may be null @@ -2138,14 +2138,14 @@ public class StringUtils { * A {@code null} or zero length search array will return {@code false}. * *- * StringUtils.indexOfAny(null, *) = -1 - * StringUtils.indexOfAny("", *) = -1 - * StringUtils.indexOfAny(*, null) = -1 - * StringUtils.indexOfAny(*, []) = -1 - * StringUtils.indexOfAny("zzabyycdxx",['z','a']) = 0 - * StringUtils.indexOfAny("zzabyycdxx",['b','y']) = 3 - * StringUtils.indexOfAny("aba", ['z']) = -1 + * StringUtils.indexOfAny(null, *) = -1 + * StringUtils.indexOfAny("", *) = -1 + * StringUtils.indexOfAny(*, null) = -1 + * StringUtils.indexOfAny(*, []) = -1 + * StringUtils.indexOfAny("zzabyycdxx", ['z', 'a']) = 0 + * StringUtils.indexOfAny("zzabyycdxx", ['b', 'y']) = 3 + * StringUtils.indexOfAny("aba", ['z']) = -1 ** * @param cs the CharSequence to check, may be null @@ -2112,7 +2112,7 @@ public class StringUtils { * StringUtils.indexOfAny(*, "") = -1 * StringUtils.indexOfAny("zzabyycdxx", "za") = 0 * StringUtils.indexOfAny("zzabyycdxx", "by") = 3 - * StringUtils.indexOfAny("aba","z") = -1 + * StringUtils.indexOfAny("aba", "z") = -1 *
- * StringUtils.containsAny(null, *) = false - * StringUtils.containsAny("", *) = false - * StringUtils.containsAny(*, null) = false - * StringUtils.containsAny(*, []) = false - * StringUtils.containsAny("zzabyycdxx",['z','a']) = true - * StringUtils.containsAny("zzabyycdxx",['b','y']) = true - * StringUtils.containsAny("zzabyycdxx",['z','y']) = true - * StringUtils.containsAny("aba", ['z']) = false + * StringUtils.containsAny(null, *) = false + * StringUtils.containsAny("", *) = false + * StringUtils.containsAny(*, null) = false + * StringUtils.containsAny(*, []) = false + * StringUtils.containsAny("zzabyycdxx", ['z', 'a']) = true + * StringUtils.containsAny("zzabyycdxx", ['b', 'y']) = true + * StringUtils.containsAny("zzabyycdxx", ['z', 'y']) = true + * StringUtils.containsAny("aba", ['z']) = false ** * @param cs the CharSequence to check, may be null @@ -2205,7 +2205,7 @@ public class StringUtils { * StringUtils.containsAny("zzabyycdxx", "zy") = true * StringUtils.containsAny("zzabyycdxx", "\tx") = true * StringUtils.containsAny("zzabyycdxx", "$.#yF") = true - * StringUtils.containsAny("aba","z") = false + * StringUtils.containsAny("aba", "z") = false * * * @param cs @@ -2327,7 +2327,7 @@ public class StringUtils { * StringUtils.indexOfAnyBut(*, "") = -1 * StringUtils.indexOfAnyBut("zzabyycdxx", "za") = 3 * StringUtils.indexOfAnyBut("zzabyycdxx", "") = -1 - * StringUtils.indexOfAnyBut("aba","ab") = -1 + * StringUtils.indexOfAnyBut("aba", "ab") = -1 * * * @param seq the CharSequence to check, may be null @@ -2523,16 +2523,16 @@ public class StringUtils { * null. This method uses {@link String#indexOf(String)} if possible. * *
- * StringUtils.indexOfAny(null, *) = -1 - * StringUtils.indexOfAny(*, null) = -1 - * StringUtils.indexOfAny(*, []) = -1 - * StringUtils.indexOfAny("zzabyycdxx", ["ab","cd"]) = 2 - * StringUtils.indexOfAny("zzabyycdxx", ["cd","ab"]) = 2 - * StringUtils.indexOfAny("zzabyycdxx", ["mn","op"]) = -1 - * StringUtils.indexOfAny("zzabyycdxx", ["zab","aby"]) = 1 - * StringUtils.indexOfAny("zzabyycdxx", [""]) = 0 - * StringUtils.indexOfAny("", [""]) = 0 - * StringUtils.indexOfAny("", ["a"]) = -1 + * StringUtils.indexOfAny(null, *) = -1 + * StringUtils.indexOfAny(*, null) = -1 + * StringUtils.indexOfAny(*, []) = -1 + * StringUtils.indexOfAny("zzabyycdxx", ["ab", "cd"]) = 2 + * StringUtils.indexOfAny("zzabyycdxx", ["cd", "ab"]) = 2 + * StringUtils.indexOfAny("zzabyycdxx", ["mn", "op"]) = -1 + * StringUtils.indexOfAny("zzabyycdxx", ["zab", "aby"]) = 1 + * StringUtils.indexOfAny("zzabyycdxx", [""]) = 0 + * StringUtils.indexOfAny("", [""]) = 0 + * StringUtils.indexOfAny("", ["a"]) = -1 ** * @param str the CharSequence to check, may be null @@ -2576,15 +2576,15 @@ public class StringUtils { * if {@code str} is not null. This method uses {@link String#indexOf(String)} if possible * *
- * StringUtils.lastIndexOfAny(null, *) = -1 - * StringUtils.lastIndexOfAny(*, null) = -1 - * StringUtils.lastIndexOfAny(*, []) = -1 - * StringUtils.lastIndexOfAny(*, [null]) = -1 - * StringUtils.lastIndexOfAny("zzabyycdxx", ["ab","cd"]) = 6 - * StringUtils.lastIndexOfAny("zzabyycdxx", ["cd","ab"]) = 6 - * StringUtils.lastIndexOfAny("zzabyycdxx", ["mn","op"]) = -1 - * StringUtils.lastIndexOfAny("zzabyycdxx", ["mn","op"]) = -1 - * StringUtils.lastIndexOfAny("zzabyycdxx", ["mn",""]) = 10 + * StringUtils.lastIndexOfAny(null, *) = -1 + * StringUtils.lastIndexOfAny(*, null) = -1 + * StringUtils.lastIndexOfAny(*, []) = -1 + * StringUtils.lastIndexOfAny(*, [null]) = -1 + * StringUtils.lastIndexOfAny("zzabyycdxx", ["ab", "cd"]) = 6 + * StringUtils.lastIndexOfAny("zzabyycdxx", ["cd", "ab"]) = 6 + * StringUtils.lastIndexOfAny("zzabyycdxx", ["mn", "op"]) = -1 + * StringUtils.lastIndexOfAny("zzabyycdxx", ["mn", "op"]) = -1 + * StringUtils.lastIndexOfAny("zzabyycdxx", ["mn", ""]) = 10 ** * @param str the CharSequence to check, may be null @@ -4910,7 +4910,7 @@ public class StringUtils { if (isEmpty(str) || isEmpty(remove)) { return str; } - if (str.startsWith(remove)){ + if (str.startsWith(remove)) { return str.substring(remove.length()); } return str; @@ -6161,7 +6161,7 @@ public class StringUtils { */ @Deprecated public static String chomp(final String str, final String separator) { - return removeEnd(str,separator); + return removeEnd(str, separator); } // Chopping @@ -6289,7 +6289,7 @@ public class StringUtils { * @since 2.5 */ public static String repeat(final String str, final String separator, final int repeat) { - if(str == null || separator == null) { + if (str == null || separator == null) { return repeat(str, repeat); } // given that repeat(String, int) is quite optimized, better to rely on it than try and splice this into it @@ -8176,8 +8176,8 @@ public class StringUtils { *
* StringUtils.getLevenshteinDistance(null, *) = IllegalArgumentException * StringUtils.getLevenshteinDistance(*, null) = IllegalArgumentException - * StringUtils.getLevenshteinDistance("","") = 0 - * StringUtils.getLevenshteinDistance("","a") = 1 + * StringUtils.getLevenshteinDistance("", "") = 0 + * StringUtils.getLevenshteinDistance("", "a") = 1 * StringUtils.getLevenshteinDistance("aaapppp", "") = 7 * StringUtils.getLevenshteinDistance("frog", "fog") = 1 * StringUtils.getLevenshteinDistance("fly", "ant") = 3 @@ -8268,7 +8268,7 @@ public class StringUtils { * StringUtils.getLevenshteinDistance(null, *, *) = IllegalArgumentException * StringUtils.getLevenshteinDistance(*, null, *) = IllegalArgumentException * StringUtils.getLevenshteinDistance(*, *, -1) = IllegalArgumentException - * StringUtils.getLevenshteinDistance("","", 0) = 0 + * StringUtils.getLevenshteinDistance("", "", 0) = 0 * StringUtils.getLevenshteinDistance("aaapppp", "", 8) = 7 * StringUtils.getLevenshteinDistance("aaapppp", "", 7) = 7 * StringUtils.getLevenshteinDistance("aaapppp", "", 6)) = -1 @@ -8431,8 +8431,8 @@ public class StringUtils { * ** StringUtils.getJaroWinklerDistance(null, null) = IllegalArgumentException - * StringUtils.getJaroWinklerDistance("","") = 0.0 - * StringUtils.getJaroWinklerDistance("","a") = 0.0 + * StringUtils.getJaroWinklerDistance("", "") = 0.0 + * StringUtils.getJaroWinklerDistance("", "a") = 0.0 * StringUtils.getJaroWinklerDistance("aaapppp", "") = 0.0 * StringUtils.getJaroWinklerDistance("frog", "fog") = 0.93 * StringUtils.getJaroWinklerDistance("fly", "ant") = 0.0 diff --git a/src/main/java/org/apache/commons/lang3/ThreadUtils.java b/src/main/java/org/apache/commons/lang3/ThreadUtils.java index caf6fa0d2..16986e0de 100644 --- a/src/main/java/org/apache/commons/lang3/ThreadUtils.java +++ b/src/main/java/org/apache/commons/lang3/ThreadUtils.java @@ -52,7 +52,7 @@ public class ThreadUtils { public static Thread findThreadById(final long threadId, final ThreadGroup threadGroup) { Validate.isTrue(threadGroup != null, "The thread group must not be null"); final Thread thread = findThreadById(threadId); - if(thread != null && threadGroup.equals(thread.getThreadGroup())) { + if (thread != null && threadGroup.equals(thread.getThreadGroup())) { return thread; } return null; @@ -75,7 +75,7 @@ public class ThreadUtils { public static Thread findThreadById(final long threadId, final String threadGroupName) { Validate.isTrue(threadGroupName != null, "The thread group name must not be null"); final Thread thread = findThreadById(threadId); - if(thread != null && thread.getThreadGroup() != null && thread.getThreadGroup().getName().equals(threadGroupName)) { + if (thread != null && thread.getThreadGroup() != null && thread.getThreadGroup().getName().equals(threadGroupName)) { return thread; } return null; @@ -119,13 +119,13 @@ public class ThreadUtils { final CollectionthreadGroups = findThreadGroups(new NamePredicate(threadGroupName)); - if(threadGroups.isEmpty()) { + if (threadGroups.isEmpty()) { return Collections.emptyList(); } final Collection result = new ArrayList<>(); final NamePredicate threadNamePredicate = new NamePredicate(threadName); - for(final ThreadGroup group : threadGroups) { + for (final ThreadGroup group : threadGroups) { result.addAll(findThreads(group, false, threadNamePredicate)); } return Collections.unmodifiableCollection(result); @@ -170,7 +170,7 @@ public class ThreadUtils { */ public static ThreadGroup getSystemThreadGroup() { ThreadGroup threadGroup = Thread.currentThread().getThreadGroup(); - while(threadGroup.getParent() != null) { + while (threadGroup.getParent() != null) { threadGroup = threadGroup.getParent(); } return threadGroup; @@ -431,11 +431,11 @@ public class ThreadUtils { threadGroups = new ThreadGroup[count + (count / 2) + 1]; //slightly grow the array size count = group.enumerate(threadGroups, recurse); //return value of enumerate() must be strictly less than the array size according to javadoc - } while(count >= threadGroups.length); + } while (count >= threadGroups.length); final List result = new ArrayList<>(count); - for(int i = 0; i < count; ++i) { - if(predicate.test(threadGroups[i])) { + for (int i = 0; i < count; ++i) { + if (predicate.test(threadGroups[i])) { result.add(threadGroups[i]); } } diff --git a/src/main/java/org/apache/commons/lang3/builder/ToStringStyle.java b/src/main/java/org/apache/commons/lang3/builder/ToStringStyle.java index d54b19c32..cf8e79af2 100644 --- a/src/main/java/org/apache/commons/lang3/builder/ToStringStyle.java +++ b/src/main/java/org/apache/commons/lang3/builder/ToStringStyle.java @@ -2407,7 +2407,7 @@ public abstract class ToStringStyle implements Serializable { throw new UnsupportedOperationException( "Field names are mandatory when using JsonToStringStyle"); } - if (!isFullDetail(fullDetail)){ + if (!isFullDetail(fullDetail)) { throw new UnsupportedOperationException( "FullDetail must be true when using JsonToStringStyle"); } @@ -2423,7 +2423,7 @@ public abstract class ToStringStyle implements Serializable { throw new UnsupportedOperationException( "Field names are mandatory when using JsonToStringStyle"); } - if (!isFullDetail(fullDetail)){ + if (!isFullDetail(fullDetail)) { throw new UnsupportedOperationException( "FullDetail must be true when using JsonToStringStyle"); } @@ -2439,7 +2439,7 @@ public abstract class ToStringStyle implements Serializable { throw new UnsupportedOperationException( "Field names are mandatory when using JsonToStringStyle"); } - if (!isFullDetail(fullDetail)){ + if (!isFullDetail(fullDetail)) { throw new UnsupportedOperationException( "FullDetail must be true when using JsonToStringStyle"); } @@ -2455,7 +2455,7 @@ public abstract class ToStringStyle implements Serializable { throw new UnsupportedOperationException( "Field names are mandatory when using JsonToStringStyle"); } - if (!isFullDetail(fullDetail)){ + if (!isFullDetail(fullDetail)) { throw new UnsupportedOperationException( "FullDetail must be true when using JsonToStringStyle"); } @@ -2471,7 +2471,7 @@ public abstract class ToStringStyle implements Serializable { throw new UnsupportedOperationException( "Field names are mandatory when using JsonToStringStyle"); } - if (!isFullDetail(fullDetail)){ + if (!isFullDetail(fullDetail)) { throw new UnsupportedOperationException( "FullDetail must be true when using JsonToStringStyle"); } @@ -2487,7 +2487,7 @@ public abstract class ToStringStyle implements Serializable { throw new UnsupportedOperationException( "Field names are mandatory when using JsonToStringStyle"); } - if (!isFullDetail(fullDetail)){ + if (!isFullDetail(fullDetail)) { throw new UnsupportedOperationException( "FullDetail must be true when using JsonToStringStyle"); } @@ -2503,7 +2503,7 @@ public abstract class ToStringStyle implements Serializable { throw new UnsupportedOperationException( "Field names are mandatory when using JsonToStringStyle"); } - if (!isFullDetail(fullDetail)){ + if (!isFullDetail(fullDetail)) { throw new UnsupportedOperationException( "FullDetail must be true when using JsonToStringStyle"); } @@ -2519,7 +2519,7 @@ public abstract class ToStringStyle implements Serializable { throw new UnsupportedOperationException( "Field names are mandatory when using JsonToStringStyle"); } - if (!isFullDetail(fullDetail)){ + if (!isFullDetail(fullDetail)) { throw new UnsupportedOperationException( "FullDetail must be true when using JsonToStringStyle"); } @@ -2535,7 +2535,7 @@ public abstract class ToStringStyle implements Serializable { throw new UnsupportedOperationException( "Field names are mandatory when using JsonToStringStyle"); } - if (!isFullDetail(fullDetail)){ + if (!isFullDetail(fullDetail)) { throw new UnsupportedOperationException( "FullDetail must be true when using JsonToStringStyle"); } @@ -2551,7 +2551,7 @@ public abstract class ToStringStyle implements Serializable { throw new UnsupportedOperationException( "Field names are mandatory when using JsonToStringStyle"); } - if (!isFullDetail(fullDetail)){ + if (!isFullDetail(fullDetail)) { throw new UnsupportedOperationException( "FullDetail must be true when using JsonToStringStyle"); } diff --git a/src/main/java/org/apache/commons/lang3/concurrent/TimedSemaphore.java b/src/main/java/org/apache/commons/lang3/concurrent/TimedSemaphore.java index a3517bdf4..7fce712d1 100644 --- a/src/main/java/org/apache/commons/lang3/concurrent/TimedSemaphore.java +++ b/src/main/java/org/apache/commons/lang3/concurrent/TimedSemaphore.java @@ -65,7 +65,7 @@ import java.util.concurrent.TimeUnit; * // Gather statistics * public void run() { * try { - * while(true) { + * while (true) { * semaphore.acquire(); // limit database load * performQuery(); // issue a query * } diff --git a/src/main/java/org/apache/commons/lang3/exception/ContextedException.java b/src/main/java/org/apache/commons/lang3/exception/ContextedException.java index 4ab95f37c..02b2b225b 100644 --- a/src/main/java/org/apache/commons/lang3/exception/ContextedException.java +++ b/src/main/java/org/apache/commons/lang3/exception/ContextedException.java @@ -231,7 +231,7 @@ public class ContextedException extends Exception implements ExceptionContext { * @return the message, never null */ @Override - public String getMessage(){ + public String getMessage() { return getFormattedExceptionMessage(super.getMessage()); } diff --git a/src/main/java/org/apache/commons/lang3/exception/ContextedRuntimeException.java b/src/main/java/org/apache/commons/lang3/exception/ContextedRuntimeException.java index 9b904fce1..12db259dc 100644 --- a/src/main/java/org/apache/commons/lang3/exception/ContextedRuntimeException.java +++ b/src/main/java/org/apache/commons/lang3/exception/ContextedRuntimeException.java @@ -231,7 +231,7 @@ public class ContextedRuntimeException extends RuntimeException implements Excep * @return the message, never null */ @Override - public String getMessage(){ + public String getMessage() { return getFormattedExceptionMessage(super.getMessage()); } diff --git a/src/main/java/org/apache/commons/lang3/exception/DefaultExceptionContext.java b/src/main/java/org/apache/commons/lang3/exception/DefaultExceptionContext.java index 277c224ab..20a3e1772 100644 --- a/src/main/java/org/apache/commons/lang3/exception/DefaultExceptionContext.java +++ b/src/main/java/org/apache/commons/lang3/exception/DefaultExceptionContext.java @@ -124,7 +124,7 @@ public class DefaultExceptionContext implements ExceptionContext, Serializable { * @return the exception message with context information appended, never null */ @Override - public String getFormattedExceptionMessage(final String baseMessage){ + public String getFormattedExceptionMessage(final String baseMessage) { final StringBuilder buffer = new StringBuilder(256); if (baseMessage != null) { buffer.append(baseMessage); diff --git a/src/main/java/org/apache/commons/lang3/math/IEEE754rUtils.java b/src/main/java/org/apache/commons/lang3/math/IEEE754rUtils.java index 8cd351b50..fea850428 100644 --- a/src/main/java/org/apache/commons/lang3/math/IEEE754rUtils.java +++ b/src/main/java/org/apache/commons/lang3/math/IEEE754rUtils.java @@ -95,10 +95,10 @@ public class IEEE754rUtils { * @return the smallest of the values */ public static double min(final double a, final double b) { - if(Double.isNaN(a)) { + if (Double.isNaN(a)) { return b; } else - if(Double.isNaN(b)) { + if (Double.isNaN(b)) { return a; } else { return Math.min(a, b); @@ -129,10 +129,10 @@ public class IEEE754rUtils { * @return the smallest of the values */ public static float min(final float a, final float b) { - if(Float.isNaN(a)) { + if (Float.isNaN(a)) { return b; } else - if(Float.isNaN(b)) { + if (Float.isNaN(b)) { return a; } else { return Math.min(a, b); @@ -207,10 +207,10 @@ public class IEEE754rUtils { * @return the largest of the values */ public static double max(final double a, final double b) { - if(Double.isNaN(a)) { + if (Double.isNaN(a)) { return b; } else - if(Double.isNaN(b)) { + if (Double.isNaN(b)) { return a; } else { return Math.max(a, b); @@ -241,10 +241,10 @@ public class IEEE754rUtils { * @return the largest of the values */ public static float max(final float a, final float b) { - if(Float.isNaN(a)) { + if (Float.isNaN(a)) { return b; } else - if(Float.isNaN(b)) { + if (Float.isNaN(b)) { return a; } else { return Math.max(a, b); diff --git a/src/main/java/org/apache/commons/lang3/math/NumberUtils.java b/src/main/java/org/apache/commons/lang3/math/NumberUtils.java index 2522acadc..e3efc965c 100644 --- a/src/main/java/org/apache/commons/lang3/math/NumberUtils.java +++ b/src/main/java/org/apache/commons/lang3/math/NumberUtils.java @@ -122,7 +122,7 @@ public class NumberUtils { * @since 2.1 */ public static int toInt(final String str, final int defaultValue) { - if(str == null) { + if (str == null) { return defaultValue; } try { @@ -366,7 +366,7 @@ public class NumberUtils { * @since 2.5 */ public static byte toByte(final String str, final byte defaultValue) { - if(str == null) { + if (str == null) { return defaultValue; } try { @@ -415,7 +415,7 @@ public class NumberUtils { * @since 2.5 */ public static short toShort(final String str, final short defaultValue) { - if(str == null) { + if (str == null) { return defaultValue; } try { @@ -585,33 +585,33 @@ public class NumberUtils { // BigDecimal, BigInteger and Byte // useful methods: // Byte.decode(String) - // Byte.valueOf(String,int radix) + // Byte.valueOf(String, int radix) // Byte.valueOf(String) // Double.valueOf(String) // Float.valueOf(String) // Float.valueOf(String) - // Integer.valueOf(String,int radix) + // Integer.valueOf(String, int radix) // Integer.valueOf(String) // Integer.decode(String) // Integer.getInteger(String) - // Integer.getInteger(String,int val) - // Integer.getInteger(String,Integer val) + // Integer.getInteger(String, int val) + // Integer.getInteger(String, Integer val) // Integer.valueOf(String) // Double.valueOf(String) // new Byte(String) // Long.valueOf(String) // Long.getLong(String) - // Long.getLong(String,int) - // Long.getLong(String,Integer) - // Long.valueOf(String,int) + // Long.getLong(String, int) + // Long.getLong(String, Integer) + // Long.valueOf(String, int) // Long.valueOf(String) // Short.valueOf(String) // Short.decode(String) - // Short.valueOf(String,int) + // Short.valueOf(String, int) // Short.valueOf(String) // new BigDecimal(String) // new BigInteger(String) - // new BigInteger(String,int radix) + // new BigInteger(String, int radix) // Possible inputs: // 45 45.5 45E7 4.5E7 Hex Oct Binary xxxF xxxD xxxf xxxd // plus minus everything. Prolly more. A lot are not separable. @@ -624,7 +624,7 @@ public class NumberUtils { * prefix is more than 8 - or BigInteger if there are more than 16 digits. * * Then, the value is examined for a type qualifier on the end, i.e. one of - *
* @@ -657,7 +657,7 @@ public class NumberUtils { // Need to deal with all possible hex prefixes here final String[] hex_prefixes = {"0x", "0X", "-0x", "-0X", "#", "-#"}; int pfxLen = 0; - for(final String pfx : hex_prefixes) { + for (final String pfx : hex_prefixes) { if (str.startsWith(pfx)) { pfxLen += pfx.length(); break; @@ -665,7 +665,7 @@ public class NumberUtils { } if (pfxLen > 0) { // we have a hex number char firstSigDigit = 0; // strip leading zeroes - for(int i = pfxLen; i < str.length(); i++) { + for (int i = pfxLen; i < str.length(); i++) { firstSigDigit = str.charAt(i); if (firstSigDigit == '0') { // count leading zeroes pfxLen++; diff --git a/src/main/java/org/apache/commons/lang3/package-info.java b/src/main/java/org/apache/commons/lang3/package-info.java index b9f22ba25..9a476fe5c 100644 --- a/src/main/java/org/apache/commons/lang3/package-info.java +++ b/src/main/java/org/apache/commons/lang3/package-info.java @@ -61,7 +61,7 @@ *'f','F','d','D','l','L'
. If it is found, it starts + *'f', 'F', 'd', 'D', 'l', 'L'
. If it is found, it starts * trying to create successively larger types from the type specified * until one is found that can represent the value.SystemUtils is a simple little class which makes it easy to find out information about which platform you are on. * For some, this is a necessary evil. It was never something I expected to use myself until I was trying to ensure that Commons Lang itself compiled under JDK 1.2. * Having pushed out a few JDK 1.3 bits that had slipped in (
+ * There was no obvious solution and I needed to move onwards, so the simple solution was to wrap that particular test in aCollections.EMPTY_MAP
is a classic offender), I then found that one of the Unit Tests was dying mysteriously under JDK 1.2, but ran fine under JDK 1.3. - * There was no obvious solution and I needed to move onwards, so the simple solution was to wrap that particular test in aif(SystemUtils.isJavaVersionAtLeast(1.3f)) {
, make a note and move on.if (SystemUtils.isJavaVersionAtLeast(1.3f)) {
, make a note and move on. * *The {@link org.apache.commons.lang3.CharEncoding} class is also used to interact with the Java environment and may be used to see which character encodings are supported in a particular environment.
* diff --git a/src/main/java/org/apache/commons/lang3/reflect/ConstructorUtils.java b/src/main/java/org/apache/commons/lang3/reflect/ConstructorUtils.java index b6fb70de5..f95af54db 100644 --- a/src/main/java/org/apache/commons/lang3/reflect/ConstructorUtils.java +++ b/src/main/java/org/apache/commons/lang3/reflect/ConstructorUtils.java @@ -271,7 +271,7 @@ public class ConstructorUtils { // temporary variable for annotation, see comment above (1) @SuppressWarnings("unchecked") final - Constructorconstructor = (Constructor )ctor; + Constructor constructor = (Constructor ) ctor; result = constructor; } } diff --git a/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java b/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java index 5874f5942..a9a80316c 100644 --- a/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java +++ b/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java @@ -77,7 +77,7 @@ public class MethodUtils { * This method delegates the method search to {@link #getMatchingAccessibleMethod(Class, String, Class[])}.
* *This is a convenient wrapper for - * {@link #invokeMethod(Object object,String methodName, Object[] args, Class[] parameterTypes)}. + * {@link #invokeMethod(Object object, String methodName, Object[] args, Class[] parameterTypes)}. *
* * @param object invoke method on this object @@ -99,7 +99,7 @@ public class MethodUtils { *Invokes a named method without parameters.
* *This is a convenient wrapper for - * {@link #invokeMethod(Object object,boolean forceAccess,String methodName, Object[] args, Class[] parameterTypes)}. + * {@link #invokeMethod(Object object, boolean forceAccess, String methodName, Object[] args, Class[] parameterTypes)}. *
* * @param object invoke method on this object @@ -128,7 +128,7 @@ public class MethodUtils { * would match a {@code boolean} primitive. * *This is a convenient wrapper for - * {@link #invokeMethod(Object object,String methodName, Object[] args, Class[] parameterTypes)}. + * {@link #invokeMethod(Object object, String methodName, Object[] args, Class[] parameterTypes)}. *
* * @param object invoke method on this object @@ -156,7 +156,7 @@ public class MethodUtils { * would match a {@code boolean} primitive. * *This is a convenient wrapper for - * {@link #invokeMethod(Object object,boolean forceAccess,String methodName, Object[] args, Class[] parameterTypes)}. + * {@link #invokeMethod(Object object, boolean forceAccess, String methodName, Object[] args, Class[] parameterTypes)}. *
* * @param object invoke method on this object @@ -261,7 +261,7 @@ public class MethodUtils { * types. * *This uses reflection to invoke the method obtained from a call to - * {@link #getAccessibleMethod}(Class,String,Class[])}.
+ * {@link #getAccessibleMethod}(Class, String, Class[])}. * * @param object invoke method on this object * @param methodName get method with this name @@ -284,7 +284,7 @@ public class MethodUtils { *Invokes a method with no parameters.
* *This uses reflection to invoke the method obtained from a call to - * {@link #getAccessibleMethod}(Class,String,Class[])}.
+ * {@link #getAccessibleMethod}(Class, String, Class[])}. * * @param object invoke method on this object * @param methodName get method with this name @@ -310,7 +310,7 @@ public class MethodUtils { * types given. * *This uses reflection to invoke the method obtained from a call to - * {@link #getAccessibleMethod(Class,String,Class[])}.
+ * {@link #getAccessibleMethod(Class, String, Class[])}. * * @param object invoke method on this object * @param methodName get method with this name @@ -482,7 +482,7 @@ public class MethodUtils { // Copy the variadic arguments into the varargs array. System.arraycopy(args, methodParameterTypes.length - 1, varArgsArray, 0, varArgLength); - if(varArgComponentType.isPrimitive()) { + if (varArgComponentType.isPrimitive()) { // unbox from wrapper type to primitive type varArgsArray = ArrayUtils.toPrimitive(varArgsArray); } diff --git a/src/main/java/org/apache/commons/lang3/reflect/TypeUtils.java b/src/main/java/org/apache/commons/lang3/reflect/TypeUtils.java index 0ec0fb6bc..640230370 100644 --- a/src/main/java/org/apache/commons/lang3/reflect/TypeUtils.java +++ b/src/main/java/org/apache/commons/lang3/reflect/TypeUtils.java @@ -737,7 +737,7 @@ public class TypeUtils { /** *Retrieves all the type arguments for this parameterized type * including owner hierarchy arguments such as - * {@code Outer
diff --git a/src/main/java/org/apache/commons/lang3/text/ExtendedMessageFormat.java b/src/main/java/org/apache/commons/lang3/text/ExtendedMessageFormat.java index 573b013c4..76f65e6d6 100644 --- a/src/main/java/org/apache/commons/lang3/text/ExtendedMessageFormat.java +++ b/src/main/java/org/apache/commons/lang3/text/ExtendedMessageFormat.java @@ -276,7 +276,7 @@ public class ExtendedMessageFormat extends MessageFormat { if (ObjectUtils.notEqual(getClass(), obj.getClass())) { return false; } - final ExtendedMessageFormat rhs = (ExtendedMessageFormat)obj; + final ExtendedMessageFormat rhs = (ExtendedMessageFormat) obj; if (ObjectUtils.notEqual(toPattern, rhs.toPattern)) { return false; } @@ -478,7 +478,7 @@ public class ExtendedMessageFormat extends MessageFormat { "Quoted string must start with quote character"; // handle quote character at the beginning of the string - if(appendTo != null) { + if (appendTo != null) { appendTo.append(QUOTE); } next(pos); diff --git a/src/main/java/org/apache/commons/lang3/text/StrBuilder.java b/src/main/java/org/apache/commons/lang3/text/StrBuilder.java index d07279dae..262a9d772 100644 --- a/src/main/java/org/apache/commons/lang3/text/StrBuilder.java +++ b/src/main/java/org/apache/commons/lang3/text/StrBuilder.java @@ -1348,11 +1348,11 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build * This method is for example useful for constructing queries *.Inner .DeepInner } . + * {@code Outer .Inner .DeepInner } . * The arguments are returned in a * {@link Map} specifying the argument type for each {@link TypeVariable}. * * StrBuilder whereClause = new StrBuilder(); - * if(searchCommand.getPriority() != null) { + * if (searchCommand.getPriority() != null) { * whereClause.appendSeparator(" and", " where"); * whereClause.append(" priority = ?") * } - * if(searchCommand.getComponent() != null) { + * if (searchCommand.getComponent() != null) { * whereClause.appendSeparator(" and", " where"); * whereClause.append(" component = ?") * } @@ -2145,7 +2145,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build final int half = size / 2; final char[] buf = buffer; - for (int leftIdx = 0, rightIdx = size - 1; leftIdx < half; leftIdx++,rightIdx--) { + for (int leftIdx = 0, rightIdx = size - 1; leftIdx < half; leftIdx++, rightIdx--) { final char swap = buf[leftIdx]; buf[leftIdx] = buf[rightIdx]; buf[rightIdx] = swap; @@ -2230,7 +2230,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build return false; } int pos = size - len; - for (int i = 0; i < len; i++,pos++) { + for (int i = 0; i < len; i++, pos++) { if (buffer[pos] != str.charAt(i)) { return false; } diff --git a/src/main/java/org/apache/commons/lang3/text/StrSubstitutor.java b/src/main/java/org/apache/commons/lang3/text/StrSubstitutor.java index d02418e5e..b8c885ec8 100644 --- a/src/main/java/org/apache/commons/lang3/text/StrSubstitutor.java +++ b/src/main/java/org/apache/commons/lang3/text/StrSubstitutor.java @@ -218,10 +218,10 @@ public class StrSubstitutor { if (valueProperties == null) { return source.toString(); } - final MapvalueMap = new HashMap<>(); + final Map valueMap = new HashMap<>(); final Enumeration> propNames = valueProperties.propertyNames(); while (propNames.hasMoreElements()) { - final String propName = (String)propNames.nextElement(); + final String propName = (String) propNames.nextElement(); final String propValue = valueProperties.getProperty(propName); valueMap.put(propName, propValue); } diff --git a/src/main/java/org/apache/commons/lang3/text/WordUtils.java b/src/main/java/org/apache/commons/lang3/text/WordUtils.java index 3787f3339..f7c420c5b 100644 --- a/src/main/java/org/apache/commons/lang3/text/WordUtils.java +++ b/src/main/java/org/apache/commons/lang3/text/WordUtils.java @@ -292,7 +292,7 @@ public class WordUtils { while (offset < inputLineLength) { int spaceToWrapAt = -1; Matcher matcher = patternToWrapOn.matcher( - str.substring(offset, Math.min((int)Math.min(Integer.MAX_VALUE, offset + wrapLength + 1L), inputLineLength))); + str.substring(offset, Math.min((int) Math.min(Integer.MAX_VALUE, offset + wrapLength + 1L), inputLineLength))); if (matcher.find()) { if (matcher.start() == 0) { offset += matcher.end(); @@ -302,11 +302,11 @@ public class WordUtils { } // only last line without leading spaces is left - if(inputLineLength - offset <= wrapLength) { + if (inputLineLength - offset <= wrapLength) { break; } - while(matcher.find()){ + while (matcher.find()) { spaceToWrapAt = matcher.start() + offset; } diff --git a/src/main/java/org/apache/commons/lang3/text/translate/AggregateTranslator.java b/src/main/java/org/apache/commons/lang3/text/translate/AggregateTranslator.java index 86b22bbcc..a800f4611 100644 --- a/src/main/java/org/apache/commons/lang3/text/translate/AggregateTranslator.java +++ b/src/main/java/org/apache/commons/lang3/text/translate/AggregateTranslator.java @@ -53,7 +53,7 @@ public class AggregateTranslator extends CharSequenceTranslator { public int translate(final CharSequence input, final int index, final Writer out) throws IOException { for (final CharSequenceTranslator translator : translators) { final int consumed = translator.translate(input, index, out); - if(consumed != 0) { + if (consumed != 0) { return consumed; } } diff --git a/src/main/java/org/apache/commons/lang3/text/translate/EntityArrays.java b/src/main/java/org/apache/commons/lang3/text/translate/EntityArrays.java index d4357f6cc..864779e67 100644 --- a/src/main/java/org/apache/commons/lang3/text/translate/EntityArrays.java +++ b/src/main/java/org/apache/commons/lang3/text/translate/EntityArrays.java @@ -163,15 +163,15 @@ public class EntityArrays { // {"\u0391", "Α"}, // greek capital letter alpha, U+0391 --> {"\u0392", "Β"}, // greek capital letter beta, U+0392 --> - {"\u0393", "Γ"}, // greek capital letter gamma,U+0393 ISOgrk3 --> - {"\u0394", "Δ"}, // greek capital letter delta,U+0394 ISOgrk3 --> + {"\u0393", "Γ"}, // greek capital letter gamma, U+0393 ISOgrk3 --> + {"\u0394", "Δ"}, // greek capital letter delta, U+0394 ISOgrk3 --> {"\u0395", "Ε"}, // greek capital letter epsilon, U+0395 --> {"\u0396", "Ζ"}, // greek capital letter zeta, U+0396 --> {"\u0397", "Η"}, // greek capital letter eta, U+0397 --> - {"\u0398", "Θ"}, // greek capital letter theta,U+0398 ISOgrk3 --> + {"\u0398", "Θ"}, // greek capital letter theta, U+0398 ISOgrk3 --> {"\u0399", "Ι"}, // greek capital letter iota, U+0399 --> {"\u039A", "Κ"}, // greek capital letter kappa, U+039A --> - {"\u039B", "Λ"}, // greek capital letter lambda,U+039B ISOgrk3 --> + {"\u039B", "Λ"}, // greek capital letter lambda, U+039B ISOgrk3 --> {"\u039C", "Μ"}, // greek capital letter mu, U+039C --> {"\u039D", "Ν"}, // greek capital letter nu, U+039D --> {"\u039E", "Ξ"}, // greek capital letter xi, U+039E ISOgrk3 --> @@ -179,56 +179,56 @@ public class EntityArrays { {"\u03A0", "Π"}, // greek capital letter pi, U+03A0 ISOgrk3 --> {"\u03A1", "Ρ"}, // greek capital letter rho, U+03A1 --> // - {"\u03A3", "Σ"}, // greek capital letter sigma,U+03A3 ISOgrk3 --> + {"\u03A3", "Σ"}, // greek capital letter sigma, U+03A3 ISOgrk3 --> {"\u03A4", "Τ"}, // greek capital letter tau, U+03A4 --> - {"\u03A5", "Υ"}, // greek capital letter upsilon,U+03A5 ISOgrk3 --> - {"\u03A6", "Φ"}, // greek capital letter phi,U+03A6 ISOgrk3 --> + {"\u03A5", "Υ"}, // greek capital letter upsilon, U+03A5 ISOgrk3 --> + {"\u03A6", "Φ"}, // greek capital letter phi, U+03A6 ISOgrk3 --> {"\u03A7", "Χ"}, // greek capital letter chi, U+03A7 --> - {"\u03A8", "Ψ"}, // greek capital letter psi,U+03A8 ISOgrk3 --> - {"\u03A9", "Ω"}, // greek capital letter omega,U+03A9 ISOgrk3 --> - {"\u03B1", "α"}, // greek small letter alpha,U+03B1 ISOgrk3 --> + {"\u03A8", "Ψ"}, // greek capital letter psi, U+03A8 ISOgrk3 --> + {"\u03A9", "Ω"}, // greek capital letter omega, U+03A9 ISOgrk3 --> + {"\u03B1", "α"}, // greek small letter alpha, U+03B1 ISOgrk3 --> {"\u03B2", "β"}, // greek small letter beta, U+03B2 ISOgrk3 --> - {"\u03B3", "γ"}, // greek small letter gamma,U+03B3 ISOgrk3 --> - {"\u03B4", "δ"}, // greek small letter delta,U+03B4 ISOgrk3 --> - {"\u03B5", "ε"}, // greek small letter epsilon,U+03B5 ISOgrk3 --> + {"\u03B3", "γ"}, // greek small letter gamma, U+03B3 ISOgrk3 --> + {"\u03B4", "δ"}, // greek small letter delta, U+03B4 ISOgrk3 --> + {"\u03B5", "ε"}, // greek small letter epsilon, U+03B5 ISOgrk3 --> {"\u03B6", "ζ"}, // greek small letter zeta, U+03B6 ISOgrk3 --> {"\u03B7", "η"}, // greek small letter eta, U+03B7 ISOgrk3 --> - {"\u03B8", "θ"}, // greek small letter theta,U+03B8 ISOgrk3 --> + {"\u03B8", "θ"}, // greek small letter theta, U+03B8 ISOgrk3 --> {"\u03B9", "ι"}, // greek small letter iota, U+03B9 ISOgrk3 --> - {"\u03BA", "κ"}, // greek small letter kappa,U+03BA ISOgrk3 --> - {"\u03BB", "λ"}, // greek small letter lambda,U+03BB ISOgrk3 --> + {"\u03BA", "κ"}, // greek small letter kappa, U+03BA ISOgrk3 --> + {"\u03BB", "λ"}, // greek small letter lambda, U+03BB ISOgrk3 --> {"\u03BC", "μ"}, // greek small letter mu, U+03BC ISOgrk3 --> {"\u03BD", "ν"}, // greek small letter nu, U+03BD ISOgrk3 --> {"\u03BE", "ξ"}, // greek small letter xi, U+03BE ISOgrk3 --> {"\u03BF", "ο"}, // greek small letter omicron, U+03BF NEW --> {"\u03C0", "π"}, // greek small letter pi, U+03C0 ISOgrk3 --> {"\u03C1", "ρ"}, // greek small letter rho, U+03C1 ISOgrk3 --> - {"\u03C2", "ς"}, // greek small letter final sigma,U+03C2 ISOgrk3 --> - {"\u03C3", "σ"}, // greek small letter sigma,U+03C3 ISOgrk3 --> + {"\u03C2", "ς"}, // greek small letter final sigma, U+03C2 ISOgrk3 --> + {"\u03C3", "σ"}, // greek small letter sigma, U+03C3 ISOgrk3 --> {"\u03C4", "τ"}, // greek small letter tau, U+03C4 ISOgrk3 --> - {"\u03C5", "υ"}, // greek small letter upsilon,U+03C5 ISOgrk3 --> + {"\u03C5", "υ"}, // greek small letter upsilon, U+03C5 ISOgrk3 --> {"\u03C6", "φ"}, // greek small letter phi, U+03C6 ISOgrk3 --> {"\u03C7", "χ"}, // greek small letter chi, U+03C7 ISOgrk3 --> {"\u03C8", "ψ"}, // greek small letter psi, U+03C8 ISOgrk3 --> - {"\u03C9", "ω"}, // greek small letter omega,U+03C9 ISOgrk3 --> - {"\u03D1", "ϑ"}, // greek small letter theta symbol,U+03D1 NEW --> - {"\u03D2", "ϒ"}, // greek upsilon with hook symbol,U+03D2 NEW --> + {"\u03C9", "ω"}, // greek small letter omega, U+03C9 ISOgrk3 --> + {"\u03D1", "ϑ"}, // greek small letter theta symbol, U+03D1 NEW --> + {"\u03D2", "ϒ"}, // greek upsilon with hook symbol, U+03D2 NEW --> {"\u03D6", "ϖ"}, // greek pi symbol, U+03D6 ISOgrk3 --> // - {"\u2022", "•"}, // bullet = black small circle,U+2022 ISOpub --> + {"\u2022", "•"}, // bullet = black small circle, U+2022 ISOpub --> // - {"\u2026", "…"}, // horizontal ellipsis = three dot leader,U+2026 ISOpub --> + {"\u2026", "…"}, // horizontal ellipsis = three dot leader, U+2026 ISOpub --> {"\u2032", "′"}, // prime = minutes = feet, U+2032 ISOtech --> - {"\u2033", "″"}, // double prime = seconds = inches,U+2033 ISOtech --> - {"\u203E", "‾"}, // overline = spacing overscore,U+203E NEW --> + {"\u2033", "″"}, // double prime = seconds = inches, U+2033 ISOtech --> + {"\u203E", "‾"}, // overline = spacing overscore, U+203E NEW --> {"\u2044", "⁄"}, // fraction slash, U+2044 NEW --> // {"\u2118", "℘"}, // script capital P = power set= Weierstrass p, U+2118 ISOamso --> - {"\u2111", "ℑ"}, // blackletter capital I = imaginary part,U+2111 ISOamso --> - {"\u211C", "ℜ"}, // blackletter capital R = real part symbol,U+211C ISOamso --> + {"\u2111", "ℑ"}, // blackletter capital I = imaginary part, U+2111 ISOamso --> + {"\u211C", "ℜ"}, // blackletter capital R = real part symbol, U+211C ISOamso --> {"\u2122", "™"}, // trade mark sign, U+2122 ISOnum --> - {"\u2135", "ℵ"}, // alef symbol = first transfinite cardinal,U+2135 NEW --> - // + // // {"\u2190", "←"}, // leftwards arrow, U+2190 ISOnum --> @@ -242,23 +242,23 @@ public class EntityArrays { // arrow but also does not have any other character for that function. // So ? lArr canbe used for 'is implied by' as ISOtech suggests --> {"\u21D1", "⇑"}, // upwards double arrow, U+21D1 ISOamsa --> - {"\u21D2", "⇒"}, // rightwards double arrow,U+21D2 ISOtech --> + {"\u21D2", "⇒"}, // rightwards double arrow, U+21D2 ISOtech --> // {"\u21D3", "⇓"}, // downwards double arrow, U+21D3 ISOamsa --> - {"\u21D4", "⇔"}, // left right double arrow,U+21D4 ISOamsa --> + {"\u21D4", "⇔"}, // left right double arrow, U+21D4 ISOamsa --> // {"\u2200", "∀"}, // for all, U+2200 ISOtech --> {"\u2202", "∂"}, // partial differential, U+2202 ISOtech --> {"\u2203", "∃"}, // there exists, U+2203 ISOtech --> - {"\u2205", "∅"}, // empty set = null set = diameter,U+2205 ISOamso --> - {"\u2207", "∇"}, // nabla = backward difference,U+2207 ISOtech --> + {"\u2205", "∅"}, // empty set = null set = diameter, U+2205 ISOamso --> + {"\u2207", "∇"}, // nabla = backward difference, U+2207 ISOtech --> {"\u2208", "∈"}, // element of, U+2208 ISOtech --> {"\u2209", "∉"}, // not an element of, U+2209 ISOtech --> {"\u220B", "∋"}, // contains as member, U+220B ISOtech --> // - {"\u220F", "∏"}, // n-ary product = product sign,U+220F ISOamsb --> + {"\u220F", "∏"}, // n-ary product = product sign, U+220F ISOamsb --> // {"\u2211", "∑"}, // n-ary summation, U+2211 ISOamsb --> @@ -266,7 +266,7 @@ public class EntityArrays { // though the same glyph might be used for both --> {"\u2212", "−"}, // minus sign, U+2212 ISOtech --> {"\u2217", "∗"}, // asterisk operator, U+2217 ISOtech --> - {"\u221A", "√"}, // square root = radical sign,U+221A ISOtech --> + {"\u221A", "√"}, // square root = radical sign, U+221A ISOtech --> {"\u221D", "∝"}, // proportional to, U+221D ISOtech --> {"\u221E", "∞"}, // infinity, U+221E ISOtech --> {"\u2220", "∠"}, // angle, U+2220 ISOamso --> @@ -276,15 +276,15 @@ public class EntityArrays { {"\u222A", "∪"}, // union = cup, U+222A ISOtech --> {"\u222B", "∫"}, // integral, U+222B ISOtech --> {"\u2234", "∴"}, // therefore, U+2234 ISOtech --> - {"\u223C", "∼"}, // tilde operator = varies with = similar to,U+223C ISOtech --> - // + // {"\u2245", "≅"}, // approximately equal to, U+2245 ISOtech --> - {"\u2248", "≈"}, // almost equal to = asymptotic to,U+2248 ISOamsr --> + {"\u2248", "≈"}, // almost equal to = asymptotic to, U+2248 ISOamsr --> {"\u2260", "≠"}, // not equal to, U+2260 ISOtech --> {"\u2261", "≡"}, // identical to, U+2261 ISOtech --> {"\u2264", "≤"}, // less-than or equal to, U+2264 ISOtech --> - {"\u2265", "≥"}, // greater-than or equal to,U+2265 ISOtech --> + {"\u2265", "≥"}, // greater-than or equal to, U+2265 ISOtech --> {"\u2282", "⊂"}, // subset of, U+2282 ISOtech --> {"\u2283", "⊃"}, // superset of, U+2283 ISOtech --> // , {"\u2284", "⊄"}, // not a subset of, U+2284 ISOamsn --> {"\u2286", "⊆"}, // subset of or equal to, U+2286 ISOtech --> - {"\u2287", "⊇"}, // superset of or equal to,U+2287 ISOtech --> - {"\u2295", "⊕"}, // circled plus = direct sum,U+2295 ISOamsb --> - {"\u2297", "⊗"}, // circled times = vector product,U+2297 ISOamsb --> - {"\u22A5", "⊥"}, // up tack = orthogonal to = perpendicular,U+22A5 ISOtech --> + {"\u2287", "⊇"}, // superset of or equal to, U+2287 ISOtech --> + {"\u2295", "⊕"}, // circled plus = direct sum, U+2295 ISOamsb --> + {"\u2297", "⊗"}, // circled times = vector product, U+2297 ISOamsb --> + {"\u22A5", "⊥"}, // up tack = orthogonal to = perpendicular, U+22A5 ISOtech --> {"\u22C5", "⋅"}, // dot operator, U+22C5 ISOamsb --> // // - {"\u2308", "⌈"}, // left ceiling = apl upstile,U+2308 ISOamsc --> + {"\u2308", "⌈"}, // left ceiling = apl upstile, U+2308 ISOamsc --> {"\u2309", "⌉"}, // right ceiling, U+2309 ISOamsc --> - {"\u230A", "⌊"}, // left floor = apl downstile,U+230A ISOamsc --> + {"\u230A", "⌊"}, // left floor = apl downstile, U+230A ISOamsc --> {"\u230B", "⌋"}, // right floor, U+230B ISOamsc --> - {"\u2329", "〈"}, // left-pointing angle bracket = bra,U+2329 ISOtech --> + {"\u2329", "〈"}, // left-pointing angle bracket = bra, U+2329 ISOtech --> // - {"\u232A", "〉"}, // right-pointing angle bracket = ket,U+232A ISOtech --> + {"\u232A", "〉"}, // right-pointing angle bracket = ket, U+232A ISOtech --> // // @@ -314,42 +314,42 @@ public class EntityArrays { // {"\u2660", "♠"}, // black spade suit, U+2660 ISOpub --> // - {"\u2663", "♣"}, // black club suit = shamrock,U+2663 ISOpub --> - {"\u2665", "♥"}, // black heart suit = valentine,U+2665 ISOpub --> + {"\u2663", "♣"}, // black club suit = shamrock, U+2663 ISOpub --> + {"\u2665", "♥"}, // black heart suit = valentine, U+2665 ISOpub --> {"\u2666", "♦"}, // black diamond suit, U+2666 ISOpub --> // - {"\u0152", "Œ"}, // -- latin capital ligature OE,U+0152 ISOlat2 --> + {"\u0152", "Œ"}, // -- latin capital ligature OE, U+0152 ISOlat2 --> {"\u0153", "œ"}, // -- latin small ligature oe, U+0153 ISOlat2 --> // - {"\u0160", "Š"}, // -- latin capital letter S with caron,U+0160 ISOlat2 --> - {"\u0161", "š"}, // -- latin small letter s with caron,U+0161 ISOlat2 --> - {"\u0178", "Ÿ"}, // -- latin capital letter Y with diaeresis,U+0178 ISOlat2 --> + {"\u0160", "Š"}, // -- latin capital letter S with caron, U+0160 ISOlat2 --> + {"\u0161", "š"}, // -- latin small letter s with caron, U+0161 ISOlat2 --> + {"\u0178", "Ÿ"}, // -- latin capital letter Y with diaeresis, U+0178 ISOlat2 --> // - {"\u02C6", "ˆ"}, // -- modifier letter circumflex accent,U+02C6 ISOpub --> + {"\u02C6", "ˆ"}, // -- modifier letter circumflex accent, U+02C6 ISOpub --> {"\u02DC", "˜"}, // small tilde, U+02DC ISOdia --> // {"\u2002", " "}, // en space, U+2002 ISOpub --> {"\u2003", " "}, // em space, U+2003 ISOpub --> {"\u2009", " "}, // thin space, U+2009 ISOpub --> - {"\u200C", ""}, // zero width non-joiner,U+200C NEW RFC 2070 --> + {"\u200C", ""}, // zero width non-joiner, U+200C NEW RFC 2070 --> {"\u200D", ""}, // zero width joiner, U+200D NEW RFC 2070 --> {"\u200E", ""}, // left-to-right mark, U+200E NEW RFC 2070 --> {"\u200F", ""}, // right-to-left mark, U+200F NEW RFC 2070 --> {"\u2013", "–"}, // en dash, U+2013 ISOpub --> {"\u2014", "—"}, // em dash, U+2014 ISOpub --> - {"\u2018", "‘"}, // left single quotation mark,U+2018 ISOnum --> - {"\u2019", "’"}, // right single quotation mark,U+2019 ISOnum --> + {"\u2018", "‘"}, // left single quotation mark, U+2018 ISOnum --> + {"\u2019", "’"}, // right single quotation mark, U+2019 ISOnum --> {"\u201A", "‚"}, // single low-9 quotation mark, U+201A NEW --> - {"\u201C", "“"}, // left double quotation mark,U+201C ISOnum --> - {"\u201D", "”"}, // right double quotation mark,U+201D ISOnum --> + {"\u201C", "“"}, // left double quotation mark, U+201C ISOnum --> + {"\u201D", "”"}, // right double quotation mark, U+201D ISOnum --> {"\u201E", "„"}, // double low-9 quotation mark, U+201E NEW --> {"\u2020", "†"}, // dagger, U+2020 ISOpub --> {"\u2021", "‡"}, // double dagger, U+2021 ISOpub --> {"\u2030", "‰"}, // per mille sign, U+2030 ISOtech --> - {"\u2039", "‹"}, // single left-pointing angle quotation mark,U+2039 ISO proposed --> + {"\u2039", "‹"}, // single left-pointing angle quotation mark, U+2039 ISO proposed --> // - {"\u203A", "›"}, // single right-pointing angle quotation mark,U+203A ISO proposed --> + {"\u203A", "›"}, // single right-pointing angle quotation mark, U+203A ISO proposed --> // {"\u20AC", "€"}, // -- euro sign, U+20AC NEW --> }; @@ -448,7 +448,7 @@ public class EntityArrays { */ public static String[][] invert(final String[][] array) { final String[][] newarray = new String[array.length][2]; - for(int i = 0; i above) { return false; } diff --git a/src/main/java/org/apache/commons/lang3/text/translate/NumericEntityUnescaper.java b/src/main/java/org/apache/commons/lang3/text/translate/NumericEntityUnescaper.java index 91e2e98d5..06994fedb 100644 --- a/src/main/java/org/apache/commons/lang3/text/translate/NumericEntityUnescaper.java +++ b/src/main/java/org/apache/commons/lang3/text/translate/NumericEntityUnescaper.java @@ -57,7 +57,7 @@ public class NumericEntityUnescaper extends CharSequenceTranslator { * @param options to apply to this unescaper */ public NumericEntityUnescaper(final OPTION... options) { - if(options.length > 0) { + if (options.length > 0) { this.options = EnumSet.copyOf(Arrays.asList(options)); } else { this.options = EnumSet.copyOf(Arrays.asList(new OPTION[] { OPTION.semiColonRequired })); @@ -81,24 +81,24 @@ public class NumericEntityUnescaper extends CharSequenceTranslator { public int translate(final CharSequence input, final int index, final Writer out) throws IOException { final int seqEnd = input.length(); // Uses -2 to ensure there is something after the - if(input.charAt(index) == '&' && index < seqEnd - 2 && input.charAt(index + 1) == '#') { + if (input.charAt(index) == '&' && index < seqEnd - 2 && input.charAt(index + 1) == '#') { int start = index + 2; boolean isHex = false; final char firstChar = input.charAt(start); - if(firstChar == 'x' || firstChar == 'X') { + if (firstChar == 'x' || firstChar == 'X') { start++; isHex = true; // Check there's more than just an x after the - if(start == seqEnd) { + if (start == seqEnd) { return 0; } } int end = start; // Note that this supports character codes without a ; on the end - while(end < seqEnd && ( input.charAt(end) >= '0' && input.charAt(end) <= '9' || + while (end < seqEnd && ( input.charAt(end) >= '0' && input.charAt(end) <= '9' || input.charAt(end) >= 'a' && input.charAt(end) <= 'f' || input.charAt(end) >= 'A' && input.charAt(end) <= 'F' ) ) { end++; @@ -106,18 +106,18 @@ public class NumericEntityUnescaper extends CharSequenceTranslator { final boolean semiNext = end != seqEnd && input.charAt(end) == ';'; - if(!semiNext) { - if(isSet(OPTION.semiColonRequired)) { + if (!semiNext) { + if (isSet(OPTION.semiColonRequired)) { return 0; } else - if(isSet(OPTION.errorIfNoSemiColon)) { + if (isSet(OPTION.errorIfNoSemiColon)) { throw new IllegalArgumentException("Semi-colon required at end of numeric entity"); } } int entityValue; try { - if(isHex) { + if (isHex) { entityValue = Integer.parseInt(input.subSequence(start, end).toString(), 16); } else { entityValue = Integer.parseInt(input.subSequence(start, end).toString(), 10); @@ -126,7 +126,7 @@ public class NumericEntityUnescaper extends CharSequenceTranslator { return 0; } - if(entityValue > 0xFFFF) { + if (entityValue > 0xFFFF) { final char[] chars = Character.toChars(entityValue); out.write(chars[0]); out.write(chars[1]); diff --git a/src/main/java/org/apache/commons/lang3/text/translate/OctalUnescaper.java b/src/main/java/org/apache/commons/lang3/text/translate/OctalUnescaper.java index e8ac35782..77c9ca6fe 100644 --- a/src/main/java/org/apache/commons/lang3/text/translate/OctalUnescaper.java +++ b/src/main/java/org/apache/commons/lang3/text/translate/OctalUnescaper.java @@ -42,7 +42,7 @@ public class OctalUnescaper extends CharSequenceTranslator { public int translate(final CharSequence input, final int index, final Writer out) throws IOException { final int remaining = input.length() - index - 1; // how many characters left, ignoring the first \ final StringBuilder builder = new StringBuilder(); - if(input.charAt(index) == '\\' && remaining > 0 && isOctalDigit(input.charAt(index + 1)) ) { + if (input.charAt(index) == '\\' && remaining > 0 && isOctalDigit(input.charAt(index + 1)) ) { final int next = index + 1; final int next2 = index + 2; final int next3 = index + 3; @@ -50,9 +50,9 @@ public class OctalUnescaper extends CharSequenceTranslator { // we know this is good as we checked it in the if block above builder.append(input.charAt(next)); - if(remaining > 1 && isOctalDigit(input.charAt(next2))) { + if (remaining > 1 && isOctalDigit(input.charAt(next2))) { builder.append(input.charAt(next2)); - if(remaining > 2 && isZeroToThree(input.charAt(next)) && isOctalDigit(input.charAt(next3))) { + if (remaining > 2 && isZeroToThree(input.charAt(next)) && isOctalDigit(input.charAt(next3))) { builder.append(input.charAt(next3)); } } diff --git a/src/main/java/org/apache/commons/lang3/text/translate/UnicodeEscaper.java b/src/main/java/org/apache/commons/lang3/text/translate/UnicodeEscaper.java index 5771d1558..5ccac6a2f 100644 --- a/src/main/java/org/apache/commons/lang3/text/translate/UnicodeEscaper.java +++ b/src/main/java/org/apache/commons/lang3/text/translate/UnicodeEscaper.java @@ -37,7 +37,7 @@ public class UnicodeEscaper extends CodePointTranslator { /** * Constructs a
*/ - public UnicodeEscaper(){ + public UnicodeEscaper() { this(0, Integer.MAX_VALUE, true); } diff --git a/src/main/java/org/apache/commons/lang3/time/DateUtils.java b/src/main/java/org/apache/commons/lang3/time/DateUtils.java index e917bf90e..cbad16dc7 100644 --- a/src/main/java/org/apache/commons/lang3/time/DateUtils.java +++ b/src/main/java/org/apache/commons/lang3/time/DateUtils.java @@ -1662,7 +1662,7 @@ public class DateUtils { * @since 2.4 */ private static long getFragment(final Calendar calendar, final int fragment, final TimeUnit unit) { - if(calendar == null) { + if (calendar == null) { throw new IllegalArgumentException("The date must not be null"); } @@ -1701,7 +1701,7 @@ public class DateUtils { case Calendar.SECOND: result += unit.convert(calendar.get(Calendar.MILLISECOND), TimeUnit.MILLISECONDS); break; - case Calendar.MILLISECOND: break;//never useful + case Calendar.MILLISECOND: break; //never useful default: throw new IllegalArgumentException("The fragment " + fragment + " is not supported"); } return result; diff --git a/src/main/java/org/apache/commons/lang3/time/DurationFormatUtils.java b/src/main/java/org/apache/commons/lang3/time/DurationFormatUtils.java index 8c6e20a53..5ed08c793 100644 --- a/src/main/java/org/apache/commons/lang3/time/DurationFormatUtils.java +++ b/src/main/java/org/apache/commons/lang3/time/DurationFormatUtils.java @@ -344,7 +344,7 @@ public class DurationFormatUtils { } else { // there are no M's in the format string - if( !Token.containsTokenWithValue(tokens, y) ) { + if ( !Token.containsTokenWithValue(tokens, y) ) { int target = end.get(Calendar.YEAR); if (months < 0) { // target is end-year -1 @@ -369,7 +369,7 @@ public class DurationFormatUtils { years = 0; } - while( start.get(Calendar.MONTH) != end.get(Calendar.MONTH) ) { + while ( start.get(Calendar.MONTH) != end.get(Calendar.MONTH) ) { days += start.getActualMaximum(Calendar.DAY_OF_MONTH); start.add(Calendar.MONTH, 1); } diff --git a/src/main/java/org/apache/commons/lang3/time/FastDateParser.java b/src/main/java/org/apache/commons/lang3/time/FastDateParser.java index ed0301e24..783acb8e3 100644 --- a/src/main/java/org/apache/commons/lang3/time/FastDateParser.java +++ b/src/main/java/org/apache/commons/lang3/time/FastDateParser.java @@ -79,7 +79,7 @@ public class FastDateParser implements DateParser, Serializable { */ private static final long serialVersionUID = 3L; - static final Locale JAPANESE_IMPERIAL = new Locale("ja","JP","JP"); + static final Locale JAPANESE_IMPERIAL = new Locale("ja", "JP", "JP"); // defining fields private final String pattern; @@ -135,10 +135,10 @@ public class FastDateParser implements DateParser, Serializable { final Calendar definingCalendar = Calendar.getInstance(timeZone, locale); int centuryStartYear; - if(centuryStart!=null) { + if (centuryStart!=null) { definingCalendar.setTime(centuryStart); centuryStartYear= definingCalendar.get(Calendar.YEAR); - } else if(locale.equals(JAPANESE_IMPERIAL)) { + } else if (locale.equals(JAPANESE_IMPERIAL)) { centuryStartYear= 0; } else { // from 80 years ago to 20 years from now @@ -161,9 +161,9 @@ public class FastDateParser implements DateParser, Serializable { patterns = new ArrayList<>(); final StrategyParser fm = new StrategyParser(definingCalendar); - for(;;) { + for (;;) { final StrategyAndWidth field = fm.getNextStrategy(); - if(field==null) { + if (field==null) { break; } patterns.add(field); @@ -186,7 +186,7 @@ public class FastDateParser implements DateParser, Serializable { } int getMaxWidth(final ListIteratorUnicodeEscaper
for all characters.lt) { - if(!strategy.isNumber() || !lt.hasNext()) { + if (!strategy.isNumber() || !lt.hasNext()) { return 0; } final Strategy nextStrategy = lt.next().strategy; @@ -448,7 +448,7 @@ public class FastDateParser implements DateParser, Serializable { sb.append(c); } } - if(sb.charAt(sb.length() - 1) == '.') { + if (sb.charAt(sb.length() - 1) == '.') { // trailing '.' is optional sb.append('?'); } @@ -719,7 +719,7 @@ public class FastDateParser implements DateParser, Serializable { void setCalendar(final FastDateParser parser, final Calendar cal, final String value) { final String lowerCase = value.toLowerCase(locale); Integer iVal = lKeyValues.get(lowerCase); - if(iVal == null) { + if (iVal == null) { // match missing the optional trailing period iVal = lKeyValues.get(lowerCase + '.'); } diff --git a/src/main/java/org/apache/commons/lang3/time/FastDatePrinter.java b/src/main/java/org/apache/commons/lang3/time/FastDatePrinter.java index eaf95e880..a5edb289e 100644 --- a/src/main/java/org/apache/commons/lang3/time/FastDatePrinter.java +++ b/src/main/java/org/apache/commons/lang3/time/FastDatePrinter.java @@ -488,7 +488,7 @@ public class FastDatePrinter implements DatePrinter, Serializable { public StringBuffer format(final long millis, final StringBuffer buf) { final Calendar c = newCalendar(); c.setTimeInMillis(millis); - return (StringBuffer) applyRules(c, (Appendable)buf); + return (StringBuffer) applyRules(c, (Appendable) buf); } /* (non-Javadoc) @@ -498,7 +498,7 @@ public class FastDatePrinter implements DatePrinter, Serializable { public StringBuffer format(final Date date, final StringBuffer buf) { final Calendar c = newCalendar(); c.setTime(date); - return (StringBuffer) applyRules(c, (Appendable)buf); + return (StringBuffer) applyRules(c, (Appendable) buf); } /* (non-Javadoc) @@ -536,8 +536,8 @@ public class FastDatePrinter implements DatePrinter, Serializable { @Override public B format(Calendar calendar, final B buf) { // do not pass in calendar directly, this will cause TimeZone of FastDatePrinter to be ignored - if(!calendar.getTimeZone().equals(mTimeZone)) { - calendar = (Calendar)calendar.clone(); + if (!calendar.getTimeZone().equals(mTimeZone)) { + calendar = (Calendar) calendar.clone(); calendar.setTimeZone(mTimeZone); } return applyRules(calendar, buf); @@ -555,7 +555,7 @@ public class FastDatePrinter implements DatePrinter, Serializable { */ @Deprecated protected StringBuffer applyRules(final Calendar calendar, final StringBuffer buf) { - return (StringBuffer) applyRules(calendar, (Appendable)buf); + return (StringBuffer) applyRules(calendar, (Appendable) buf); } /** @@ -678,8 +678,8 @@ public class FastDatePrinter implements DatePrinter, Serializable { * @param value the value to append digits from. */ private static void appendDigits(final Appendable buffer, final int value) throws IOException { - buffer.append((char)(value / 10 + '0')); - buffer.append((char)(value % 10 + '0')); + buffer.append((char) (value / 10 + '0')); + buffer.append((char) (value % 10 + '0')); } private static final int MAX_DIGITS = 10; // log10(Integer.MAX_VALUE) ~= 9.3 @@ -939,7 +939,7 @@ public class FastDatePrinter implements DatePrinter, Serializable { @Override public final void appendTo(final Appendable buffer, final int value) throws IOException { if (value < 10) { - buffer.append((char)(value + '0')); + buffer.append((char) (value + '0')); } else if (value < 100) { appendDigits(buffer, value); } else { @@ -984,7 +984,7 @@ public class FastDatePrinter implements DatePrinter, Serializable { @Override public final void appendTo(final Appendable buffer, final int value) throws IOException { if (value < 10) { - buffer.append((char)(value + '0')); + buffer.append((char) (value + '0')); } else { appendDigits(buffer, value); } @@ -1562,7 +1562,7 @@ public class FastDatePrinter implements DatePrinter, Serializable { return true; } if (obj instanceof TimeZoneDisplayKey) { - final TimeZoneDisplayKey other = (TimeZoneDisplayKey)obj; + final TimeZoneDisplayKey other = (TimeZoneDisplayKey) obj; return mTimeZone.equals(other.mTimeZone) && mStyle == other.mStyle && diff --git a/src/main/java/org/apache/commons/lang3/time/FormatCache.java b/src/main/java/org/apache/commons/lang3/time/FormatCache.java index 1cb711a17..075cdc7c5 100644 --- a/src/main/java/org/apache/commons/lang3/time/FormatCache.java +++ b/src/main/java/org/apache/commons/lang3/time/FormatCache.java @@ -32,7 +32,7 @@ import org.apache.commons.lang3.Validate; * * @since 3.0 */ -// TODO: Before making public move from getDateTimeInstance(Integer,...) to int; or some other approach. +// TODO: Before making public move from getDateTimeInstance(Integer, ...) to int; or some other approach. abstract class FormatCache { /** @@ -201,7 +201,7 @@ abstract class FormatCache { } else { formatter = DateFormat.getDateTimeInstance(dateStyle.intValue(), timeStyle.intValue(), locale); } - pattern = ((SimpleDateFormat)formatter).toPattern(); + pattern = ((SimpleDateFormat) formatter).toPattern(); final String previous = cDateTimeInstanceCache.putIfAbsent(key, pattern); if (previous != null) { // even though it doesn't matter if another thread put the pattern @@ -240,7 +240,7 @@ abstract class FormatCache { // Eliminate the usual boilerplate because // this inner static class is only used in a generic ConcurrentHashMap // which will not compare against other Object types - return Arrays.equals(keys, ((MultipartKey)obj).keys); + return Arrays.equals(keys, ((MultipartKey) obj).keys); } /** @@ -248,10 +248,10 @@ abstract class FormatCache { */ @Override public int hashCode() { - if(hashCode==0) { + if (hashCode==0) { int rc= 0; - for(final Object key : keys) { - if(key!=null) { + for (final Object key : keys) { + if (key!=null) { rc= rc*7 + key.hashCode(); } } diff --git a/src/test/java/org/apache/commons/lang3/ArrayUtilsAddTest.java b/src/test/java/org/apache/commons/lang3/ArrayUtilsAddTest.java index bbd1c8abb..5396d437e 100644 --- a/src/test/java/org/apache/commons/lang3/ArrayUtilsAddTest.java +++ b/src/test/java/org/apache/commons/lang3/ArrayUtilsAddTest.java @@ -34,12 +34,12 @@ import org.junit.jupiter.api.Test; public class ArrayUtilsAddTest { @Test - public void testJira567(){ + public void testJira567() { Number[] n; // Valid array construction n = ArrayUtils.addAll(new Number[]{Integer.valueOf(1)}, new Long[]{Long.valueOf(2)}); - assertEquals(2,n.length); - assertEquals(Number.class,n.getClass().getComponentType()); + assertEquals(2, n.length); + assertEquals(Number.class, n.getClass().getComponentType()); // Invalid - can't store Long in Integer array assertThrows(IllegalArgumentException.class, () -> ArrayUtils.addAll(new Integer[]{Integer.valueOf(1)}, new Long[]{Long.valueOf(2)})); @@ -63,17 +63,17 @@ public class ArrayUtilsAddTest { @Test public void testAddObjectArrayByte() { byte[] newArray; - newArray = ArrayUtils.add((byte[])null, (byte)0); + newArray = ArrayUtils.add((byte[]) null, (byte) 0); assertTrue(Arrays.equals(new byte[]{0}, newArray)); assertEquals(Byte.TYPE, newArray.getClass().getComponentType()); - newArray = ArrayUtils.add((byte[])null, (byte)1); + newArray = ArrayUtils.add((byte[]) null, (byte) 1); assertTrue(Arrays.equals(new byte[]{1}, newArray)); assertEquals(Byte.TYPE, newArray.getClass().getComponentType()); final byte[] array1 = new byte[]{1, 2, 3}; - newArray = ArrayUtils.add(array1, (byte)0); + newArray = ArrayUtils.add(array1, (byte) 0); assertTrue(Arrays.equals(new byte[]{1, 2, 3, 0}, newArray)); assertEquals(Byte.TYPE, newArray.getClass().getComponentType()); - newArray = ArrayUtils.add(array1, (byte)4); + newArray = ArrayUtils.add(array1, (byte) 4); assertTrue(Arrays.equals(new byte[]{1, 2, 3, 4}, newArray)); assertEquals(Byte.TYPE, newArray.getClass().getComponentType()); } @@ -81,17 +81,17 @@ public class ArrayUtilsAddTest { @Test public void testAddObjectArrayChar() { char[] newArray; - newArray = ArrayUtils.add((char[])null, (char)0); + newArray = ArrayUtils.add((char[]) null, (char) 0); assertTrue(Arrays.equals(new char[]{0}, newArray)); assertEquals(Character.TYPE, newArray.getClass().getComponentType()); - newArray = ArrayUtils.add((char[])null, (char)1); + newArray = ArrayUtils.add((char[]) null, (char) 1); assertTrue(Arrays.equals(new char[]{1}, newArray)); assertEquals(Character.TYPE, newArray.getClass().getComponentType()); final char[] array1 = new char[]{1, 2, 3}; - newArray = ArrayUtils.add(array1, (char)0); + newArray = ArrayUtils.add(array1, (char) 0); assertTrue(Arrays.equals(new char[]{1, 2, 3, 0}, newArray)); assertEquals(Character.TYPE, newArray.getClass().getComponentType()); - newArray = ArrayUtils.add(array1, (char)4); + newArray = ArrayUtils.add(array1, (char) 4); assertTrue(Arrays.equals(new char[]{1, 2, 3, 4}, newArray)); assertEquals(Character.TYPE, newArray.getClass().getComponentType()); } @@ -99,10 +99,10 @@ public class ArrayUtilsAddTest { @Test public void testAddObjectArrayDouble() { double[] newArray; - newArray = ArrayUtils.add((double[])null, 0); + newArray = ArrayUtils.add((double[]) null, 0); assertTrue(Arrays.equals(new double[]{0}, newArray)); assertEquals(Double.TYPE, newArray.getClass().getComponentType()); - newArray = ArrayUtils.add((double[])null, 1); + newArray = ArrayUtils.add((double[]) null, 1); assertTrue(Arrays.equals(new double[]{1}, newArray)); assertEquals(Double.TYPE, newArray.getClass().getComponentType()); final double[] array1 = new double[]{1, 2, 3}; @@ -117,10 +117,10 @@ public class ArrayUtilsAddTest { @Test public void testAddObjectArrayFloat() { float[] newArray; - newArray = ArrayUtils.add((float[])null, 0); + newArray = ArrayUtils.add((float[]) null, 0); assertTrue(Arrays.equals(new float[]{0}, newArray)); assertEquals(Float.TYPE, newArray.getClass().getComponentType()); - newArray = ArrayUtils.add((float[])null, 1); + newArray = ArrayUtils.add((float[]) null, 1); assertTrue(Arrays.equals(new float[]{1}, newArray)); assertEquals(Float.TYPE, newArray.getClass().getComponentType()); final float[] array1 = new float[]{1, 2, 3}; @@ -135,10 +135,10 @@ public class ArrayUtilsAddTest { @Test public void testAddObjectArrayInt() { int[] newArray; - newArray = ArrayUtils.add((int[])null, 0); + newArray = ArrayUtils.add((int[]) null, 0); assertTrue(Arrays.equals(new int[]{0}, newArray)); assertEquals(Integer.TYPE, newArray.getClass().getComponentType()); - newArray = ArrayUtils.add((int[])null, 1); + newArray = ArrayUtils.add((int[]) null, 1); assertTrue(Arrays.equals(new int[]{1}, newArray)); assertEquals(Integer.TYPE, newArray.getClass().getComponentType()); final int[] array1 = new int[]{1, 2, 3}; @@ -153,10 +153,10 @@ public class ArrayUtilsAddTest { @Test public void testAddObjectArrayLong() { long[] newArray; - newArray = ArrayUtils.add((long[])null, 0); + newArray = ArrayUtils.add((long[]) null, 0); assertTrue(Arrays.equals(new long[]{0}, newArray)); assertEquals(Long.TYPE, newArray.getClass().getComponentType()); - newArray = ArrayUtils.add((long[])null, 1); + newArray = ArrayUtils.add((long[]) null, 1); assertTrue(Arrays.equals(new long[]{1}, newArray)); assertEquals(Long.TYPE, newArray.getClass().getComponentType()); final long[] array1 = new long[]{1, 2, 3}; @@ -171,17 +171,17 @@ public class ArrayUtilsAddTest { @Test public void testAddObjectArrayShort() { short[] newArray; - newArray = ArrayUtils.add((short[])null, (short)0); + newArray = ArrayUtils.add((short[]) null, (short) 0); assertTrue(Arrays.equals(new short[]{0}, newArray)); assertEquals(Short.TYPE, newArray.getClass().getComponentType()); - newArray = ArrayUtils.add((short[])null, (short)1); + newArray = ArrayUtils.add((short[]) null, (short) 1); assertTrue(Arrays.equals(new short[]{1}, newArray)); assertEquals(Short.TYPE, newArray.getClass().getComponentType()); final short[] array1 = new short[]{1, 2, 3}; - newArray = ArrayUtils.add(array1, (short)0); + newArray = ArrayUtils.add(array1, (short) 0); assertTrue(Arrays.equals(new short[]{1, 2, 3, 0}, newArray)); assertEquals(Short.TYPE, newArray.getClass().getComponentType()); - newArray = ArrayUtils.add(array1, (short)4); + newArray = ArrayUtils.add(array1, (short) 4); assertTrue(Arrays.equals(new short[]{1, 2, 3, 4}, newArray)); assertEquals(Short.TYPE, newArray.getClass().getComponentType()); } @@ -191,7 +191,7 @@ public class ArrayUtilsAddTest { Object[] newArray; //show that not casting is okay - newArray = ArrayUtils.add((Object[])null, "a"); + newArray = ArrayUtils.add((Object[]) null, "a"); assertTrue(Arrays.equals(new String[]{"a"}, newArray)); assertTrue(Arrays.equals(new Object[]{"a"}, newArray)); assertEquals(String.class, newArray.getClass().getComponentType()); @@ -224,7 +224,7 @@ public class ArrayUtilsAddTest { @Test @SuppressWarnings("deprecation") - public void testLANG571(){ + public void testLANG571() { final String[] stringArray=null; final String aString=null; assertThrows(IllegalArgumentException.class, () -> ArrayUtils.add(stringArray, aString)); @@ -353,7 +353,7 @@ public class ArrayUtilsAddTest { @Test public void testAddObjectAtIndex() { Object[] newArray; - newArray = ArrayUtils.add((Object[])null, 0, "a"); + newArray = ArrayUtils.add((Object[]) null, 0, "a"); assertTrue(Arrays.equals(new String[]{"a"}, newArray)); assertTrue(Arrays.equals(new Object[]{"a"}, newArray)); assertEquals(String.class, newArray.getClass().getComponentType()); diff --git a/src/test/java/org/apache/commons/lang3/ArrayUtilsInsertTest.java b/src/test/java/org/apache/commons/lang3/ArrayUtilsInsertTest.java index 689e79d69..134982cf1 100644 --- a/src/test/java/org/apache/commons/lang3/ArrayUtilsInsertTest.java +++ b/src/test/java/org/apache/commons/lang3/ArrayUtilsInsertTest.java @@ -31,8 +31,8 @@ public class ArrayUtilsInsertTest { @Test public void testInsertBooleans() { - final boolean[] array = {true,false,true}; - final boolean[] values = {false,true,false}; + final boolean[] array = {true, false, true}; + final boolean[] values = {false, true, false}; final boolean[] result = ArrayUtils.insert(42, array, null); assertArrayEquals(array, result); @@ -45,19 +45,19 @@ public class ArrayUtilsInsertTest { assertThrows(IndexOutOfBoundsException.class, () -> ArrayUtils.insert(-1, array, array)); assertThrows(IndexOutOfBoundsException.class, () -> ArrayUtils.insert(array.length + 1, array, array)); - assertArrayEquals(new boolean[]{false,true,false,true}, ArrayUtils.insert(0, array, false)); - assertArrayEquals(new boolean[]{true,false,false,true}, ArrayUtils.insert(1, array, false)); - assertArrayEquals(new boolean[]{true,false,true,false}, ArrayUtils.insert(array.length, array, false)); - assertArrayEquals(new boolean[]{false,true,false,true,false,true}, ArrayUtils.insert(0, array, values)); - assertArrayEquals(new boolean[]{true,false,true,false,false,true}, ArrayUtils.insert(1, array, values)); - assertArrayEquals(new boolean[]{true,false,true,false,true,false}, ArrayUtils.insert(array.length, array, values)); + assertArrayEquals(new boolean[]{false, true, false, true}, ArrayUtils.insert(0, array, false)); + assertArrayEquals(new boolean[]{true, false, false, true}, ArrayUtils.insert(1, array, false)); + assertArrayEquals(new boolean[]{true, false, true, false}, ArrayUtils.insert(array.length, array, false)); + assertArrayEquals(new boolean[]{false, true, false, true, false, true}, ArrayUtils.insert(0, array, values)); + assertArrayEquals(new boolean[]{true, false, true, false, false, true}, ArrayUtils.insert(1, array, values)); + assertArrayEquals(new boolean[]{true, false, true, false, true, false}, ArrayUtils.insert(array.length, array, values)); } @Test public void testInsertBytes() { - final byte[] array = {1,2,3}; - final byte[] values = {4,5,6}; + final byte[] array = {1, 2, 3}; + final byte[] values = {4, 5, 6}; final byte[] result = ArrayUtils.insert(42, array, null); assertArrayEquals(array, result); @@ -70,18 +70,18 @@ public class ArrayUtilsInsertTest { assertThrows(IndexOutOfBoundsException.class, () -> ArrayUtils.insert(-1, array, array)); assertThrows(IndexOutOfBoundsException.class, () -> ArrayUtils.insert(array.length + 1, array, array)); - assertArrayEquals(new byte[]{0,1,2,3}, ArrayUtils.insert(0, array, (byte) 0)); - assertArrayEquals(new byte[]{1,0,2,3}, ArrayUtils.insert(1, array, (byte) 0)); - assertArrayEquals(new byte[]{1,2,3,0}, ArrayUtils.insert(array.length, array, (byte) 0)); - assertArrayEquals(new byte[]{4,5,6,1,2,3}, ArrayUtils.insert(0, array, values)); - assertArrayEquals(new byte[]{1,4,5,6,2,3}, ArrayUtils.insert(1, array, values)); - assertArrayEquals(new byte[]{1,2,3,4,5,6}, ArrayUtils.insert(array.length, array, values)); + assertArrayEquals(new byte[]{0, 1, 2, 3}, ArrayUtils.insert(0, array, (byte) 0)); + assertArrayEquals(new byte[]{1, 0, 2, 3}, ArrayUtils.insert(1, array, (byte) 0)); + assertArrayEquals(new byte[]{1, 2, 3, 0}, ArrayUtils.insert(array.length, array, (byte) 0)); + assertArrayEquals(new byte[]{4, 5, 6, 1, 2, 3}, ArrayUtils.insert(0, array, values)); + assertArrayEquals(new byte[]{1, 4, 5, 6, 2, 3}, ArrayUtils.insert(1, array, values)); + assertArrayEquals(new byte[]{1, 2, 3, 4, 5, 6}, ArrayUtils.insert(array.length, array, values)); } @Test public void testInsertChars() { - final char[] array = {'a','b','c'}; - final char[] values = {'d','e','f'}; + final char[] array = {'a', 'b', 'c'}; + final char[] values = {'d', 'e', 'f'}; final char[] result = ArrayUtils.insert(42, array, null); assertArrayEquals(array, result); @@ -94,18 +94,18 @@ public class ArrayUtilsInsertTest { assertThrows(IndexOutOfBoundsException.class, () -> ArrayUtils.insert(-1, array, array)); assertThrows(IndexOutOfBoundsException.class, () -> ArrayUtils.insert(array.length + 1, array, array)); - assertArrayEquals(new char[]{'z','a','b','c'}, ArrayUtils.insert(0, array, 'z')); - assertArrayEquals(new char[]{'a','z','b','c'}, ArrayUtils.insert(1, array, 'z')); - assertArrayEquals(new char[]{'a','b','c','z'}, ArrayUtils.insert(array.length, array, 'z')); - assertArrayEquals(new char[]{'d','e','f','a','b','c'}, ArrayUtils.insert(0, array, values)); - assertArrayEquals(new char[]{'a','d','e','f','b','c'}, ArrayUtils.insert(1, array, values)); - assertArrayEquals(new char[]{'a','b','c','d','e','f'}, ArrayUtils.insert(array.length, array, values)); + assertArrayEquals(new char[]{'z', 'a', 'b', 'c'}, ArrayUtils.insert(0, array, 'z')); + assertArrayEquals(new char[]{'a', 'z', 'b', 'c'}, ArrayUtils.insert(1, array, 'z')); + assertArrayEquals(new char[]{'a', 'b', 'c', 'z'}, ArrayUtils.insert(array.length, array, 'z')); + assertArrayEquals(new char[]{'d', 'e', 'f', 'a', 'b', 'c'}, ArrayUtils.insert(0, array, values)); + assertArrayEquals(new char[]{'a', 'd', 'e', 'f', 'b', 'c'}, ArrayUtils.insert(1, array, values)); + assertArrayEquals(new char[]{'a', 'b', 'c', 'd', 'e', 'f'}, ArrayUtils.insert(array.length, array, values)); } @Test public void testInsertDoubles() { - final double[] array = {1,2,3}; - final double[] values = {4,5,6}; + final double[] array = {1, 2, 3}; + final double[] values = {4, 5, 6}; final double delta = 0.000001; final double[] result = ArrayUtils.insert(42, array, null); @@ -119,18 +119,18 @@ public class ArrayUtilsInsertTest { assertThrows(IndexOutOfBoundsException.class, () -> ArrayUtils.insert(-1, array, array)); assertThrows(IndexOutOfBoundsException.class, () -> ArrayUtils.insert(array.length + 1, array, array)); - assertArrayEquals(new double[]{0,1,2,3}, ArrayUtils.insert(0, array, 0), delta); - assertArrayEquals(new double[]{1,0,2,3}, ArrayUtils.insert(1, array, 0), delta); - assertArrayEquals(new double[]{1,2,3,0}, ArrayUtils.insert(array.length, array, 0), delta); - assertArrayEquals(new double[]{4,5,6,1,2,3}, ArrayUtils.insert(0, array, values), delta); - assertArrayEquals(new double[]{1,4,5,6,2,3}, ArrayUtils.insert(1, array, values), delta); - assertArrayEquals(new double[]{1,2,3,4,5,6}, ArrayUtils.insert(array.length, array, values), delta); + assertArrayEquals(new double[]{0, 1, 2, 3}, ArrayUtils.insert(0, array, 0), delta); + assertArrayEquals(new double[]{1, 0, 2, 3}, ArrayUtils.insert(1, array, 0), delta); + assertArrayEquals(new double[]{1, 2, 3, 0}, ArrayUtils.insert(array.length, array, 0), delta); + assertArrayEquals(new double[]{4, 5, 6, 1, 2, 3}, ArrayUtils.insert(0, array, values), delta); + assertArrayEquals(new double[]{1, 4, 5, 6, 2, 3}, ArrayUtils.insert(1, array, values), delta); + assertArrayEquals(new double[]{1, 2, 3, 4, 5, 6}, ArrayUtils.insert(array.length, array, values), delta); } @Test public void testInsertFloats() { - final float[] array = {1,2,3}; - final float[] values = {4,5,6}; + final float[] array = {1, 2, 3}; + final float[] values = {4, 5, 6}; final float delta = 0.000001f; final float[] result = ArrayUtils.insert(42, array, null); @@ -144,18 +144,18 @@ public class ArrayUtilsInsertTest { assertThrows(IndexOutOfBoundsException.class, () -> ArrayUtils.insert(-1, array, array)); assertThrows(IndexOutOfBoundsException.class, () -> ArrayUtils.insert(array.length + 1, array, array)); - assertArrayEquals(new float[]{0,1,2,3}, ArrayUtils.insert(0, array, 0), delta); - assertArrayEquals(new float[]{1,0,2,3}, ArrayUtils.insert(1, array, 0), delta); - assertArrayEquals(new float[]{1,2,3,0}, ArrayUtils.insert(array.length, array, 0), delta); - assertArrayEquals(new float[]{4,5,6,1,2,3}, ArrayUtils.insert(0, array, values), delta); - assertArrayEquals(new float[]{1,4,5,6,2,3}, ArrayUtils.insert(1, array, values), delta); - assertArrayEquals(new float[]{1,2,3,4,5,6}, ArrayUtils.insert(array.length, array, values), delta); + assertArrayEquals(new float[]{0, 1, 2, 3}, ArrayUtils.insert(0, array, 0), delta); + assertArrayEquals(new float[]{1, 0, 2, 3}, ArrayUtils.insert(1, array, 0), delta); + assertArrayEquals(new float[]{1, 2, 3, 0}, ArrayUtils.insert(array.length, array, 0), delta); + assertArrayEquals(new float[]{4, 5, 6, 1, 2, 3}, ArrayUtils.insert(0, array, values), delta); + assertArrayEquals(new float[]{1, 4, 5, 6, 2, 3}, ArrayUtils.insert(1, array, values), delta); + assertArrayEquals(new float[]{1, 2, 3, 4, 5, 6}, ArrayUtils.insert(array.length, array, values), delta); } @Test public void testInsertInts() { - final int[] array = {1,2,3}; - final int[] values = {4,5,6}; + final int[] array = {1, 2, 3}; + final int[] values = {4, 5, 6}; final int[] result = ArrayUtils.insert(42, array, null); assertArrayEquals(array, result); @@ -168,19 +168,19 @@ public class ArrayUtilsInsertTest { assertThrows(IndexOutOfBoundsException.class, () -> ArrayUtils.insert(-1, array, array)); assertThrows(IndexOutOfBoundsException.class, () -> ArrayUtils.insert(array.length + 1, array, array)); - assertArrayEquals(new int[]{0,1,2,3}, ArrayUtils.insert(0, array, 0)); - assertArrayEquals(new int[]{1,0,2,3}, ArrayUtils.insert(1, array, 0)); - assertArrayEquals(new int[]{1,2,3,0}, ArrayUtils.insert(array.length, array, 0)); - assertArrayEquals(new int[]{4,5,6,1,2,3}, ArrayUtils.insert(0, array, values)); - assertArrayEquals(new int[]{1,4,5,6,2,3}, ArrayUtils.insert(1, array, values)); - assertArrayEquals(new int[]{1,2,3,4,5,6}, ArrayUtils.insert(array.length, array, values)); + assertArrayEquals(new int[]{0, 1, 2, 3}, ArrayUtils.insert(0, array, 0)); + assertArrayEquals(new int[]{1, 0, 2, 3}, ArrayUtils.insert(1, array, 0)); + assertArrayEquals(new int[]{1, 2, 3, 0}, ArrayUtils.insert(array.length, array, 0)); + assertArrayEquals(new int[]{4, 5, 6, 1, 2, 3}, ArrayUtils.insert(0, array, values)); + assertArrayEquals(new int[]{1, 4, 5, 6, 2, 3}, ArrayUtils.insert(1, array, values)); + assertArrayEquals(new int[]{1, 2, 3, 4, 5, 6}, ArrayUtils.insert(array.length, array, values)); } @Test public void testInsertLongs() { - final long[] array = {1,2,3}; - final long[] values = {4,5,6}; + final long[] array = {1, 2, 3}; + final long[] values = {4, 5, 6}; final long[] result = ArrayUtils.insert(42, array, null); assertArrayEquals(array, result); @@ -193,19 +193,19 @@ public class ArrayUtilsInsertTest { assertThrows(IndexOutOfBoundsException.class, () -> ArrayUtils.insert(-1, array, array)); assertThrows(IndexOutOfBoundsException.class, () -> ArrayUtils.insert(array.length + 1, array, array)); - assertArrayEquals(new long[]{0,1,2,3}, ArrayUtils.insert(0, array, 0)); - assertArrayEquals(new long[]{1,0,2,3}, ArrayUtils.insert(1, array, 0)); - assertArrayEquals(new long[]{1,2,3,0}, ArrayUtils.insert(array.length, array, 0)); - assertArrayEquals(new long[]{4,5,6,1,2,3}, ArrayUtils.insert(0, array, values)); - assertArrayEquals(new long[]{1,4,5,6,2,3}, ArrayUtils.insert(1, array, values)); - assertArrayEquals(new long[]{1,2,3,4,5,6}, ArrayUtils.insert(array.length, array, values)); + assertArrayEquals(new long[]{0, 1, 2, 3}, ArrayUtils.insert(0, array, 0)); + assertArrayEquals(new long[]{1, 0, 2, 3}, ArrayUtils.insert(1, array, 0)); + assertArrayEquals(new long[]{1, 2, 3, 0}, ArrayUtils.insert(array.length, array, 0)); + assertArrayEquals(new long[]{4, 5, 6, 1, 2, 3}, ArrayUtils.insert(0, array, values)); + assertArrayEquals(new long[]{1, 4, 5, 6, 2, 3}, ArrayUtils.insert(1, array, values)); + assertArrayEquals(new long[]{1, 2, 3, 4, 5, 6}, ArrayUtils.insert(array.length, array, values)); } @Test public void testInsertShorts() { - final short[] array = {1,2,3}; - final short[] values = {4,5,6}; + final short[] array = {1, 2, 3}; + final short[] values = {4, 5, 6}; final short[] result = ArrayUtils.insert(42, array, null); assertArrayEquals(array, result); @@ -218,19 +218,19 @@ public class ArrayUtilsInsertTest { assertThrows(IndexOutOfBoundsException.class, () -> ArrayUtils.insert(-1, array, array)); assertThrows(IndexOutOfBoundsException.class, () -> ArrayUtils.insert(array.length + 1, array, array)); - assertArrayEquals(new short[]{0,1,2,3}, ArrayUtils.insert(0, array, (short) 0)); - assertArrayEquals(new short[]{1,0,2,3}, ArrayUtils.insert(1, array, (short) 0)); - assertArrayEquals(new short[]{1,2,3,0}, ArrayUtils.insert(array.length, array, (short) 0)); - assertArrayEquals(new short[]{4,5,6,1,2,3}, ArrayUtils.insert(0, array, values)); - assertArrayEquals(new short[]{1,4,5,6,2,3}, ArrayUtils.insert(1, array, values)); - assertArrayEquals(new short[]{1,2,3,4,5,6}, ArrayUtils.insert(array.length, array, values)); + assertArrayEquals(new short[]{0, 1, 2, 3}, ArrayUtils.insert(0, array, (short) 0)); + assertArrayEquals(new short[]{1, 0, 2, 3}, ArrayUtils.insert(1, array, (short) 0)); + assertArrayEquals(new short[]{1, 2, 3, 0}, ArrayUtils.insert(array.length, array, (short) 0)); + assertArrayEquals(new short[]{4, 5, 6, 1, 2, 3}, ArrayUtils.insert(0, array, values)); + assertArrayEquals(new short[]{1, 4, 5, 6, 2, 3}, ArrayUtils.insert(1, array, values)); + assertArrayEquals(new short[]{1, 2, 3, 4, 5, 6}, ArrayUtils.insert(array.length, array, values)); } @Test public void testInsertGenericArray() { - final String[] array = {"a","b","c"}; - final String[] values = {"d","e","f"}; + final String[] array = {"a", "b", "c"}; + final String[] values = {"d", "e", "f"}; final String[] result = ArrayUtils.insert(42, array, (String[]) null); assertArrayEquals(array, result); @@ -243,11 +243,11 @@ public class ArrayUtilsInsertTest { assertThrows(IndexOutOfBoundsException.class, () -> ArrayUtils.insert(-1, array, array)); assertThrows(IndexOutOfBoundsException.class, () -> ArrayUtils.insert(array.length + 1, array, array)); - assertArrayEquals(new String[]{"z","a","b","c"}, ArrayUtils.insert(0, array, "z")); - assertArrayEquals(new String[]{"a","z","b","c"}, ArrayUtils.insert(1, array, "z")); - assertArrayEquals(new String[]{"a","b","c","z"}, ArrayUtils.insert(array.length, array, "z")); - assertArrayEquals(new String[]{"d","e","f","a","b","c"}, ArrayUtils.insert(0, array, values)); - assertArrayEquals(new String[]{"a","d","e","f","b","c"}, ArrayUtils.insert(1, array, values)); - assertArrayEquals(new String[]{"a","b","c","d","e","f"}, ArrayUtils.insert(array.length, array, values)); + assertArrayEquals(new String[]{"z", "a", "b", "c"}, ArrayUtils.insert(0, array, "z")); + assertArrayEquals(new String[]{"a", "z", "b", "c"}, ArrayUtils.insert(1, array, "z")); + assertArrayEquals(new String[]{"a", "b", "c", "z"}, ArrayUtils.insert(array.length, array, "z")); + assertArrayEquals(new String[]{"d", "e", "f", "a", "b", "c"}, ArrayUtils.insert(0, array, values)); + assertArrayEquals(new String[]{"a", "d", "e", "f", "b", "c"}, ArrayUtils.insert(1, array, values)); + assertArrayEquals(new String[]{"a", "b", "c", "d", "e", "f"}, ArrayUtils.insert(array.length, array, values)); } } diff --git a/src/test/java/org/apache/commons/lang3/ArrayUtilsRemoveTest.java b/src/test/java/org/apache/commons/lang3/ArrayUtilsRemoveTest.java index d8ce3655a..9b5eba0b1 100644 --- a/src/test/java/org/apache/commons/lang3/ArrayUtilsRemoveTest.java +++ b/src/test/java/org/apache/commons/lang3/ArrayUtilsRemoveTest.java @@ -52,8 +52,8 @@ public class ArrayUtilsRemoveTest { } @Test - public void testRemoveNumberArray(){ - final Number[] inarray = {Integer.valueOf(1),Long.valueOf(2),Byte.valueOf((byte) 3)}; + public void testRemoveNumberArray() { + final Number[] inarray = {Integer.valueOf(1), Long.valueOf(2), Byte.valueOf((byte) 3)}; assertEquals(3, inarray.length); Number[] outarray; outarray = ArrayUtils.remove(inarray, 1); diff --git a/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java b/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java index c5044094b..7d83ed07e 100644 --- a/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java @@ -942,9 +942,9 @@ public class ArrayUtilsTest { public void testSubarrChar() { final char[] nullArray = null; final char[] array = {'a', 'b', 'c', 'd', 'e', 'f'}; - final char[] leftSubarray = {'a', 'b', 'c', 'd',}; - final char[] midSubarray = {'b', 'c', 'd', 'e',}; - final char[] rightSubarray = {'c', 'd', 'e', 'f',}; + final char[] leftSubarray = {'a', 'b', 'c', 'd'}; + final char[] midSubarray = {'b', 'c', 'd', 'e'}; + final char[] rightSubarray = {'c', 'd', 'e', 'f'}; assertTrue(ArrayUtils.isEquals(leftSubarray, ArrayUtils.subarray(array, 0, 4)), "0 start, mid end"); assertTrue(ArrayUtils.isEquals(array, ArrayUtils.subarray(array, 0, array.length)), "0 start, length end"); @@ -1022,8 +1022,8 @@ public class ArrayUtilsTest { public void testSubarrayDouble() { final double[] nullArray = null; final double[] array = {10.123, 11.234, 12.345, 13.456, 14.567, 15.678}; - final double[] leftSubarray = {10.123, 11.234, 12.345, 13.456,}; - final double[] midSubarray = {11.234, 12.345, 13.456, 14.567,}; + final double[] leftSubarray = {10.123, 11.234, 12.345, 13.456}; + final double[] midSubarray = {11.234, 12.345, 13.456, 14.567}; final double[] rightSubarray = {12.345, 13.456, 14.567, 15.678}; assertTrue(ArrayUtils.isEquals(leftSubarray, ArrayUtils.subarray(array, 0, 4)), "0 start, mid end"); @@ -1079,7 +1079,7 @@ public class ArrayUtilsTest { assertEquals(ArrayUtils.EMPTY_FLOAT_ARRAY, ArrayUtils.subarray(array, 3, 3), "start == end"); assertTrue(ArrayUtils.isEquals(leftSubarray, ArrayUtils.subarray(array, -2, 4)), "start undershoot, normal end"); - assertEquals(ArrayUtils.EMPTY_FLOAT_ARRAY, ArrayUtils.subarray(array, 33, 4),"start overshoot, any end"); + assertEquals(ArrayUtils.EMPTY_FLOAT_ARRAY, ArrayUtils.subarray(array, 33, 4), "start overshoot, any end"); assertTrue(ArrayUtils.isEquals(rightSubarray, ArrayUtils.subarray(array, 2, 33)), "normal start, end overshoot"); assertTrue(ArrayUtils.isEquals(array, ArrayUtils.subarray(array, -2, 12)), "start undershoot, end overshoot"); @@ -4821,7 +4821,7 @@ public class ArrayUtilsTest { } @Test - public void testIsArrayIndexValid(){ + public void testIsArrayIndexValid() { assertFalse(ArrayUtils.isArrayIndexValid(null, 0)); String[] array = new String[1]; diff --git a/src/test/java/org/apache/commons/lang3/BooleanUtilsTest.java b/src/test/java/org/apache/commons/lang3/BooleanUtilsTest.java index dddb416d3..c25c22ef2 100644 --- a/src/test/java/org/apache/commons/lang3/BooleanUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/BooleanUtilsTest.java @@ -1007,7 +1007,7 @@ public class BooleanUtilsTest { } @Test - public void testCompare(){ + public void testCompare() { assertTrue(BooleanUtils.compare(true, false) > 0); assertEquals(0, BooleanUtils.compare(true, true)); assertEquals(0, BooleanUtils.compare(false, false)); diff --git a/src/test/java/org/apache/commons/lang3/CharSequenceUtilsTest.java b/src/test/java/org/apache/commons/lang3/CharSequenceUtilsTest.java index abaf3461e..e7dd3b48d 100644 --- a/src/test/java/org/apache/commons/lang3/CharSequenceUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/CharSequenceUtilsTest.java @@ -84,7 +84,7 @@ public class CharSequenceUtilsTest { final boolean expected; final Class extends Throwable> throwable; TestData(final String source, final boolean ignoreCase, final int toffset, - final String other, final int ooffset, final int len, final boolean expected){ + final String other, final int ooffset, final int len, final boolean expected) { this.source = source; this.ignoreCase = ignoreCase; this.toffset = toffset; @@ -95,7 +95,7 @@ public class CharSequenceUtilsTest { this.throwable = null; } TestData(final String source, final boolean ignoreCase, final int toffset, - final String other, final int ooffset, final int len, final Class extends Throwable> throwable){ + final String other, final int ooffset, final int len, final Class extends Throwable> throwable) { this.source = source; this.ignoreCase = ignoreCase; this.toffset = toffset; @@ -106,7 +106,7 @@ public class CharSequenceUtilsTest { this.throwable = throwable; } @Override - public String toString(){ + public String toString() { final StringBuilder sb = new StringBuilder(); sb.append(source).append("[").append(toffset).append("]"); sb.append(ignoreCase? " caseblind ":" samecase "); @@ -134,8 +134,8 @@ public class CharSequenceUtilsTest { new TestData("Abc", false, 0, "abc", 0, 3, false), new TestData("Abc", true, 1, "abc", 1, 2, true), new TestData("Abc", false, 1, "abc", 1, 2, true), - new TestData("Abcd",true, 1, "abcD",1, 2, true), - new TestData("Abcd",false, 1, "abcD",1, 2, true), + new TestData("Abcd", true, 1, "abcD", 1, 2, true), + new TestData("Abcd", false, 1, "abcD", 1, 2, true), }; private abstract static class RunTest { diff --git a/src/test/java/org/apache/commons/lang3/CharSetTest.java b/src/test/java/org/apache/commons/lang3/CharSetTest.java index e0f318d39..a3c25c62a 100644 --- a/src/test/java/org/apache/commons/lang3/CharSetTest.java +++ b/src/test/java/org/apache/commons/lang3/CharSetTest.java @@ -325,7 +325,7 @@ public class CharSetTest { set = CharSet.getInstance("^-b"); array = set.getCharRanges(); - assertTrue(ArrayUtils.contains(array, CharRange.isIn('^','b'))); // "^-b" + assertTrue(ArrayUtils.contains(array, CharRange.isIn('^', 'b'))); // "^-b" assertTrue(set.contains('b')); assertTrue(set.contains('_')); // between ^ and a assertFalse(set.contains('A')); @@ -333,7 +333,7 @@ public class CharSetTest { set = CharSet.getInstance("b-^"); array = set.getCharRanges(); - assertTrue(ArrayUtils.contains(array, CharRange.isIn('^','b'))); // "b-^" + assertTrue(ArrayUtils.contains(array, CharRange.isIn('^', 'b'))); // "b-^" assertTrue(set.contains('b')); assertTrue(set.contains('^')); assertTrue(set.contains('a')); // between ^ and b diff --git a/src/test/java/org/apache/commons/lang3/ClassUtilsTest.java b/src/test/java/org/apache/commons/lang3/ClassUtilsTest.java index 59c9dad64..0f4c1ce54 100644 --- a/src/test/java/org/apache/commons/lang3/ClassUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/ClassUtilsTest.java @@ -158,7 +158,7 @@ public class ClassUtilsTest { // ------------------------------------------------------------------------- @Test public void test_getAbbreviatedName_Class() { - assertEquals("", ClassUtils.getAbbreviatedName((Class>)null, 1)); + assertEquals("", ClassUtils.getAbbreviatedName((Class>) null, 1)); assertEquals("j.l.String", ClassUtils.getAbbreviatedName(String.class, 1)); assertEquals("j.l.String", ClassUtils.getAbbreviatedName(String.class, 5)); assertEquals("j.lang.String", ClassUtils.getAbbreviatedName(String.class, 13)); @@ -1295,8 +1295,8 @@ public class ClassUtilsTest { assertNull(ClassUtils.primitivesToWrappers((Class>[]) null), "null -> null"); // equivalent cast to avoid warning // Other possible casts for null assertTrue(Arrays.equals(ArrayUtils.EMPTY_CLASS_ARRAY, ClassUtils.primitivesToWrappers()), "empty -> empty"); - final Class>[] castNull = ClassUtils.primitivesToWrappers((Class>)null); // == new Class>[]{null} - assertTrue(Arrays.equals(new Class>[]{null}, castNull), "(Class>)null -> [null]"); + final Class>[] castNull = ClassUtils.primitivesToWrappers((Class>) null); // == new Class>[]{null} + assertTrue(Arrays.equals(new Class>[]{null}, castNull), "(Class>) null -> [null]"); // test empty array is returned unchanged assertArrayEquals(ArrayUtils.EMPTY_CLASS_ARRAY, ClassUtils.primitivesToWrappers(ArrayUtils.EMPTY_CLASS_ARRAY), "empty -> empty"); @@ -1366,7 +1366,7 @@ public class ClassUtilsTest { // Additional varargs tests assertTrue(Arrays.equals(ArrayUtils.EMPTY_CLASS_ARRAY, ClassUtils.toClass()), "empty -> empty"); final Class>[] castNull = ClassUtils.toClass((Object) null); // == new Object[]{null} - assertTrue(Arrays.equals(new Object[]{null}, castNull), "(Object)null -> [null]"); + assertTrue(Arrays.equals(new Object[]{null}, castNull), "(Object) null -> [null]"); assertSame(ArrayUtils.EMPTY_CLASS_ARRAY, ClassUtils.toClass(ArrayUtils.EMPTY_OBJECT_ARRAY)); @@ -1415,8 +1415,8 @@ public class ClassUtilsTest { assertNull(ClassUtils.wrappersToPrimitives((Class>[]) null), "Wrong result for null input"); // equivalent cast // Other possible casts for null assertTrue(Arrays.equals(ArrayUtils.EMPTY_CLASS_ARRAY, ClassUtils.wrappersToPrimitives()), "empty -> empty"); - final Class>[] castNull = ClassUtils.wrappersToPrimitives((Class>)null); // == new Class>[]{null} - assertTrue(Arrays.equals(new Class>[]{null}, castNull), "(Class>)null -> [null]"); + final Class>[] castNull = ClassUtils.wrappersToPrimitives((Class>) null); // == new Class>[]{null} + assertTrue(Arrays.equals(new Class>[]{null}, castNull), "(Class>) null -> [null]"); } @Test diff --git a/src/test/java/org/apache/commons/lang3/ConversionTest.java b/src/test/java/org/apache/commons/lang3/ConversionTest.java index 74e6b1379..7cf32cb13 100644 --- a/src/test/java/org/apache/commons/lang3/ConversionTest.java +++ b/src/test/java/org/apache/commons/lang3/ConversionTest.java @@ -291,10 +291,10 @@ public class ConversionTest { */ @Test public void testBinaryToHexDigitMsb0_4bits_2args() { - // boolean[] shortArray = new boolean[]{true,true,false}; - // assertEquals('6', Conversion.BinaryToHexDigitMsb0(shortArray,0)); - // assertEquals('3', Conversion.BinaryToHexDigitMsb0(shortArray,1)); - // assertEquals('1', Conversion.BinaryToHexDigitMsb0(shortArray,2)); + // boolean[] shortArray = new boolean[]{true, true, false}; + // assertEquals('6', Conversion.BinaryToHexDigitMsb0(shortArray, 0)); + // assertEquals('3', Conversion.BinaryToHexDigitMsb0(shortArray, 1)); + // assertEquals('1', Conversion.BinaryToHexDigitMsb0(shortArray, 2)); final boolean[] shortArray = new boolean[]{true, true, false, true}; assertEquals('d', Conversion.binaryToHexDigitMsb0_4bits(shortArray, 0)); final boolean[] longArray = new boolean[]{true, false, true, false, false, true, true}; @@ -302,9 +302,9 @@ public class ConversionTest { assertEquals('4', Conversion.binaryToHexDigitMsb0_4bits(longArray, 1)); assertEquals('9', Conversion.binaryToHexDigitMsb0_4bits(longArray, 2)); assertEquals('3', Conversion.binaryToHexDigitMsb0_4bits(longArray, 3)); - // assertEquals('6', Conversion.BinaryToHexDigitMsb0(longArray,4)); - // assertEquals('3', Conversion.BinaryToHexDigitMsb0(longArray,5)); - // assertEquals('1', Conversion.BinaryToHexDigitMsb0(longArray,6)); + // assertEquals('6', Conversion.BinaryToHexDigitMsb0(longArray, 4)); + // assertEquals('3', Conversion.BinaryToHexDigitMsb0(longArray, 5)); + // assertEquals('1', Conversion.BinaryToHexDigitMsb0(longArray, 6)); final boolean[] maxLengthArray = new boolean[]{ true, false, true, false, false, true, true, true}; assertEquals('a', Conversion.binaryToHexDigitMsb0_4bits(maxLengthArray, 0)); @@ -312,9 +312,9 @@ public class ConversionTest { assertEquals('9', Conversion.binaryToHexDigitMsb0_4bits(maxLengthArray, 2)); assertEquals('3', Conversion.binaryToHexDigitMsb0_4bits(maxLengthArray, 3)); assertEquals('7', Conversion.binaryToHexDigitMsb0_4bits(maxLengthArray, 4)); - // assertEquals('7', Conversion.BinaryToHexDigitMsb0(longArray,5)); - // assertEquals('3', Conversion.BinaryToHexDigitMsb0(longArray,6)); - // assertEquals('1', Conversion.BinaryToHexDigitMsb0(longArray,7)); + // assertEquals('7', Conversion.BinaryToHexDigitMsb0(longArray, 5)); + // assertEquals('3', Conversion.BinaryToHexDigitMsb0(longArray, 6)); + // assertEquals('1', Conversion.BinaryToHexDigitMsb0(longArray, 7)); final boolean[] javaDocCheck = new boolean[]{ true, false, false, true, true, false, true, false}; assertEquals('d', Conversion.binaryToHexDigitMsb0_4bits(javaDocCheck, 3)); @@ -465,9 +465,9 @@ public class ConversionTest { final StringBuilder sb = new StringBuilder(); for (final boolean e : src) { if (e) { - sb.append("1,"); + sb.append("1, "); } else { - sb.append("0,"); + sb.append("0, "); } } final String out = sb.toString(); @@ -489,7 +489,7 @@ public class ConversionTest { 0x123456789ABCDEF0L, Conversion.intArrayToLong(src, 0, 0x123456789ABCDEF0L, 0, 0)); assertEquals( 0x1234567878000000L, Conversion.intArrayToLong(src, 2, 0x123456789ABCDEF0L, 0, 1)); - // assertEquals(0x0F12345678000000L,Conversion.intsToLong(src,1,0x123456789ABCDEF0L,32,2)); + // assertEquals(0x0F12345678000000L, Conversion.intsToLong(src, 1, 0x123456789ABCDEF0L, 32, 2)); } /** @@ -498,7 +498,7 @@ public class ConversionTest { @Test public void testShortArrayToLong() { final short[] src = new short[]{ - (short)0xCDF1, (short)0xF0C1, (short)0x0F12, (short)0x3456, (short)0x7800}; + (short) 0xCDF1, (short) 0xF0C1, (short) 0x0F12, (short) 0x3456, (short) 0x7800}; assertEquals(0x0000000000000000L, Conversion.shortArrayToLong(src, 0, 0L, 0, 0)); assertEquals(0x000000000000CDF1L, Conversion.shortArrayToLong(src, 0, 0L, 0, 1)); assertEquals(0x00000000F0C1CDF1L, Conversion.shortArrayToLong(src, 0, 0L, 0, 2)); @@ -519,8 +519,8 @@ public class ConversionTest { @Test public void testByteArrayToLong() { final byte[] src = new byte[]{ - (byte)0xCD, (byte)0xF1, (byte)0xF0, (byte)0xC1, (byte)0x0F, (byte)0x12, (byte)0x34, - (byte)0x56, (byte)0x78}; + (byte) 0xCD, (byte) 0xF1, (byte) 0xF0, (byte) 0xC1, (byte) 0x0F, (byte) 0x12, (byte) 0x34, + (byte) 0x56, (byte) 0x78}; assertEquals(0x0000000000000000L, Conversion.byteArrayToLong(src, 0, 0L, 0, 0)); assertEquals(0x00000000000000CDL, Conversion.byteArrayToLong(src, 0, 0L, 0, 1)); assertEquals(0x00000000C1F0F1CDL, Conversion.byteArrayToLong(src, 0, 0L, 0, 4)); @@ -539,14 +539,14 @@ public class ConversionTest { @Test public void testShortArrayToInt() { final short[] src = new short[]{ - (short)0xCDF1, (short)0xF0C1, (short)0x0F12, (short)0x3456, (short)0x7800}; + (short) 0xCDF1, (short) 0xF0C1, (short) 0x0F12, (short) 0x3456, (short) 0x7800}; assertEquals(0x00000000, Conversion.shortArrayToInt(src, 0, 0, 0, 0)); assertEquals(0x0000CDF1, Conversion.shortArrayToInt(src, 0, 0, 0, 1)); assertEquals(0xF0C1CDF1, Conversion.shortArrayToInt(src, 0, 0, 0, 2)); assertEquals(0x0F12F0C1, Conversion.shortArrayToInt(src, 1, 0, 0, 2)); assertEquals(0x12345678, Conversion.shortArrayToInt(src, 0, 0x12345678, 0, 0)); assertEquals(0xCDF15678, Conversion.shortArrayToInt(src, 0, 0x12345678, 16, 1)); - // assertEquals(0x34567800,Conversion.ShortArrayToInt(src, 3, 0x12345678, 16, 2)); + // assertEquals(0x34567800, Conversion.ShortArrayToInt(src, 3, 0x12345678, 16, 2)); } /** @@ -555,15 +555,15 @@ public class ConversionTest { @Test public void testByteArrayToInt() { final byte[] src = new byte[]{ - (byte)0xCD, (byte)0xF1, (byte)0xF0, (byte)0xC1, (byte)0x0F, (byte)0x12, (byte)0x34, - (byte)0x56, (byte)0x78}; + (byte) 0xCD, (byte) 0xF1, (byte) 0xF0, (byte) 0xC1, (byte) 0x0F, (byte) 0x12, (byte) 0x34, + (byte) 0x56, (byte) 0x78}; assertEquals(0x00000000, Conversion.byteArrayToInt(src, 0, 0, 0, 0)); assertEquals(0x000000CD, Conversion.byteArrayToInt(src, 0, 0, 0, 1)); assertEquals(0xC1F0F1CD, Conversion.byteArrayToInt(src, 0, 0, 0, 4)); assertEquals(0x0FC1F0F1, Conversion.byteArrayToInt(src, 1, 0, 0, 4)); assertEquals(0x12345678, Conversion.byteArrayToInt(src, 0, 0x12345678, 0, 0)); assertEquals(0xCD345678, Conversion.byteArrayToInt(src, 0, 0x12345678, 24, 1)); - // assertEquals(0x56341278,Conversion.ByteArrayToInt(src, 5, 0x01234567, 8, 4)); + // assertEquals(0x56341278, Conversion.ByteArrayToInt(src, 5, 0x01234567, 8, 4)); } /** @@ -572,15 +572,15 @@ public class ConversionTest { @Test public void testByteArrayToShort() { final byte[] src = new byte[]{ - (byte)0xCD, (byte)0xF1, (byte)0xF0, (byte)0xC1, (byte)0x0F, (byte)0x12, (byte)0x34, - (byte)0x56, (byte)0x78}; - assertEquals((short)0x0000, Conversion.byteArrayToShort(src, 0, (short)0, 0, 0)); - assertEquals((short)0x00CD, Conversion.byteArrayToShort(src, 0, (short)0, 0, 1)); - assertEquals((short)0xF1CD, Conversion.byteArrayToShort(src, 0, (short)0, 0, 2)); - assertEquals((short)0xF0F1, Conversion.byteArrayToShort(src, 1, (short)0, 0, 2)); - assertEquals((short)0x1234, Conversion.byteArrayToShort(src, 0, (short)0x1234, 0, 0)); - assertEquals((short)0xCD34, Conversion.byteArrayToShort(src, 0, (short)0x1234, 8, 1)); - // assertEquals((short)0x5678,Conversion.ByteArrayToShort(src, 7, (short) 0x0123, 8, + (byte) 0xCD, (byte) 0xF1, (byte) 0xF0, (byte) 0xC1, (byte) 0x0F, (byte) 0x12, (byte) 0x34, + (byte) 0x56, (byte) 0x78}; + assertEquals((short) 0x0000, Conversion.byteArrayToShort(src, 0, (short) 0, 0, 0)); + assertEquals((short) 0x00CD, Conversion.byteArrayToShort(src, 0, (short) 0, 0, 1)); + assertEquals((short) 0xF1CD, Conversion.byteArrayToShort(src, 0, (short) 0, 0, 2)); + assertEquals((short) 0xF0F1, Conversion.byteArrayToShort(src, 1, (short) 0, 0, 2)); + assertEquals((short) 0x1234, Conversion.byteArrayToShort(src, 0, (short) 0x1234, 0, 0)); + assertEquals((short) 0xCD34, Conversion.byteArrayToShort(src, 0, (short) 0x1234, 8, 1)); + // assertEquals((short) 0x5678, Conversion.ByteArrayToShort(src, 7, (short) 0x0123, 8, // 2)); } @@ -620,12 +620,12 @@ public class ConversionTest { @Test public void testHexToShort() { final String src = "CDF1F0C10F12345678"; - assertEquals((short)0x0000, Conversion.hexToShort(src, 0, (short)0, 0, 0)); - assertEquals((short)0x000C, Conversion.hexToShort(src, 0, (short)0, 0, 1)); - assertEquals((short)0x1FDC, Conversion.hexToShort(src, 0, (short)0, 0, 4)); - assertEquals((short)0xF1FD, Conversion.hexToShort(src, 1, (short)0, 0, 4)); - assertEquals((short)0x1234, Conversion.hexToShort(src, 0, (short)0x1234, 0, 0)); - assertEquals((short)0x8764, Conversion.hexToShort(src, 15, (short)0x1234, 4, 3)); + assertEquals((short) 0x0000, Conversion.hexToShort(src, 0, (short) 0, 0, 0)); + assertEquals((short) 0x000C, Conversion.hexToShort(src, 0, (short) 0, 0, 1)); + assertEquals((short) 0x1FDC, Conversion.hexToShort(src, 0, (short) 0, 0, 4)); + assertEquals((short) 0xF1FD, Conversion.hexToShort(src, 1, (short) 0, 0, 4)); + assertEquals((short) 0x1234, Conversion.hexToShort(src, 0, (short) 0x1234, 0, 0)); + assertEquals((short) 0x8764, Conversion.hexToShort(src, 15, (short) 0x1234, 4, 3)); } /** @@ -634,12 +634,12 @@ public class ConversionTest { @Test public void testHexToByte() { final String src = "CDF1F0C10F12345678"; - assertEquals((byte)0x00, Conversion.hexToByte(src, 0, (byte)0, 0, 0)); - assertEquals((byte)0x0C, Conversion.hexToByte(src, 0, (byte)0, 0, 1)); - assertEquals((byte)0xDC, Conversion.hexToByte(src, 0, (byte)0, 0, 2)); - assertEquals((byte)0xFD, Conversion.hexToByte(src, 1, (byte)0, 0, 2)); - assertEquals((byte)0x34, Conversion.hexToByte(src, 0, (byte)0x34, 0, 0)); - assertEquals((byte)0x84, Conversion.hexToByte(src, 17, (byte)0x34, 4, 1)); + assertEquals((byte) 0x00, Conversion.hexToByte(src, 0, (byte) 0, 0, 0)); + assertEquals((byte) 0x0C, Conversion.hexToByte(src, 0, (byte) 0, 0, 1)); + assertEquals((byte) 0xDC, Conversion.hexToByte(src, 0, (byte) 0, 0, 2)); + assertEquals((byte) 0xFD, Conversion.hexToByte(src, 1, (byte) 0, 0, 2)); + assertEquals((byte) 0x34, Conversion.hexToByte(src, 0, (byte) 0x34, 0, 0)); + assertEquals((byte) 0x84, Conversion.hexToByte(src, 17, (byte) 0x34, 4, 1)); } /** @@ -700,14 +700,14 @@ public class ConversionTest { false, false, false, false, true, false, true, false, true, false, false, true, true, false, true, true, true, false, false, false, false, true}; // conversion of "CDF1F0C10F12345678" by HexToBinary - assertEquals((short)0x0000, Conversion.binaryToShort(src, 0 * 4, (short)0, 0, 0 * 4)); - assertEquals((short)0x000C, Conversion.binaryToShort(src, 0 * 4, (short)0, 0, 1 * 4)); - assertEquals((short)0x1FDC, Conversion.binaryToShort(src, 0 * 4, (short)0, 0, 4 * 4)); - assertEquals((short)0xF1FD, Conversion.binaryToShort(src, 1 * 4, (short)0, 0, 4 * 4)); + assertEquals((short) 0x0000, Conversion.binaryToShort(src, 0 * 4, (short) 0, 0, 0 * 4)); + assertEquals((short) 0x000C, Conversion.binaryToShort(src, 0 * 4, (short) 0, 0, 1 * 4)); + assertEquals((short) 0x1FDC, Conversion.binaryToShort(src, 0 * 4, (short) 0, 0, 4 * 4)); + assertEquals((short) 0xF1FD, Conversion.binaryToShort(src, 1 * 4, (short) 0, 0, 4 * 4)); assertEquals( - (short)0x1234, Conversion.binaryToShort(src, 0 * 4, (short)0x1234, 0, 0 * 4)); + (short) 0x1234, Conversion.binaryToShort(src, 0 * 4, (short) 0x1234, 0, 0 * 4)); assertEquals( - (short)0x8764, Conversion.binaryToShort(src, 15 * 4, (short)0x1234, 4, 3 * 4)); + (short) 0x8764, Conversion.binaryToShort(src, 15 * 4, (short) 0x1234, 4, 3 * 4)); } /** @@ -723,12 +723,12 @@ public class ConversionTest { false, false, false, false, true, false, true, false, true, false, false, true, true, false, true, true, true, false, false, false, false, true}; // conversion of "CDF1F0C10F12345678" by HexToBinary - assertEquals((byte)0x00, Conversion.binaryToByte(src, 0 * 4, (byte)0, 0, 0 * 4)); - assertEquals((byte)0x0C, Conversion.binaryToByte(src, 0 * 4, (byte)0, 0, 1 * 4)); - assertEquals((byte)0xDC, Conversion.binaryToByte(src, 0 * 4, (byte)0, 0, 2 * 4)); - assertEquals((byte)0xFD, Conversion.binaryToByte(src, 1 * 4, (byte)0, 0, 2 * 4)); - assertEquals((byte)0x34, Conversion.binaryToByte(src, 0 * 4, (byte)0x34, 0, 0 * 4)); - assertEquals((byte)0x84, Conversion.binaryToByte(src, 17 * 4, (byte)0x34, 4, 1 * 4)); + assertEquals((byte) 0x00, Conversion.binaryToByte(src, 0 * 4, (byte) 0, 0, 0 * 4)); + assertEquals((byte) 0x0C, Conversion.binaryToByte(src, 0 * 4, (byte) 0, 0, 1 * 4)); + assertEquals((byte) 0xDC, Conversion.binaryToByte(src, 0 * 4, (byte) 0, 0, 2 * 4)); + assertEquals((byte) 0xFD, Conversion.binaryToByte(src, 1 * 4, (byte) 0, 0, 2 * 4)); + assertEquals((byte) 0x34, Conversion.binaryToByte(src, 0 * 4, (byte) 0x34, 0, 0 * 4)); + assertEquals((byte) 0x84, Conversion.binaryToByte(src, 17 * 4, (byte) 0x34, 4, 1 * 4)); } /** @@ -752,11 +752,11 @@ public class ConversionTest { new int[]{0x90ABCDEF, 0x12345678, 0xFFFFFFFF, 0xFFFFFFFF}, Conversion.longToIntArray(0x1234567890ABCDEFL, 0, new int[]{-1, -1, -1, -1}, 0, 2)); // assertArrayEquals(new - // int[]{0x90ABCDEF,0x12345678,0x90ABCDEF,0x12345678},Conversion.longToIntArray(0x1234567890ABCDEFL, - // 0,new int[]{-1,-1,-1,-1},0,4));//rejected by assertion + // int[]{0x90ABCDEF, 0x12345678, 0x90ABCDEF, 0x12345678}, Conversion.longToIntArray(0x1234567890ABCDEFL, + // 0, new int[]{-1, -1, -1, -1}, 0, 4));//rejected by assertion // assertArrayEquals(new - // int[]{0xFFFFFFFF,0x90ABCDEF,0x12345678,0x90ABCDEF},Conversion.longToIntArray(0x1234567890ABCDEFL, - // 0,new int[]{-1,-1,-1,-1},1,3)); + // int[]{0xFFFFFFFF, 0x90ABCDEF, 0x12345678, 0x90ABCDEF}, Conversion.longToIntArray(0x1234567890ABCDEFL, + // 0, new int[]{-1, -1, -1, -1}, 1, 3)); assertArrayEquals( new int[]{0xFFFFFFFF, 0xFFFFFFFF, 0x90ABCDEF, 0x12345678}, Conversion.longToIntArray(0x1234567890ABCDEFL, 0, new int[]{-1, -1, -1, -1}, 2, 2)); @@ -779,8 +779,8 @@ public class ConversionTest { new int[]{0xFFFFFFFF, 0xFFFFFFFF, 0x890ABCDE, 0xFFFFFFFF}, Conversion.longToIntArray(0x1234567890ABCDEFL, 4, new int[]{-1, -1, -1, -1}, 2, 1)); // assertArrayEquals(new - // int[]{0x4855E6F7,0x091A2B3C,0x4855E6F7,0x091A2B3C},Conversion.longToIntArray(0x1234567890ABCDEFL, - // 1,new int[]{-1,-1,-1,-1},0,4));//rejected by assertion + // int[]{0x4855E6F7, 0x091A2B3C, 0x4855E6F7, 0x091A2B3C}, Conversion.longToIntArray(0x1234567890ABCDEFL, + // 1, new int[]{-1, -1, -1, -1}, 0, 4));//rejected by assertion assertArrayEquals( new int[]{0x091A2B3C}, Conversion.longToIntArray(0x1234567890ABCDEFL, 33, new int[]{0}, 0, 1)); @@ -801,63 +801,63 @@ public class ConversionTest { new short[]{}, Conversion.longToShortArray(0x0000000000000000L, 0, new short[]{}, 100, 0)); assertArrayEquals( - new short[]{(short)0xFFFF, (short)0xFFFF, (short)0xFFFF, (short)0xFFFF}, + new short[]{(short) 0xFFFF, (short) 0xFFFF, (short) 0xFFFF, (short) 0xFFFF}, Conversion.longToShortArray( 0x1234567890ABCDEFL, 0, new short[]{-1, -1, -1, -1}, 0, 0)); assertArrayEquals( - new short[]{(short)0xCDEF, (short)0xFFFF, (short)0xFFFF, (short)0xFFFF}, + new short[]{(short) 0xCDEF, (short) 0xFFFF, (short) 0xFFFF, (short) 0xFFFF}, Conversion.longToShortArray( 0x1234567890ABCDEFL, 0, new short[]{-1, -1, -1, -1}, 0, 1)); assertArrayEquals( - new short[]{(short)0xCDEF, (short)0x90AB, (short)0xFFFF, (short)0xFFFF}, + new short[]{(short) 0xCDEF, (short) 0x90AB, (short) 0xFFFF, (short) 0xFFFF}, Conversion.longToShortArray( 0x1234567890ABCDEFL, 0, new short[]{-1, -1, -1, -1}, 0, 2)); assertArrayEquals( - new short[]{(short)0xCDEF, (short)0x90AB, (short)0x5678, (short)0xFFFF}, + new short[]{(short) 0xCDEF, (short) 0x90AB, (short) 0x5678, (short) 0xFFFF}, Conversion.longToShortArray( 0x1234567890ABCDEFL, 0, new short[]{-1, -1, -1, -1}, 0, 3)); assertArrayEquals( - new short[]{(short)0xCDEF, (short)0x90AB, (short)0x5678, (short)0x1234}, + new short[]{(short) 0xCDEF, (short) 0x90AB, (short) 0x5678, (short) 0x1234}, Conversion.longToShortArray( 0x1234567890ABCDEFL, 0, new short[]{-1, -1, -1, -1}, 0, 4)); assertArrayEquals( - new short[]{(short)0xFFFF, (short)0xCDEF, (short)0x90AB, (short)0x5678}, + new short[]{(short) 0xFFFF, (short) 0xCDEF, (short) 0x90AB, (short) 0x5678}, Conversion.longToShortArray( 0x1234567890ABCDEFL, 0, new short[]{-1, -1, -1, -1}, 1, 3)); assertArrayEquals( - new short[]{(short)0xFFFF, (short)0xFFFF, (short)0xCDEF, (short)0x90AB}, + new short[]{(short) 0xFFFF, (short) 0xFFFF, (short) 0xCDEF, (short) 0x90AB}, Conversion.longToShortArray( 0x1234567890ABCDEFL, 0, new short[]{-1, -1, -1, -1}, 2, 2)); assertArrayEquals( - new short[]{(short)0xFFFF, (short)0xFFFF, (short)0xCDEF, (short)0xFFFF}, + new short[]{(short) 0xFFFF, (short) 0xFFFF, (short) 0xCDEF, (short) 0xFFFF}, Conversion.longToShortArray( 0x1234567890ABCDEFL, 0, new short[]{-1, -1, -1, -1}, 2, 1)); assertArrayEquals( - new short[]{(short)0xFFFF, (short)0xFFFF, (short)0xFFFF, (short)0xCDEF}, + new short[]{(short) 0xFFFF, (short) 0xFFFF, (short) 0xFFFF, (short) 0xCDEF}, Conversion.longToShortArray( 0x1234567890ABCDEFL, 0, new short[]{-1, -1, -1, -1}, 3, 1)); assertArrayEquals( - new short[]{(short)0xFFFF, (short)0xFFFF, (short)0xE6F7, (short)0xFFFF}, + new short[]{(short) 0xFFFF, (short) 0xFFFF, (short) 0xE6F7, (short) 0xFFFF}, Conversion.longToShortArray( 0x1234567890ABCDEFL, 1, new short[]{-1, -1, -1, -1}, 2, 1)); assertArrayEquals( - new short[]{(short)0xFFFF, (short)0xFFFF, (short)0xF37B, (short)0xFFFF}, + new short[]{(short) 0xFFFF, (short) 0xFFFF, (short) 0xF37B, (short) 0xFFFF}, Conversion.longToShortArray( 0x1234567890ABCDEFL, 2, new short[]{-1, -1, -1, -1}, 2, 1)); assertArrayEquals( - new short[]{(short)0xFFFF, (short)0xFFFF, (short)0x79BD, (short)0xFFFF}, + new short[]{(short) 0xFFFF, (short) 0xFFFF, (short) 0x79BD, (short) 0xFFFF}, Conversion.longToShortArray( 0x1234567890ABCDEFL, 3, new short[]{-1, -1, -1, -1}, 2, 1)); assertArrayEquals( - new short[]{(short)0xFFFF, (short)0xFFFF, (short)0xBCDE, (short)0xFFFF}, + new short[]{(short) 0xFFFF, (short) 0xFFFF, (short) 0xBCDE, (short) 0xFFFF}, Conversion.longToShortArray( 0x1234567890ABCDEFL, 4, new short[]{-1, -1, -1, -1}, 2, 1)); assertArrayEquals( - new short[]{(short)0xE6F7, (short)0x4855, (short)0x2B3C, (short)0x091A}, + new short[]{(short) 0xE6F7, (short) 0x4855, (short) 0x2B3C, (short) 0x091A}, Conversion.longToShortArray( 0x1234567890ABCDEFL, 1, new short[]{-1, -1, -1, -1}, 0, 4)); assertArrayEquals( - new short[]{(short)0x2B3C}, + new short[]{(short) 0x2B3C}, Conversion.longToShortArray(0x1234567890ABCDEFL, 33, new short[]{0}, 0, 1)); } @@ -873,52 +873,52 @@ public class ConversionTest { assertArrayEquals( new short[]{}, Conversion.intToShortArray(0x00000000, 0, new short[]{}, 100, 0)); assertArrayEquals( - new short[]{(short)0xFFFF, (short)0xFFFF, (short)0xFFFF, (short)0xFFFF}, + new short[]{(short) 0xFFFF, (short) 0xFFFF, (short) 0xFFFF, (short) 0xFFFF}, Conversion.intToShortArray(0x12345678, 0, new short[]{-1, -1, -1, -1}, 0, 0)); assertArrayEquals( - new short[]{(short)0x5678, (short)0xFFFF, (short)0xFFFF, (short)0xFFFF}, + new short[]{(short) 0x5678, (short) 0xFFFF, (short) 0xFFFF, (short) 0xFFFF}, Conversion.intToShortArray(0x12345678, 0, new short[]{-1, -1, -1, -1}, 0, 1)); assertArrayEquals( - new short[]{(short)0x5678, (short)0x1234, (short)0xFFFF, (short)0xFFFF}, + new short[]{(short) 0x5678, (short) 0x1234, (short) 0xFFFF, (short) 0xFFFF}, Conversion.intToShortArray(0x12345678, 0, new short[]{-1, -1, -1, -1}, 0, 2)); // assertArrayEquals(new - // short[]{(short)0x5678,(short)0x1234,(short)0x5678,(short)0xFFFF},Conversion.intToShortArray(0x12345678, - // 0,new short[]{-1,-1,-1,-1},0,3));//rejected by assertion + // short[]{(short) 0x5678, (short) 0x1234, (short) 0x5678, (short) 0xFFFF}, Conversion.intToShortArray(0x12345678, + // 0, new short[]{-1, -1, -1, -1}, 0, 3));//rejected by assertion // assertArrayEquals(new - // short[]{(short)0x5678,(short)0x1234,(short)0x5678,(short)0x1234},Conversion.intToShortArray(0x12345678, - // 0,new short[]{-1,-1,-1,-1},0,4)); + // short[]{(short) 0x5678, (short) 0x1234, (short) 0x5678, (short) 0x1234}, Conversion.intToShortArray(0x12345678, + // 0, new short[]{-1, -1, -1, -1}, 0, 4)); // assertArrayEquals(new - // short[]{(short)0xFFFF,(short)0x5678,(short)0x1234,(short)0x5678},Conversion.intToShortArray(0x12345678, - // 0,new short[]{-1,-1,-1,-1},1,3)); + // short[]{(short) 0xFFFF, (short) 0x5678, (short) 0x1234, (short) 0x5678}, Conversion.intToShortArray(0x12345678, + // 0, new short[]{-1, -1, -1, -1}, 1, 3)); assertArrayEquals( - new short[]{(short)0xFFFF, (short)0xFFFF, (short)0x5678, (short)0x1234}, + new short[]{(short) 0xFFFF, (short) 0xFFFF, (short) 0x5678, (short) 0x1234}, Conversion.intToShortArray(0x12345678, 0, new short[]{-1, -1, -1, -1}, 2, 2)); assertArrayEquals( - new short[]{(short)0xFFFF, (short)0xFFFF, (short)0x5678, (short)0xFFFF}, + new short[]{(short) 0xFFFF, (short) 0xFFFF, (short) 0x5678, (short) 0xFFFF}, Conversion.intToShortArray(0x12345678, 0, new short[]{-1, -1, -1, -1}, 2, 1)); assertArrayEquals( - new short[]{(short)0xFFFF, (short)0xFFFF, (short)0xFFFF, (short)0x5678}, + new short[]{(short) 0xFFFF, (short) 0xFFFF, (short) 0xFFFF, (short) 0x5678}, Conversion.intToShortArray(0x12345678, 0, new short[]{-1, -1, -1, -1}, 3, 1)); assertArrayEquals( - new short[]{(short)0xFFFF, (short)0xFFFF, (short)0x2B3C, (short)0xFFFF}, + new short[]{(short) 0xFFFF, (short) 0xFFFF, (short) 0x2B3C, (short) 0xFFFF}, Conversion.intToShortArray(0x12345678, 1, new short[]{-1, -1, -1, -1}, 2, 1)); assertArrayEquals( - new short[]{(short)0xFFFF, (short)0xFFFF, (short)0x159E, (short)0xFFFF}, + new short[]{(short) 0xFFFF, (short) 0xFFFF, (short) 0x159E, (short) 0xFFFF}, Conversion.intToShortArray(0x12345678, 2, new short[]{-1, -1, -1, -1}, 2, 1)); assertArrayEquals( - new short[]{(short)0xFFFF, (short)0xFFFF, (short)0x8ACF, (short)0xFFFF}, + new short[]{(short) 0xFFFF, (short) 0xFFFF, (short) 0x8ACF, (short) 0xFFFF}, Conversion.intToShortArray(0x12345678, 3, new short[]{-1, -1, -1, -1}, 2, 1)); assertArrayEquals( - new short[]{(short)0xFFFF, (short)0xFFFF, (short)0x4567, (short)0xFFFF}, + new short[]{(short) 0xFFFF, (short) 0xFFFF, (short) 0x4567, (short) 0xFFFF}, Conversion.intToShortArray(0x12345678, 4, new short[]{-1, -1, -1, -1}, 2, 1)); // assertArrayEquals(new - // short[]{(short)0xE6F7,(short)0x4855,(short)0x2B3C,(short)0x091A},Conversion.intToShortArray(0x12345678, - // 1,new short[]{-1,-1,-1,-1},0,4));//rejected by assertion + // short[]{(short) 0xE6F7, (short) 0x4855, (short) 0x2B3C, (short) 0x091A}, Conversion.intToShortArray(0x12345678, + // 1, new short[]{-1, -1, -1, -1}, 0, 4));//rejected by assertion // assertArrayEquals(new - // short[]{(short)0x2B3C},Conversion.intToShortArray(0x12345678,33,new - // short[]{0},0,1));//rejected by assertion + // short[]{(short) 0x2B3C}, Conversion.intToShortArray(0x12345678, 33, new + // short[]{0}, 0, 1));//rejected by assertion assertArrayEquals( - new short[]{(short)0x091A}, + new short[]{(short) 0x091A}, Conversion.intToShortArray(0x12345678, 17, new short[]{0}, 0, 1)); } @@ -938,95 +938,95 @@ public class ConversionTest { Conversion.longToByteArray(0x0000000000000000L, 0, new byte[]{}, 100, 0)); assertArrayEquals( new byte[]{ - (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, - (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF}, + (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, + (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF}, Conversion.longToByteArray(0x1234567890ABCDEFL, 0, new byte[]{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 0, 0)); assertArrayEquals( new byte[]{ - (byte)0xEF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, - (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF}, + (byte) 0xEF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, + (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF}, Conversion.longToByteArray(0x1234567890ABCDEFL, 0, new byte[]{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 0, 1)); assertArrayEquals( new byte[]{ - (byte)0xEF, (byte)0xCD, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, - (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF}, + (byte) 0xEF, (byte) 0xCD, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, + (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF}, Conversion.longToByteArray(0x1234567890ABCDEFL, 0, new byte[]{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 0, 2)); assertArrayEquals( new byte[]{ - (byte)0xEF, (byte)0xCD, (byte)0xAB, (byte)0x90, (byte)0xFF, (byte)0xFF, - (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF}, + (byte) 0xEF, (byte) 0xCD, (byte) 0xAB, (byte) 0x90, (byte) 0xFF, (byte) 0xFF, + (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF}, Conversion.longToByteArray(0x1234567890ABCDEFL, 0, new byte[]{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 0, 4)); assertArrayEquals( new byte[]{ - (byte)0xEF, (byte)0xCD, (byte)0xAB, (byte)0x90, (byte)0x78, (byte)0x56, - (byte)0x34, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF}, + (byte) 0xEF, (byte) 0xCD, (byte) 0xAB, (byte) 0x90, (byte) 0x78, (byte) 0x56, + (byte) 0x34, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF}, Conversion.longToByteArray(0x1234567890ABCDEFL, 0, new byte[]{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 0, 7)); assertArrayEquals( new byte[]{ - (byte)0xEF, (byte)0xCD, (byte)0xAB, (byte)0x90, (byte)0x78, (byte)0x56, - (byte)0x34, (byte)0x12, (byte)0xFF, (byte)0xFF, (byte)0xFF}, + (byte) 0xEF, (byte) 0xCD, (byte) 0xAB, (byte) 0x90, (byte) 0x78, (byte) 0x56, + (byte) 0x34, (byte) 0x12, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF}, Conversion.longToByteArray(0x1234567890ABCDEFL, 0, new byte[]{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 0, 8)); assertArrayEquals( new byte[]{ - (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xEF, (byte)0xFF, (byte)0xFF, - (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF}, + (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xEF, (byte) 0xFF, (byte) 0xFF, + (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF}, Conversion.longToByteArray(0x1234567890ABCDEFL, 0, new byte[]{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 3, 1)); assertArrayEquals( new byte[]{ - (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xEF, (byte)0xCD, (byte)0xFF, - (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF}, + (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xEF, (byte) 0xCD, (byte) 0xFF, + (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF}, Conversion.longToByteArray(0x1234567890ABCDEFL, 0, new byte[]{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 3, 2)); assertArrayEquals( new byte[]{ - (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xEF, (byte)0xCD, (byte)0xAB, - (byte)0x90, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF}, + (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xEF, (byte) 0xCD, (byte) 0xAB, + (byte) 0x90, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF}, Conversion.longToByteArray(0x1234567890ABCDEFL, 0, new byte[]{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 3, 4)); assertArrayEquals( new byte[]{ - (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xEF, (byte)0xCD, (byte)0xAB, - (byte)0x90, (byte)0x78, (byte)0x56, (byte)0x34, (byte)0xFF}, + (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xEF, (byte) 0xCD, (byte) 0xAB, + (byte) 0x90, (byte) 0x78, (byte) 0x56, (byte) 0x34, (byte) 0xFF}, Conversion.longToByteArray(0x1234567890ABCDEFL, 0, new byte[]{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 3, 7)); assertArrayEquals( new byte[]{ - (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xEF, (byte)0xCD, (byte)0xAB, - (byte)0x90, (byte)0x78, (byte)0x56, (byte)0x34, (byte)0x12}, + (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xEF, (byte) 0xCD, (byte) 0xAB, + (byte) 0x90, (byte) 0x78, (byte) 0x56, (byte) 0x34, (byte) 0x12}, Conversion.longToByteArray(0x1234567890ABCDEFL, 0, new byte[]{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 3, 8)); assertArrayEquals( new byte[]{ - (byte)0xF7, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, - (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF}, + (byte) 0xF7, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, + (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF}, Conversion.longToByteArray(0x1234567890ABCDEFL, 1, new byte[]{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 0, 1)); assertArrayEquals( new byte[]{ - (byte)0x7B, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, - (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF}, + (byte) 0x7B, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, + (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF}, Conversion.longToByteArray(0x1234567890ABCDEFL, 2, new byte[]{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 0, 1)); assertArrayEquals( new byte[]{ - (byte)0xFF, (byte)0x00, (byte)0xFF, (byte)0x6F, (byte)0x5E, (byte)0x85, - (byte)0xC4, (byte)0xB3, (byte)0xA2, (byte)0x91, (byte)0x00}, + (byte) 0xFF, (byte) 0x00, (byte) 0xFF, (byte) 0x6F, (byte) 0x5E, (byte) 0x85, + (byte) 0xC4, (byte) 0xB3, (byte) 0xA2, (byte) 0x91, (byte) 0x00}, Conversion.longToByteArray(0x1234567890ABCDEFL, 5, new byte[]{ -1, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 3, 8)); // assertArrayEquals(new - // byte[]{(byte)0xFF,(byte)0x00,(byte)0xFF,(byte)0x5E,(byte)0x85,(byte)0xC4,(byte)0xB3,(byte)0xA2,(byte)0x91,(byte)0x00,(byte)0x00},Conversion.longToByteArray(0x1234567890ABCDEFL,13,new - // byte[]{-1, 0,-1,-1,-1,-1,-1,-1,-1,-1,-1},3,8));//rejected by assertion + // byte[]{(byte) 0xFF, (byte) 0x00, (byte) 0xFF, (byte) 0x5E, (byte) 0x85, (byte) 0xC4, (byte) 0xB3, (byte) 0xA2, (byte) 0x91, (byte) 0x00, (byte) 0x00}, Conversion.longToByteArray(0x1234567890ABCDEFL, 13, new + // byte[]{-1, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 3, 8));//rejected by assertion assertArrayEquals( new byte[]{ - (byte)0xFF, (byte)0x00, (byte)0xFF, (byte)0x5E, (byte)0x85, (byte)0xC4, - (byte)0xB3, (byte)0xA2, (byte)0x91, (byte)0x00, (byte)0xFF}, + (byte) 0xFF, (byte) 0x00, (byte) 0xFF, (byte) 0x5E, (byte) 0x85, (byte) 0xC4, + (byte) 0xB3, (byte) 0xA2, (byte) 0x91, (byte) 0x00, (byte) 0xFF}, Conversion.longToByteArray(0x1234567890ABCDEFL, 13, new byte[]{ -1, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 3, 7)); } @@ -1044,71 +1044,71 @@ public class ConversionTest { new byte[]{}, Conversion.intToByteArray(0x00000000, 0, new byte[]{}, 100, 0)); assertArrayEquals( new byte[]{ - (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, - (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF}, + (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, + (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF}, Conversion.intToByteArray(0x90ABCDEF, 0, new byte[]{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 0, 0)); assertArrayEquals( new byte[]{ - (byte)0xEF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, - (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF}, + (byte) 0xEF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, + (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF}, Conversion.intToByteArray(0x90ABCDEF, 0, new byte[]{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 0, 1)); assertArrayEquals( new byte[]{ - (byte)0xEF, (byte)0xCD, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, - (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF}, + (byte) 0xEF, (byte) 0xCD, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, + (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF}, Conversion.intToByteArray(0x90ABCDEF, 0, new byte[]{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 0, 2)); assertArrayEquals( new byte[]{ - (byte)0xEF, (byte)0xCD, (byte)0xAB, (byte)0x90, (byte)0xFF, (byte)0xFF, - (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF}, + (byte) 0xEF, (byte) 0xCD, (byte) 0xAB, (byte) 0x90, (byte) 0xFF, (byte) 0xFF, + (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF}, Conversion.intToByteArray(0x90ABCDEF, 0, new byte[]{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 0, 4)); assertArrayEquals( new byte[]{ - (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xEF, (byte)0xFF, (byte)0xFF, - (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF}, + (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xEF, (byte) 0xFF, (byte) 0xFF, + (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF}, Conversion.intToByteArray(0x90ABCDEF, 0, new byte[]{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 3, 1)); assertArrayEquals( new byte[]{ - (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xEF, (byte)0xCD, (byte)0xFF, - (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF}, + (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xEF, (byte) 0xCD, (byte) 0xFF, + (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF}, Conversion.intToByteArray(0x90ABCDEF, 0, new byte[]{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 3, 2)); assertArrayEquals( new byte[]{ - (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xEF, (byte)0xCD, (byte)0xAB, - (byte)0x90, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF}, + (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xEF, (byte) 0xCD, (byte) 0xAB, + (byte) 0x90, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF}, Conversion.intToByteArray(0x90ABCDEF, 0, new byte[]{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 3, 4)); assertArrayEquals( new byte[]{ - (byte)0xF7, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, - (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF}, + (byte) 0xF7, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, + (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF}, Conversion.intToByteArray(0x90ABCDEF, 1, new byte[]{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 0, 1)); assertArrayEquals( new byte[]{ - (byte)0x7B, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, - (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF}, + (byte) 0x7B, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, + (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF}, Conversion.intToByteArray(0x90ABCDEF, 2, new byte[]{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 0, 1)); assertArrayEquals( new byte[]{ - (byte)0xFF, (byte)0x00, (byte)0xFF, (byte)0x6F, (byte)0x5E, (byte)0x85, - (byte)0xFC, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF}, + (byte) 0xFF, (byte) 0x00, (byte) 0xFF, (byte) 0x6F, (byte) 0x5E, (byte) 0x85, + (byte) 0xFC, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF}, Conversion.intToByteArray(0x90ABCDEF, 5, new byte[]{ -1, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 3, 4)); // assertArrayEquals(new - // byte[]{(byte)0xFF,(byte)0x00,(byte)0xFF,(byte)0x5E,(byte)0x85,(byte)0xFC,(byte)0x00,(byte)0xFF,(byte)0xFF,(byte)0xFF,(byte)0xFF},Conversion.intToByteArray(0x90ABCDEF,13,new - // byte[]{-1, 0,-1,-1,-1,-1,-1,-1,-1,-1,-1},3,4));//rejected by assertion + // byte[]{(byte) 0xFF, (byte) 0x00, (byte) 0xFF, (byte) 0x5E, (byte) 0x85, (byte) 0xFC, (byte) 0x00, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF}, Conversion.intToByteArray(0x90ABCDEF, 13, new + // byte[]{-1, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 3, 4));//rejected by assertion assertArrayEquals( new byte[]{ - (byte)0xFF, (byte)0x00, (byte)0xFF, (byte)0x5E, (byte)0x85, (byte)0xFC, - (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF}, + (byte) 0xFF, (byte) 0x00, (byte) 0xFF, (byte) 0x5E, (byte) 0x85, (byte) 0xFC, + (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF}, Conversion.intToByteArray(0x90ABCDEF, 13, new byte[]{ -1, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 3, 3)); } @@ -1119,58 +1119,58 @@ public class ConversionTest { @Test public void testShortToByteArray() { assertArrayEquals( - new byte[]{}, Conversion.shortToByteArray((short)0x0000, 0, new byte[]{}, 0, 0)); + new byte[]{}, Conversion.shortToByteArray((short) 0x0000, 0, new byte[]{}, 0, 0)); assertArrayEquals( - new byte[]{}, Conversion.shortToByteArray((short)0x0000, 100, new byte[]{}, 0, 0)); + new byte[]{}, Conversion.shortToByteArray((short) 0x0000, 100, new byte[]{}, 0, 0)); assertArrayEquals( - new byte[]{}, Conversion.shortToByteArray((short)0x0000, 0, new byte[]{}, 100, 0)); + new byte[]{}, Conversion.shortToByteArray((short) 0x0000, 0, new byte[]{}, 100, 0)); assertArrayEquals( new byte[]{ - (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, - (byte)0xFF}, Conversion.shortToByteArray((short)0xCDEF, 0, new byte[]{ + (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, + (byte) 0xFF}, Conversion.shortToByteArray((short) 0xCDEF, 0, new byte[]{ -1, -1, -1, -1, -1, -1, -1}, 0, 0)); assertArrayEquals( new byte[]{ - (byte)0xEF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, - (byte)0xFF}, Conversion.shortToByteArray((short)0xCDEF, 0, new byte[]{ + (byte) 0xEF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, + (byte) 0xFF}, Conversion.shortToByteArray((short) 0xCDEF, 0, new byte[]{ -1, -1, -1, -1, -1, -1, -1}, 0, 1)); assertArrayEquals( new byte[]{ - (byte)0xEF, (byte)0xCD, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, - (byte)0xFF}, Conversion.shortToByteArray((short)0xCDEF, 0, new byte[]{ + (byte) 0xEF, (byte) 0xCD, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, + (byte) 0xFF}, Conversion.shortToByteArray((short) 0xCDEF, 0, new byte[]{ -1, -1, -1, -1, -1, -1, -1}, 0, 2)); assertArrayEquals( new byte[]{ - (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xEF, (byte)0xFF, (byte)0xFF, - (byte)0xFF}, Conversion.shortToByteArray((short)0xCDEF, 0, new byte[]{ + (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xEF, (byte) 0xFF, (byte) 0xFF, + (byte) 0xFF}, Conversion.shortToByteArray((short) 0xCDEF, 0, new byte[]{ -1, -1, -1, -1, -1, -1, -1}, 3, 1)); assertArrayEquals( new byte[]{ - (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xEF, (byte)0xCD, (byte)0xFF, - (byte)0xFF}, Conversion.shortToByteArray((short)0xCDEF, 0, new byte[]{ + (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xEF, (byte) 0xCD, (byte) 0xFF, + (byte) 0xFF}, Conversion.shortToByteArray((short) 0xCDEF, 0, new byte[]{ -1, -1, -1, -1, -1, -1, -1}, 3, 2)); assertArrayEquals( new byte[]{ - (byte)0xF7, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, - (byte)0xFF}, Conversion.shortToByteArray((short)0xCDEF, 1, new byte[]{ + (byte) 0xF7, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, + (byte) 0xFF}, Conversion.shortToByteArray((short) 0xCDEF, 1, new byte[]{ -1, -1, -1, -1, -1, -1, -1}, 0, 1)); assertArrayEquals( new byte[]{ - (byte)0x7B, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, - (byte)0xFF}, Conversion.shortToByteArray((short)0xCDEF, 2, new byte[]{ + (byte) 0x7B, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, + (byte) 0xFF}, Conversion.shortToByteArray((short) 0xCDEF, 2, new byte[]{ -1, -1, -1, -1, -1, -1, -1}, 0, 1)); assertArrayEquals( new byte[]{ - (byte)0xFF, (byte)0x00, (byte)0xFF, (byte)0x6F, (byte)0xFE, (byte)0xFF, - (byte)0xFF}, Conversion.shortToByteArray((short)0xCDEF, 5, new byte[]{ + (byte) 0xFF, (byte) 0x00, (byte) 0xFF, (byte) 0x6F, (byte) 0xFE, (byte) 0xFF, + (byte) 0xFF}, Conversion.shortToByteArray((short) 0xCDEF, 5, new byte[]{ -1, 0, -1, -1, -1, -1, -1}, 3, 2)); // assertArrayEquals(new - // byte[]{(byte)0xFF,(byte)0x00,(byte)0xFF,(byte)0x5E,(byte)0xFF,(byte)0xFF,(byte)0xFF},Conversion.shortToByteArray((short)0xCDEF,13,new - // byte[]{-1, 0,-1,-1,-1,-1,-1},3,2));//rejected by assertion + // byte[]{(byte) 0xFF, (byte) 0x00, (byte) 0xFF, (byte) 0x5E, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF}, Conversion.shortToByteArray((short) 0xCDEF, 13, new + // byte[]{-1, 0, -1, -1, -1, -1, -1}, 3, 2));//rejected by assertion assertArrayEquals( new byte[]{ - (byte)0xFF, (byte)0x00, (byte)0xFF, (byte)0xFE, (byte)0xFF, (byte)0xFF, - (byte)0xFF}, Conversion.shortToByteArray((short)0xCDEF, 13, new byte[]{ + (byte) 0xFF, (byte) 0x00, (byte) 0xFF, (byte) 0xFE, (byte) 0xFF, (byte) 0xFF, + (byte) 0xFF}, Conversion.shortToByteArray((short) 0xCDEF, 13, new byte[]{ -1, 0, -1, -1, -1, -1, -1}, 3, 1)); } @@ -1224,7 +1224,7 @@ public class ConversionTest { assertEquals( "fffdb975121fca86420fffff", Conversion.longToHex(0x1234567890ABCDEFL, 3, "ffffffffffffffffffffffff", 3, 16)); - // assertEquals("ffffffffffffffffffffffff",Conversion.longToHex(0x1234567890ABCDEFL,4,"ffffffffffffffffffffffff",3,16));//rejected + // assertEquals("ffffffffffffffffffffffff", Conversion.longToHex(0x1234567890ABCDEFL, 4, "ffffffffffffffffffffffff", 3, 16));//rejected // by assertion assertEquals( "fffedcba0987654321ffffff", @@ -1284,8 +1284,8 @@ public class ConversionTest { assertEquals( "fffdb97512ffffffffffffff", Conversion.intToHex(0x90ABCDEF, 3, "ffffffffffffffffffffffff", 3, 8)); - // assertEquals("ffffffffffffffffffffffff",Conversion.intToHex(0x90ABCDEF, - // 4,"ffffffffffffffffffffffff",3,8));//rejected by assertion + // assertEquals("ffffffffffffffffffffffff", Conversion.intToHex(0x90ABCDEF, + // 4, "ffffffffffffffffffffffff", 3, 8));//rejected by assertion assertEquals( "fffedcba09ffffffffffffff", Conversion.intToHex(0x90ABCDEF, 4, "ffffffffffffffffffffffff", 3, 7)); @@ -1298,46 +1298,46 @@ public class ConversionTest { */ @Test public void testShortToHex() { - assertEquals("", Conversion.shortToHex((short)0x0000, 0, "", 0, 0)); - assertEquals("", Conversion.shortToHex((short)0x0000, 100, "", 0, 0)); - assertEquals("", Conversion.shortToHex((short)0x0000, 0, "", 100, 0)); + assertEquals("", Conversion.shortToHex((short) 0x0000, 0, "", 0, 0)); + assertEquals("", Conversion.shortToHex((short) 0x0000, 100, "", 0, 0)); + assertEquals("", Conversion.shortToHex((short) 0x0000, 0, "", 100, 0)); assertEquals( "ffffffffffffffffffffffff", - Conversion.shortToHex((short)0xCDEF, 0, "ffffffffffffffffffffffff", 0, 0)); + Conversion.shortToHex((short) 0xCDEF, 0, "ffffffffffffffffffffffff", 0, 0)); assertEquals( "3fffffffffffffffffffffff", - Conversion.shortToHex((short)0xCDE3, 0, "ffffffffffffffffffffffff", 0, 1)); + Conversion.shortToHex((short) 0xCDE3, 0, "ffffffffffffffffffffffff", 0, 1)); assertEquals( "feffffffffffffffffffffff", - Conversion.shortToHex((short)0xCDEF, 0, "ffffffffffffffffffffffff", 0, 2)); + Conversion.shortToHex((short) 0xCDEF, 0, "ffffffffffffffffffffffff", 0, 2)); assertEquals( "fedfffffffffffffffffffff", - Conversion.shortToHex((short)0xCDEF, 0, "ffffffffffffffffffffffff", 0, 3)); + Conversion.shortToHex((short) 0xCDEF, 0, "ffffffffffffffffffffffff", 0, 3)); assertEquals( "fedcffffffffffffffffffff", - Conversion.shortToHex((short)0xCDEF, 0, "ffffffffffffffffffffffff", 0, 4)); + Conversion.shortToHex((short) 0xCDEF, 0, "ffffffffffffffffffffffff", 0, 4)); assertEquals( "fff3ffffffffffffffffffff", - Conversion.shortToHex((short)0xCDE3, 0, "ffffffffffffffffffffffff", 3, 1)); + Conversion.shortToHex((short) 0xCDE3, 0, "ffffffffffffffffffffffff", 3, 1)); assertEquals( "ffffefffffffffffffffffff", - Conversion.shortToHex((short)0xCDEF, 0, "ffffffffffffffffffffffff", 3, 2)); + Conversion.shortToHex((short) 0xCDEF, 0, "ffffffffffffffffffffffff", 3, 2)); assertEquals( "7fffffffffffffffffffffff", - Conversion.shortToHex((short)0xCDEF, 1, "ffffffffffffffffffffffff", 0, 1)); + Conversion.shortToHex((short) 0xCDEF, 1, "ffffffffffffffffffffffff", 0, 1)); assertEquals( "bfffffffffffffffffffffff", - Conversion.shortToHex((short)0xCDEF, 2, "ffffffffffffffffffffffff", 0, 1)); + Conversion.shortToHex((short) 0xCDEF, 2, "ffffffffffffffffffffffff", 0, 1)); assertEquals( "fffdb9ffffffffffffffffff", - Conversion.shortToHex((short)0xCDEF, 3, "ffffffffffffffffffffffff", 3, 4)); - // assertEquals("ffffffffffffffffffffffff",Conversion.shortToHex((short)0xCDEF, - // 4,"ffffffffffffffffffffffff",3,4));//rejected by assertion + Conversion.shortToHex((short) 0xCDEF, 3, "ffffffffffffffffffffffff", 3, 4)); + // assertEquals("ffffffffffffffffffffffff", Conversion.shortToHex((short) 0xCDEF, + // 4, "ffffffffffffffffffffffff", 3, 4));//rejected by assertion assertEquals( "fffedcffffffffffffffffff", - Conversion.shortToHex((short)0xCDEF, 4, "ffffffffffffffffffffffff", 3, 3)); - assertEquals("fedc", Conversion.shortToHex((short)0xCDEF, 0, "", 0, 4)); - assertThrows(StringIndexOutOfBoundsException.class, () -> Conversion.shortToHex((short)0xCDEF, 0, "", 1, 4)); + Conversion.shortToHex((short) 0xCDEF, 4, "ffffffffffffffffffffffff", 3, 3)); + assertEquals("fedc", Conversion.shortToHex((short) 0xCDEF, 0, "", 0, 4)); + assertThrows(StringIndexOutOfBoundsException.class, () -> Conversion.shortToHex((short) 0xCDEF, 0, "", 1, 4)); } /** @@ -1345,22 +1345,22 @@ public class ConversionTest { */ @Test public void testByteToHex() { - assertEquals("", Conversion.byteToHex((byte)0x00, 0, "", 0, 0)); - assertEquals("", Conversion.byteToHex((byte)0x00, 100, "", 0, 0)); - assertEquals("", Conversion.byteToHex((byte)0x00, 0, "", 100, 0)); - assertEquals("00000", Conversion.byteToHex((byte)0xEF, 0, "00000", 0, 0)); - assertEquals("f0000", Conversion.byteToHex((byte)0xEF, 0, "00000", 0, 1)); - assertEquals("fe000", Conversion.byteToHex((byte)0xEF, 0, "00000", 0, 2)); - assertEquals("000f0", Conversion.byteToHex((byte)0xEF, 0, "00000", 3, 1)); - assertEquals("000fe", Conversion.byteToHex((byte)0xEF, 0, "00000", 3, 2)); - assertEquals("70000", Conversion.byteToHex((byte)0xEF, 1, "00000", 0, 1)); - assertEquals("b0000", Conversion.byteToHex((byte)0xEF, 2, "00000", 0, 1)); - assertEquals("000df", Conversion.byteToHex((byte)0xEF, 3, "00000", 3, 2)); - // assertEquals("00000",Conversion.byteToHex((byte)0xEF, 4,"00000",3,2));//rejected by + assertEquals("", Conversion.byteToHex((byte) 0x00, 0, "", 0, 0)); + assertEquals("", Conversion.byteToHex((byte) 0x00, 100, "", 0, 0)); + assertEquals("", Conversion.byteToHex((byte) 0x00, 0, "", 100, 0)); + assertEquals("00000", Conversion.byteToHex((byte) 0xEF, 0, "00000", 0, 0)); + assertEquals("f0000", Conversion.byteToHex((byte) 0xEF, 0, "00000", 0, 1)); + assertEquals("fe000", Conversion.byteToHex((byte) 0xEF, 0, "00000", 0, 2)); + assertEquals("000f0", Conversion.byteToHex((byte) 0xEF, 0, "00000", 3, 1)); + assertEquals("000fe", Conversion.byteToHex((byte) 0xEF, 0, "00000", 3, 2)); + assertEquals("70000", Conversion.byteToHex((byte) 0xEF, 1, "00000", 0, 1)); + assertEquals("b0000", Conversion.byteToHex((byte) 0xEF, 2, "00000", 0, 1)); + assertEquals("000df", Conversion.byteToHex((byte) 0xEF, 3, "00000", 3, 2)); + // assertEquals("00000", Conversion.byteToHex((byte) 0xEF, 4, "00000", 3, 2));//rejected by // assertion - assertEquals("000e0", Conversion.byteToHex((byte)0xEF, 4, "00000", 3, 1)); - assertEquals("fe", Conversion.byteToHex((byte)0xEF, 0, "", 0, 2)); - assertThrows(StringIndexOutOfBoundsException.class, () -> Conversion.byteToHex((byte)0xEF, 0, "", 1, 2)); + assertEquals("000e0", Conversion.byteToHex((byte) 0xEF, 4, "00000", 3, 1)); + assertEquals("fe", Conversion.byteToHex((byte) 0xEF, 0, "", 0, 2)); + assertThrows(StringIndexOutOfBoundsException.class, () -> Conversion.byteToHex((byte) 0xEF, 0, "", 1, 2)); } /** @@ -1467,13 +1467,13 @@ public class ConversionTest { false, false, false, false, false, false, false, false, false}, Conversion.longToBinary(0x1234567890ABCDEFL, 2, new boolean[69], 0, 62)); - // assertArrayEquals(new boolean[]{false,false,false, true, true, false, true, true, + // assertArrayEquals(new boolean[]{false, false, false, true, true, false, true, true, // true, true, false, true, true, false, false, true, true, true, true, false, true, // false, true, false, true, false, false, false, false, true, false, false, true, // false, false, false, true, true, true, true, false, false, true, true, false, true, // false, true, false, false, false, true, false, true, true, false, false, false, true, // false, false, true, false, false, false - // ,false,false,false,false},Conversion.longToBinary(0x1234567890ABCDEFL, 2,new + // , false, false, false, false}, Conversion.longToBinary(0x1234567890ABCDEFL, 2, new // boolean[69], 3, 63));//rejected by assertion assertArrayEquals( new boolean[]{ @@ -1553,8 +1553,8 @@ public class ConversionTest { // true, // true, true, false, true, true, false, false, true, true, true, true, false, true, // false, true, false, true, false, false, false, false, true, false, false, false, - // false, false, false, false},Conversion.intToBinary(0x90ABCDEF, 2,new boolean[37], - // 3,31));//rejected by assertion + // false, false, false, false}, Conversion.intToBinary(0x90ABCDEF, 2, new boolean[37], + // 3, 31));//rejected by assertion assertArrayEquals( new boolean[]{ false, false, false, true, true, false, true, true, true, true, false, true, @@ -1569,70 +1569,70 @@ public class ConversionTest { @Test public void testShortToBinary() { assertArrayEquals( - new boolean[]{}, Conversion.shortToBinary((short)0x0000, 0, new boolean[]{}, 0, 0)); + new boolean[]{}, Conversion.shortToBinary((short) 0x0000, 0, new boolean[]{}, 0, 0)); assertArrayEquals( new boolean[]{}, - Conversion.shortToBinary((short)0x0000, 100, new boolean[]{}, 0, 0)); + Conversion.shortToBinary((short) 0x0000, 100, new boolean[]{}, 0, 0)); assertArrayEquals( new boolean[]{}, - Conversion.shortToBinary((short)0x0000, 0, new boolean[]{}, 100, 0)); + Conversion.shortToBinary((short) 0x0000, 0, new boolean[]{}, 100, 0)); assertArrayEquals( - new boolean[69], Conversion.shortToBinary((short)0xCDEF, 0, new boolean[69], 0, 0)); + new boolean[69], Conversion.shortToBinary((short) 0xCDEF, 0, new boolean[69], 0, 0)); assertArrayEquals( new boolean[]{ true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}, - Conversion.shortToBinary((short)0xCDEF, 0, new boolean[21], 0, 1)); + Conversion.shortToBinary((short) 0xCDEF, 0, new boolean[21], 0, 1)); assertArrayEquals( new boolean[]{ true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}, - Conversion.shortToBinary((short)0xCDEF, 0, new boolean[21], 0, 2)); + Conversion.shortToBinary((short) 0xCDEF, 0, new boolean[21], 0, 2)); assertArrayEquals( new boolean[]{ true, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}, - Conversion.shortToBinary((short)0xCDEF, 0, new boolean[21], 0, 3)); + Conversion.shortToBinary((short) 0xCDEF, 0, new boolean[21], 0, 3)); assertArrayEquals( new boolean[]{ true, true, true, true, false, true, true, true, true, false, true, true, false, false, true, false, false, false, false, false, false}, - Conversion.shortToBinary((short)0xCDEF, 0, new boolean[21], 0, 15)); + Conversion.shortToBinary((short) 0xCDEF, 0, new boolean[21], 0, 15)); assertArrayEquals( new boolean[]{ true, true, true, true, false, true, true, true, true, false, true, true, false, false, true, true, false, false, false, false, false}, - Conversion.shortToBinary((short)0xCDEF, 0, new boolean[21], 0, 16)); + Conversion.shortToBinary((short) 0xCDEF, 0, new boolean[21], 0, 16)); assertArrayEquals( new boolean[]{ false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}, - Conversion.shortToBinary((short)0xCDEF, 0, new boolean[21], 2, 1)); + Conversion.shortToBinary((short) 0xCDEF, 0, new boolean[21], 2, 1)); assertArrayEquals( new boolean[]{ false, false, true, true, true, true, false, true, true, true, true, false, true, true, false, false, true, true, false, false, false}, - Conversion.shortToBinary((short)0xCDEF, 0, new boolean[21], 2, 16)); + Conversion.shortToBinary((short) 0xCDEF, 0, new boolean[21], 2, 16)); assertArrayEquals( new boolean[]{ true, true, true, false, true, true, true, true, false, true, true, false, false, true, true, false, false, false, false, false, false}, - Conversion.shortToBinary((short)0xCDEF, 1, new boolean[21], 0, 15)); + Conversion.shortToBinary((short) 0xCDEF, 1, new boolean[21], 0, 15)); assertArrayEquals( new boolean[]{ true, true, false, true, true, true, true, false, true, true, false, false, true, true, false, false, false, false, false, false, false}, - Conversion.shortToBinary((short)0xCDEF, 2, new boolean[21], 0, 14)); + Conversion.shortToBinary((short) 0xCDEF, 2, new boolean[21], 0, 14)); // assertArrayEquals(new boolean[]{false, false, false, true, true, false, true, true, // true, true, false, true, true, false, false, true, false, false, false, false, - // false},Conversion.shortToBinary((short)0xCDEF, 2,new boolean[21], - // 3,15));//rejected by + // false}, Conversion.shortToBinary((short) 0xCDEF, 2, new boolean[21], + // 3, 15));//rejected by // assertion assertArrayEquals( new boolean[]{ false, false, false, true, true, false, true, true, true, true, false, true, true, false, false, true, true, false, false, false, false}, - Conversion.shortToBinary((short)0xCDEF, 2, new boolean[21], 3, 14)); + Conversion.shortToBinary((short) 0xCDEF, 2, new boolean[21], 3, 14)); } /** @@ -1641,46 +1641,46 @@ public class ConversionTest { @Test public void testByteToBinary() { assertArrayEquals( - new boolean[]{}, Conversion.byteToBinary((byte)0x00, 0, new boolean[]{}, 0, 0)); + new boolean[]{}, Conversion.byteToBinary((byte) 0x00, 0, new boolean[]{}, 0, 0)); assertArrayEquals( - new boolean[]{}, Conversion.byteToBinary((byte)0x00, 100, new boolean[]{}, 0, 0)); + new boolean[]{}, Conversion.byteToBinary((byte) 0x00, 100, new boolean[]{}, 0, 0)); assertArrayEquals( - new boolean[]{}, Conversion.byteToBinary((byte)0x00, 0, new boolean[]{}, 100, 0)); + new boolean[]{}, Conversion.byteToBinary((byte) 0x00, 0, new boolean[]{}, 100, 0)); assertArrayEquals( - new boolean[69], Conversion.byteToBinary((byte)0xEF, 0, new boolean[69], 0, 0)); + new boolean[69], Conversion.byteToBinary((byte) 0xEF, 0, new boolean[69], 0, 0)); assertArrayEquals(new boolean[]{ true, false, false, false, false, false, false, false, false, false, false, false, - false}, Conversion.byteToBinary((byte)0x95, 0, new boolean[13], 0, 1)); + false}, Conversion.byteToBinary((byte) 0x95, 0, new boolean[13], 0, 1)); assertArrayEquals(new boolean[]{ true, false, false, false, false, false, false, false, false, false, false, false, - false}, Conversion.byteToBinary((byte)0x95, 0, new boolean[13], 0, 2)); + false}, Conversion.byteToBinary((byte) 0x95, 0, new boolean[13], 0, 2)); assertArrayEquals(new boolean[]{ true, false, true, false, false, false, false, false, false, false, false, false, - false}, Conversion.byteToBinary((byte)0x95, 0, new boolean[13], 0, 3)); + false}, Conversion.byteToBinary((byte) 0x95, 0, new boolean[13], 0, 3)); assertArrayEquals(new boolean[]{ true, false, true, false, true, false, false, false, false, false, false, false, - false}, Conversion.byteToBinary((byte)0x95, 0, new boolean[13], 0, 7)); + false}, Conversion.byteToBinary((byte) 0x95, 0, new boolean[13], 0, 7)); assertArrayEquals(new boolean[]{ true, false, true, false, true, false, false, true, false, false, false, false, - false}, Conversion.byteToBinary((byte)0x95, 0, new boolean[13], 0, 8)); + false}, Conversion.byteToBinary((byte) 0x95, 0, new boolean[13], 0, 8)); assertArrayEquals(new boolean[]{ false, false, true, false, false, false, false, false, false, false, false, false, - false}, Conversion.byteToBinary((byte)0x95, 0, new boolean[13], 2, 1)); + false}, Conversion.byteToBinary((byte) 0x95, 0, new boolean[13], 2, 1)); assertArrayEquals(new boolean[]{ false, false, true, false, true, false, true, false, false, true, false, false, - false}, Conversion.byteToBinary((byte)0x95, 0, new boolean[13], 2, 8)); + false}, Conversion.byteToBinary((byte) 0x95, 0, new boolean[13], 2, 8)); assertArrayEquals(new boolean[]{ false, true, false, true, false, false, true, false, false, false, false, false, - false}, Conversion.byteToBinary((byte)0x95, 1, new boolean[13], 0, 7)); + false}, Conversion.byteToBinary((byte) 0x95, 1, new boolean[13], 0, 7)); assertArrayEquals(new boolean[]{ true, false, true, false, false, true, false, false, false, false, false, false, - false}, Conversion.byteToBinary((byte)0x95, 2, new boolean[13], 0, 6)); + false}, Conversion.byteToBinary((byte) 0x95, 2, new boolean[13], 0, 6)); // assertArrayEquals(new boolean[]{false, false, false, true, true, false, true, true, - // false, false, false, false, false},Conversion.byteToBinary((byte)0x95, 2,new + // false, false, false, false, false}, Conversion.byteToBinary((byte) 0x95, 2, new // boolean[13], 3, 7));//rejected by assertion assertArrayEquals(new boolean[]{ false, false, false, true, false, true, false, false, true, false, false, false, - false}, Conversion.byteToBinary((byte)0x95, 2, new boolean[13], 3, 6)); + false}, Conversion.byteToBinary((byte) 0x95, 2, new boolean[13], 3, 6)); } /** @@ -1689,24 +1689,24 @@ public class ConversionTest { @Test public void testUuidToByteArray() { assertArrayEquals(new byte[]{ - (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, - (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, - (byte)0xff, (byte)0xff}, Conversion.uuidToByteArray(new UUID( + (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, + (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, + (byte) 0xff, (byte) 0xff}, Conversion.uuidToByteArray(new UUID( 0xFFFFFFFFFFFFFFFFL, 0xFFFFFFFFFFFFFFFFL), new byte[16], 0, 16)); assertArrayEquals(new byte[]{ - (byte)0x88, (byte)0x99, (byte)0xaa, (byte)0xbb, (byte)0xcc, (byte)0xdd, (byte)0xee, - (byte)0xff, (byte)0x00, (byte)0x11, (byte)0x22, (byte)0x33, (byte)0x44, (byte)0x55, - (byte)0x66, (byte)0x77}, Conversion.uuidToByteArray(new UUID( + (byte) 0x88, (byte) 0x99, (byte) 0xaa, (byte) 0xbb, (byte) 0xcc, (byte) 0xdd, (byte) 0xee, + (byte) 0xff, (byte) 0x00, (byte) 0x11, (byte) 0x22, (byte) 0x33, (byte) 0x44, (byte) 0x55, + (byte) 0x66, (byte) 0x77}, Conversion.uuidToByteArray(new UUID( 0xFFEEDDCCBBAA9988L, 0x7766554433221100L), new byte[16], 0, 16)); assertArrayEquals(new byte[]{ - (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x88, (byte)0x99, (byte)0xaa, - (byte)0xbb, (byte)0xcc, (byte)0xdd, (byte)0xee, (byte)0xff, (byte)0x00, (byte)0x00, - (byte)0x00, (byte)0x00}, Conversion.uuidToByteArray(new UUID( + (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x88, (byte) 0x99, (byte) 0xaa, + (byte) 0xbb, (byte) 0xcc, (byte) 0xdd, (byte) 0xee, (byte) 0xff, (byte) 0x00, (byte) 0x00, + (byte) 0x00, (byte) 0x00}, Conversion.uuidToByteArray(new UUID( 0xFFEEDDCCBBAA9988L, 0x7766554433221100L), new byte[16], 4, 8)); assertArrayEquals(new byte[]{ - (byte)0x00, (byte)0x00, (byte)0x88, (byte)0x99, (byte)0xaa, (byte)0xbb, (byte)0xcc, - (byte)0xdd, (byte)0xee, (byte)0xff, (byte)0x00, (byte)0x11, (byte)0x22, (byte)0x33, - (byte)0x00, (byte)0x00}, Conversion.uuidToByteArray(new UUID( + (byte) 0x00, (byte) 0x00, (byte) 0x88, (byte) 0x99, (byte) 0xaa, (byte) 0xbb, (byte) 0xcc, + (byte) 0xdd, (byte) 0xee, (byte) 0xff, (byte) 0x00, (byte) 0x11, (byte) 0x22, (byte) 0x33, + (byte) 0x00, (byte) 0x00}, Conversion.uuidToByteArray(new UUID( 0xFFEEDDCCBBAA9988L, 0x7766554433221100L), new byte[16], 2, 12)); } @@ -1718,20 +1718,20 @@ public class ConversionTest { assertEquals( new UUID(0xFFFFFFFFFFFFFFFFL, 0xFFFFFFFFFFFFFFFFL), Conversion.byteArrayToUuid(new byte[]{ - (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, - (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, - (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff}, 0)); + (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, + (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, + (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff}, 0)); assertEquals( new UUID(0xFFEEDDCCBBAA9988L, 0x7766554433221100L), Conversion.byteArrayToUuid(new byte[]{ - (byte)0x88, (byte)0x99, (byte)0xaa, (byte)0xbb, (byte)0xcc, (byte)0xdd, - (byte)0xee, (byte)0xff, (byte)0x00, (byte)0x11, (byte)0x22, (byte)0x33, - (byte)0x44, (byte)0x55, (byte)0x66, (byte)0x77}, 0)); + (byte) 0x88, (byte) 0x99, (byte) 0xaa, (byte) 0xbb, (byte) 0xcc, (byte) 0xdd, + (byte) 0xee, (byte) 0xff, (byte) 0x00, (byte) 0x11, (byte) 0x22, (byte) 0x33, + (byte) 0x44, (byte) 0x55, (byte) 0x66, (byte) 0x77}, 0)); assertEquals( new UUID(0xFFEEDDCCBBAA9988L, 0x7766554433221100L), Conversion.byteArrayToUuid(new byte[]{ - 0, 0, (byte)0x88, (byte)0x99, (byte)0xaa, (byte)0xbb, (byte)0xcc, (byte)0xdd, - (byte)0xee, (byte)0xff, (byte)0x00, (byte)0x11, (byte)0x22, (byte)0x33, - (byte)0x44, (byte)0x55, (byte)0x66, (byte)0x77}, 2)); + 0, 0, (byte) 0x88, (byte) 0x99, (byte) 0xaa, (byte) 0xbb, (byte) 0xcc, (byte) 0xdd, + (byte) 0xee, (byte) 0xff, (byte) 0x00, (byte) 0x11, (byte) 0x22, (byte) 0x33, + (byte) 0x44, (byte) 0x55, (byte) 0x66, (byte) 0x77}, 2)); } } diff --git a/src/test/java/org/apache/commons/lang3/HashSetvBitSetTest.java b/src/test/java/org/apache/commons/lang3/HashSetvBitSetTest.java index 5c04cd6ee..fa6a4fa0a 100644 --- a/src/test/java/org/apache/commons/lang3/HashSetvBitSetTest.java +++ b/src/test/java/org/apache/commons/lang3/HashSetvBitSetTest.java @@ -71,7 +71,7 @@ public class HashSetvBitSetTest { final int[] array = new int[100]; toRemove.set(10, 20); final int[] extractIndices = extractIndices(toRemove); - return (int[]) ArrayUtils.removeAll((Object)array, extractIndices); + return (int[]) ArrayUtils.removeAll((Object) array, extractIndices); } // --- utility methods @@ -88,7 +88,7 @@ public class HashSetvBitSetTest { final int[] result = new int[coll.cardinality()]; int i = 0; int j=0; - while((j=coll.nextSetBit(j)) != -1) { + while ((j=coll.nextSetBit(j)) != -1) { result[i++] = j++; } return result; diff --git a/src/test/java/org/apache/commons/lang3/ObjectUtilsTest.java b/src/test/java/org/apache/commons/lang3/ObjectUtilsTest.java index 64eae2265..518a820c6 100644 --- a/src/test/java/org/apache/commons/lang3/ObjectUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/ObjectUtilsTest.java @@ -226,7 +226,7 @@ public class ObjectUtilsTest { ObjectUtils.identityToString(buffer, i); assertEquals(expected, buffer.toString()); - assertThrows(NullPointerException.class, () -> ObjectUtils.identityToString((StringBuffer)null, "tmp")); + assertThrows(NullPointerException.class, () -> ObjectUtils.identityToString((StringBuffer) null, "tmp")); assertThrows(NullPointerException.class, () -> ObjectUtils.identityToString(new StringBuffer(), null)); } @@ -277,7 +277,7 @@ public class ObjectUtilsTest { @Test public void testIdentityToStringStringBuilderNullStringBuilder() { - assertThrows(NullPointerException.class, () -> ObjectUtils.identityToString((StringBuilder)null, "tmp")); + assertThrows(NullPointerException.class, () -> ObjectUtils.identityToString((StringBuilder) null, "tmp")); } @Test @@ -289,7 +289,7 @@ public class ObjectUtilsTest { ObjectUtils.identityToString(builder, i); assertEquals(expected, builder.toString()); - assertThrows(NullPointerException.class, () -> ObjectUtils.identityToString((StrBuilder)null, "tmp")); + assertThrows(NullPointerException.class, () -> ObjectUtils.identityToString((StrBuilder) null, "tmp")); assertThrows(NullPointerException.class, () -> ObjectUtils.identityToString(new StrBuilder(), null)); } @@ -303,11 +303,11 @@ public class ObjectUtilsTest { ObjectUtils.identityToString(appendable, i); assertEquals(expected, appendable.toString()); - assertThrows(NullPointerException.class, () -> ObjectUtils.identityToString((Appendable)null, "tmp")); + assertThrows(NullPointerException.class, () -> ObjectUtils.identityToString((Appendable) null, "tmp")); assertThrows( NullPointerException.class, - () -> ObjectUtils.identityToString((Appendable)(new StringBuilder()), null)); + () -> ObjectUtils.identityToString((Appendable) (new StringBuilder()), null)); } @Test @@ -631,7 +631,7 @@ public class ObjectUtilsTest { @Override public CloneableString clone() throws CloneNotSupportedException { - return (CloneableString)super.clone(); + return (CloneableString) super.clone(); } } diff --git a/src/test/java/org/apache/commons/lang3/RandomStringUtilsTest.java b/src/test/java/org/apache/commons/lang3/RandomStringUtilsTest.java index ff8f8f54d..c903b3f9a 100644 --- a/src/test/java/org/apache/commons/lang3/RandomStringUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/RandomStringUtilsTest.java @@ -65,7 +65,7 @@ public class RandomStringUtilsTest { r1 = RandomStringUtils.randomAscii(50); assertEquals(50, r1.length(), "randomAscii(50) length"); - for(int i = 0; i < r1.length(); i++) { + for (int i = 0; i < r1.length(); i++) { assertTrue(r1.charAt(i) >= 32 && r1.charAt(i) <= 127, "char between 32 and 127"); } r2 = RandomStringUtils.randomAscii(50); @@ -73,7 +73,7 @@ public class RandomStringUtilsTest { r1 = RandomStringUtils.randomAlphabetic(50); assertEquals(50, r1.length(), "randomAlphabetic(50)"); - for(int i = 0; i < r1.length(); i++) { + for (int i = 0; i < r1.length(); i++) { assertTrue(Character.isLetter(r1.charAt(i)) && !Character.isDigit(r1.charAt(i)), "r1 contains alphabetic"); } r2 = RandomStringUtils.randomAlphabetic(50); @@ -81,7 +81,7 @@ public class RandomStringUtilsTest { r1 = RandomStringUtils.randomAlphanumeric(50); assertEquals(50, r1.length(), "randomAlphanumeric(50)"); - for(int i = 0; i < r1.length(); i++) { + for (int i = 0; i < r1.length(); i++) { assertTrue(Character.isLetterOrDigit(r1.charAt(i)), "r1 contains alphanumeric"); } r2 = RandomStringUtils.randomAlphabetic(50); @@ -89,7 +89,7 @@ public class RandomStringUtilsTest { r1 = RandomStringUtils.randomGraph(50); assertEquals(50, r1.length(), "randomGraph(50) length"); - for(int i = 0; i < r1.length(); i++) { + for (int i = 0; i < r1.length(); i++) { assertTrue(r1.charAt(i) >= 33 && r1.charAt(i) <= 126, "char between 33 and 126"); } r2 = RandomStringUtils.randomGraph(50); @@ -97,7 +97,7 @@ public class RandomStringUtilsTest { r1 = RandomStringUtils.randomNumeric(50); assertEquals(50, r1.length(), "randomNumeric(50)"); - for(int i = 0; i < r1.length(); i++) { + for (int i = 0; i < r1.length(); i++) { assertTrue(Character.isDigit(r1.charAt(i)) && !Character.isLetter(r1.charAt(i)), "r1 contains numeric"); } r2 = RandomStringUtils.randomNumeric(50); @@ -105,7 +105,7 @@ public class RandomStringUtilsTest { r1 = RandomStringUtils.randomPrint(50); assertEquals(50, r1.length(), "randomPrint(50) length"); - for(int i = 0; i < r1.length(); i++) { + for (int i = 0; i < r1.length(); i++) { assertTrue(r1.charAt(i) >= 32 && r1.charAt(i) <= 126, "char between 32 and 126"); } r2 = RandomStringUtils.randomPrint(50); @@ -114,7 +114,7 @@ public class RandomStringUtilsTest { String set = "abcdefg"; r1 = RandomStringUtils.random(50, set); assertEquals(50, r1.length(), "random(50, \"abcdefg\")"); - for(int i = 0; i < r1.length(); i++) { + for (int i = 0; i < r1.length(); i++) { assertTrue(set.indexOf(r1.charAt(i)) > -1, "random char in set"); } r2 = RandomStringUtils.random(50, set); @@ -129,7 +129,7 @@ public class RandomStringUtilsTest { set = "stuvwxyz"; r1 = RandomStringUtils.random(50, set.toCharArray()); assertEquals(50, r1.length(), "random(50, \"stuvwxyz\")"); - for(int i = 0; i < r1.length(); i++) { + for (int i = 0; i < r1.length(); i++) { assertTrue(set.indexOf(r1.charAt(i)) > -1, "random char in set"); } r2 = RandomStringUtils.random(50, set); @@ -142,8 +142,8 @@ public class RandomStringUtilsTest { assertTrue(!r1.equals(r2), "!r1.equals(r2)"); final long seed = System.currentTimeMillis(); - r1 = RandomStringUtils.random(50,0,0,true,true,null,new Random(seed)); - r2 = RandomStringUtils.random(50,0,0,true,true,null,new Random(seed)); + r1 = RandomStringUtils.random(50, 0, 0, true, true, null, new Random(seed)); + r2 = RandomStringUtils.random(50, 0, 0, true, true, null, new Random(seed)); assertEquals(r1, r2, "r1.equals(r2)"); r1 = RandomStringUtils.random(0); @@ -153,13 +153,13 @@ public class RandomStringUtilsTest { @Test public void testLANG805() { final long seed = System.currentTimeMillis(); - assertEquals("aaa", RandomStringUtils.random(3,0,0,false,false,new char[]{'a'},new Random(seed))); + assertEquals("aaa", RandomStringUtils.random(3, 0, 0, false, false, new char[]{'a'}, new Random(seed))); } @Test public void testLANG807() { IllegalArgumentException ex = - assertThrows(IllegalArgumentException.class, () -> RandomStringUtils.random(3,5,5,false,false)); + assertThrows(IllegalArgumentException.class, () -> RandomStringUtils.random(3, 5, 5, false, false)); final String msg = ex.getMessage(); assertTrue(msg.contains("start"), "Message (" + msg + ") must contain 'start'"); assertTrue(msg.contains("end"), "Message (" + msg + ") must contain 'end'"); @@ -212,7 +212,7 @@ public class RandomStringUtilsTest { */ @Test public void testRandomNumeric() { - final char[] testChars = {'0','9'}; + final char[] testChars = {'0', '9'}; final boolean[] found = {false, false}; for (int i = 0; i < 100; i++) { final String randString = RandomStringUtils.randomNumeric(10); @@ -439,7 +439,7 @@ public class RandomStringUtilsTest { final int[] counts = {0, 0, 0}; final int[] expected = {200, 200, 200}; for (int i = 0; i< 100; i++) { - gen = RandomStringUtils.random(6,chars); + gen = RandomStringUtils.random(6, chars); for (int j = 0; j < 6; j++) { switch (gen.charAt(j)) { case 'a': { @@ -461,7 +461,7 @@ public class RandomStringUtilsTest { } } // Perform chi-square test with df = 3-1 = 2, testing at .001 level - assertTrue(chiSquare(expected,counts) < 13.82, "test homogeneity -- will fail about 1 in 1000 times"); + assertTrue(chiSquare(expected, counts) < 13.82, "test homogeneity -- will fail about 1 in 1000 times"); } /** diff --git a/src/test/java/org/apache/commons/lang3/SerializationUtilsTest.java b/src/test/java/org/apache/commons/lang3/SerializationUtilsTest.java index 6d77852f3..d0dcaa33a 100644 --- a/src/test/java/org/apache/commons/lang3/SerializationUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/SerializationUtilsTest.java @@ -331,7 +331,7 @@ public class SerializationUtilsTest { public void testClone() { final Object test = SerializationUtils.clone(iMap); assertNotNull(test); - assertTrue(test instanceof HashMap,?>); + assertTrue(test instanceof HashMap, ?>); assertNotSame(test, iMap); final HashMap, ?> testMap = (HashMap, ?>) test; assertEquals(iString, testMap.get("FOO")); diff --git a/src/test/java/org/apache/commons/lang3/StringEscapeUtilsTest.java b/src/test/java/org/apache/commons/lang3/StringEscapeUtilsTest.java index 795a7bc5c..9c0b5348c 100644 --- a/src/test/java/org/apache/commons/lang3/StringEscapeUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/StringEscapeUtilsTest.java @@ -236,11 +236,11 @@ public class StringEscapeUtilsTest { // Test all Character values: for (char i = Character.MIN_VALUE; i < Character.MAX_VALUE; i++) { final Character c1 = new Character(i); - final Character c2 = new Character((char)(i+1)); + final Character c2 = new Character((char) (i+1)); final String expected = c1.toString() + c2.toString(); final String escapedC1 = "" + Integer.toHexString((c1.charValue())) + ";"; final String escapedC2 = "" + Integer.toHexString((c2.charValue())) + ";"; - assertEquals(expected, StringEscapeUtils.unescapeHtml4(escapedC1 + escapedC2), "hex number unescape index " + (int)i); + assertEquals(expected, StringEscapeUtils.unescapeHtml4(escapedC1 + escapedC2), "hex number unescape index " + (int) i); } } @@ -477,7 +477,7 @@ public class StringEscapeUtilsTest { // COUNTING ROD UNIT DIGIT THREE // in Unicode // codepoint: U+1D362 - final byte[] data = new byte[] { (byte)0xF0, (byte)0x9D, (byte)0x8D, (byte)0xA2 }; + final byte[] data = new byte[] { (byte) 0xF0, (byte) 0x9D, (byte) 0x8D, (byte) 0xA2 }; final String original = new String(data, Charset.forName("UTF8")); diff --git a/src/test/java/org/apache/commons/lang3/StringUtilsEqualsIndexOfTest.java b/src/test/java/org/apache/commons/lang3/StringUtilsEqualsIndexOfTest.java index 070fe90e4..642f97342 100644 --- a/src/test/java/org/apache/commons/lang3/StringUtilsEqualsIndexOfTest.java +++ b/src/test/java/org/apache/commons/lang3/StringUtilsEqualsIndexOfTest.java @@ -140,8 +140,8 @@ public class StringUtilsEqualsIndexOfTest { assertFalse(StringUtils.equalsIgnoreCase(FOO, BAR)); assertFalse(StringUtils.equalsIgnoreCase(FOO, null)); assertFalse(StringUtils.equalsIgnoreCase(null, FOO)); - assertTrue(StringUtils.equalsIgnoreCase("","")); - assertFalse(StringUtils.equalsIgnoreCase("abcd","abcd ")); + assertTrue(StringUtils.equalsIgnoreCase("", "")); + assertFalse(StringUtils.equalsIgnoreCase("abcd", "abcd ")); } @Test @@ -347,7 +347,7 @@ public class StringUtilsEqualsIndexOfTest { assertEquals(5, StringUtils.indexOf("aabaabaa", "b", 3)); assertEquals(-1, StringUtils.indexOf("aabaabaa", "b", 9)); assertEquals(2, StringUtils.indexOf("aabaabaa", "b", -1)); - assertEquals(2,StringUtils.indexOf("aabaabaa", "", 2)); + assertEquals(2, StringUtils.indexOf("aabaabaa", "", 2)); // Test that startIndex works correctly, i.e. cannot match before startIndex assertEquals(7, StringUtils.indexOf("12345678", "8", 5)); @@ -362,16 +362,16 @@ public class StringUtilsEqualsIndexOfTest { public void testIndexOfAny_StringCharArray() { assertEquals(-1, StringUtils.indexOfAny(null, (char[]) null)); assertEquals(-1, StringUtils.indexOfAny(null, new char[0])); - assertEquals(-1, StringUtils.indexOfAny(null, 'a','b')); + assertEquals(-1, StringUtils.indexOfAny(null, 'a', 'b')); assertEquals(-1, StringUtils.indexOfAny("", (char[]) null)); assertEquals(-1, StringUtils.indexOfAny("", new char[0])); - assertEquals(-1, StringUtils.indexOfAny("", 'a','b')); + assertEquals(-1, StringUtils.indexOfAny("", 'a', 'b')); assertEquals(-1, StringUtils.indexOfAny("zzabyycdxx", (char[]) null)); assertEquals(-1, StringUtils.indexOfAny("zzabyycdxx", new char[0])); - assertEquals(0, StringUtils.indexOfAny("zzabyycdxx", 'z','a')); - assertEquals(3, StringUtils.indexOfAny("zzabyycdxx", 'b','y')); + assertEquals(0, StringUtils.indexOfAny("zzabyycdxx", 'z', 'a')); + assertEquals(3, StringUtils.indexOfAny("zzabyycdxx", 'b', 'y')); assertEquals(-1, StringUtils.indexOfAny("ab", 'z')); } @@ -436,16 +436,16 @@ public class StringUtilsEqualsIndexOfTest { public void testIndexOfAnyBut_StringCharArray() { assertEquals(-1, StringUtils.indexOfAnyBut(null, (char[]) null)); assertEquals(-1, StringUtils.indexOfAnyBut(null)); - assertEquals(-1, StringUtils.indexOfAnyBut(null, 'a','b')); + assertEquals(-1, StringUtils.indexOfAnyBut(null, 'a', 'b')); assertEquals(-1, StringUtils.indexOfAnyBut("", (char[]) null)); assertEquals(-1, StringUtils.indexOfAnyBut("")); - assertEquals(-1, StringUtils.indexOfAnyBut("", 'a','b')); + assertEquals(-1, StringUtils.indexOfAnyBut("", 'a', 'b')); assertEquals(-1, StringUtils.indexOfAnyBut("zzabyycdxx", (char[]) null)); assertEquals(-1, StringUtils.indexOfAnyBut("zzabyycdxx")); - assertEquals(3, StringUtils.indexOfAnyBut("zzabyycdxx", 'z','a')); - assertEquals(0, StringUtils.indexOfAnyBut("zzabyycdxx", 'b','y')); + assertEquals(3, StringUtils.indexOfAnyBut("zzabyycdxx", 'z', 'a')); + assertEquals(0, StringUtils.indexOfAnyBut("zzabyycdxx", 'b', 'y')); assertEquals(-1, StringUtils.indexOfAnyBut("aba", 'a', 'b')); assertEquals(0, StringUtils.indexOfAnyBut("aba", 'z')); } diff --git a/src/test/java/org/apache/commons/lang3/StringUtilsStartsEndsWithTest.java b/src/test/java/org/apache/commons/lang3/StringUtilsStartsEndsWithTest.java index 5f815c635..f5cd6655f 100644 --- a/src/test/java/org/apache/commons/lang3/StringUtilsStartsEndsWithTest.java +++ b/src/test/java/org/apache/commons/lang3/StringUtilsStartsEndsWithTest.java @@ -85,9 +85,9 @@ public class StringUtilsStartsEndsWithTest { @Test public void testStartsWithAny() { - assertFalse(StringUtils.startsWithAny(null, (String[])null)); + assertFalse(StringUtils.startsWithAny(null, (String[]) null)); assertFalse(StringUtils.startsWithAny(null, "abc")); - assertFalse(StringUtils.startsWithAny("abcxyz", (String[])null)); + assertFalse(StringUtils.startsWithAny("abcxyz", (String[]) null)); assertFalse(StringUtils.startsWithAny("abcxyz")); assertTrue(StringUtils.startsWithAny("abcxyz", "abc")); assertTrue(StringUtils.startsWithAny("abcxyz", null, "xyz", "abc")); @@ -124,10 +124,10 @@ public class StringUtilsStartsEndsWithTest { assertFalse(StringUtils.endsWith(foobar, BAR), "endsWith(foobar, BAR)"); assertFalse(StringUtils.endsWith(FOOBAR, bar), "endsWith(FOOBAR, bar)"); - // "alpha,beta,gamma,delta".endsWith("delta") + // "alpha, beta, gamma, delta".endsWith("delta") assertTrue(StringUtils.endsWith("\u03B1\u03B2\u03B3\u03B4", "\u03B4"), "endsWith(\u03B1\u03B2\u03B3\u03B4, \u03B4)"); - // "alpha,beta,gamma,delta".endsWith("gamma,DELTA") + // "alpha, beta, gamma, delta".endsWith("gamma, DELTA") assertFalse(StringUtils.endsWith("\u03B1\u03B2\u03B3\u03B4", "\u03B3\u0394"), "endsWith(\u03B1\u03B2\u03B3\u03B4, \u03B3\u0394)"); } @@ -160,19 +160,19 @@ public class StringUtilsStartsEndsWithTest { assertTrue(StringUtils.endsWithIgnoreCase("ABCDEF", "def")); assertFalse(StringUtils.endsWithIgnoreCase("ABCDEF", "cde")); - // "alpha,beta,gamma,delta".endsWith("DELTA") + // "alpha, beta, gamma, delta".endsWith("DELTA") assertTrue(StringUtils.endsWithIgnoreCase("\u03B1\u03B2\u03B3\u03B4", "\u0394"), "endsWith(\u03B1\u03B2\u03B3\u03B4, \u0394)"); - // "alpha,beta,gamma,delta".endsWith("GAMMA") + // "alpha, beta, gamma, delta".endsWith("GAMMA") assertFalse(StringUtils.endsWithIgnoreCase("\u03B1\u03B2\u03B3\u03B4", "\u0393"), "endsWith(\u03B1\u03B2\u03B3\u03B4, \u0393)"); } @Test public void testEndsWithAny() { - assertFalse(StringUtils.endsWithAny(null, (String)null), "StringUtils.endsWithAny(null, null)"); + assertFalse(StringUtils.endsWithAny(null, (String) null), "StringUtils.endsWithAny(null, null)"); assertFalse(StringUtils.endsWithAny(null, new String[] {"abc"}), "StringUtils.endsWithAny(null, new String[] {abc})"); - assertFalse(StringUtils.endsWithAny("abcxyz", (String)null), "StringUtils.endsWithAny(abcxyz, null)"); + assertFalse(StringUtils.endsWithAny("abcxyz", (String) null), "StringUtils.endsWithAny(abcxyz, null)"); assertTrue(StringUtils.endsWithAny("abcxyz", new String[] {""}), "StringUtils.endsWithAny(abcxyz, new String[] {\"\"})"); assertTrue(StringUtils.endsWithAny("abcxyz", new String[] {"xyz"}), "StringUtils.endsWithAny(abcxyz, new String[] {xyz})"); assertTrue(StringUtils.endsWithAny("abcxyz", new String[] {null, "xyz", "abc"}), "StringUtils.endsWithAny(abcxyz, new String[] {null, xyz, abc})"); diff --git a/src/test/java/org/apache/commons/lang3/StringUtilsSubstringTest.java b/src/test/java/org/apache/commons/lang3/StringUtilsSubstringTest.java index 33b7c1328..76bd28290 100644 --- a/src/test/java/org/apache/commons/lang3/StringUtilsSubstringTest.java +++ b/src/test/java/org/apache/commons/lang3/StringUtilsSubstringTest.java @@ -70,7 +70,7 @@ public class StringUtilsSubstringTest { assertEquals("o", StringUtils.substring(SENTENCE, -9, -8)); assertEquals(SENTENCE, StringUtils.substring(SENTENCE, 0, 80)); assertEquals("", StringUtils.substring(SENTENCE, 2, 2)); - assertEquals("b",StringUtils.substring("abc", -2, -1)); + assertEquals("b", StringUtils.substring("abc", -2, -1)); } @Test diff --git a/src/test/java/org/apache/commons/lang3/StringUtilsTest.java b/src/test/java/org/apache/commons/lang3/StringUtilsTest.java index afcd6b2f9..da4f93757 100644 --- a/src/test/java/org/apache/commons/lang3/StringUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/StringUtilsTest.java @@ -3150,7 +3150,7 @@ public class StringUtilsTest { final int orphanedLowSurrogate = 0xDC00; final int supplementary = 0x2070E; - final int[] codePoints = {'a', orphanedHighSurrogate, 'b','c', supplementary, + final int[] codePoints = {'a', orphanedHighSurrogate, 'b', 'c', supplementary, 'd', orphanedLowSurrogate, 'e'}; final String s = new String(codePoints, 0, codePoints.length); assertArrayEquals(codePoints, StringUtils.toCodePoints(s)); diff --git a/src/test/java/org/apache/commons/lang3/ThreadUtilsTest.java b/src/test/java/org/apache/commons/lang3/ThreadUtilsTest.java index 877fbb851..4e8df276e 100644 --- a/src/test/java/org/apache/commons/lang3/ThreadUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/ThreadUtilsTest.java @@ -213,13 +213,13 @@ public class ThreadUtilsTest { t1.start(); t2.start(); assertEquals(1, ThreadUtils.findThreadsByName("thread1_XXOOPP__").size()); - assertEquals(1, ThreadUtils.findThreadsByName("thread1_XXOOPP__","thread_group_DDZZ99__").size()); - assertEquals(1, ThreadUtils.findThreadsByName("thread2_XXOOPP__","thread_group_DDZZ99__").size()); - assertEquals(0, ThreadUtils.findThreadsByName("thread1_XXOOPP__","non_existent_thread_group_JJHHZZ__").size()); - assertEquals(0, ThreadUtils.findThreadsByName("non_existent_thread_BBDDWW__","thread_group_DDZZ99__").size()); + assertEquals(1, ThreadUtils.findThreadsByName("thread1_XXOOPP__", "thread_group_DDZZ99__").size()); + assertEquals(1, ThreadUtils.findThreadsByName("thread2_XXOOPP__", "thread_group_DDZZ99__").size()); + assertEquals(0, ThreadUtils.findThreadsByName("thread1_XXOOPP__", "non_existent_thread_group_JJHHZZ__").size()); + assertEquals(0, ThreadUtils.findThreadsByName("non_existent_thread_BBDDWW__", "thread_group_DDZZ99__").size()); assertEquals(1, ThreadUtils.findThreadGroupsByName("thread_group_DDZZ99__").size()); assertEquals(0, ThreadUtils.findThreadGroupsByName("non_existent_thread_group_JJHHZZ__").size()); - assertNotNull(ThreadUtils.findThreadById(t1.getId(),threadGroup)); + assertNotNull(ThreadUtils.findThreadById(t1.getId(), threadGroup)); } finally { t1.interrupt(); t2.interrupt(); @@ -241,16 +241,16 @@ public class ThreadUtilsTest { t1.start(); t2.start(); assertEquals(1, ThreadUtils.findThreadsByName("thread1_XXOOPP__").size()); - assertEquals(1, ThreadUtils.findThreadsByName("thread1_XXOOPP__",threadGroup).size()); - assertEquals(1, ThreadUtils.findThreadsByName("thread2_XXOOPP__",threadGroup).size()); - assertEquals(0, ThreadUtils.findThreadsByName("thread1_XXOOPP__",deadThreadGroup).size()); + assertEquals(1, ThreadUtils.findThreadsByName("thread1_XXOOPP__", threadGroup).size()); + assertEquals(1, ThreadUtils.findThreadsByName("thread2_XXOOPP__", threadGroup).size()); + assertEquals(0, ThreadUtils.findThreadsByName("thread1_XXOOPP__", deadThreadGroup).size()); } finally { t1.interrupt(); t2.interrupt(); t1.join(); t2.join(); threadGroup.destroy(); - assertEquals(0, ThreadUtils.findThreadsByName("thread2_XXOOPP__",threadGroup).size()); + assertEquals(0, ThreadUtils.findThreadsByName("thread2_XXOOPP__", threadGroup).size()); } } @@ -264,10 +264,10 @@ public class ThreadUtilsTest { try { t1.start(); t2.start(); - assertSame(t1, ThreadUtils.findThreadById(t1.getId(),"thread_group_DDZZ99__")); - assertSame(t2, ThreadUtils.findThreadById(t2.getId(),"thread_group_DDZZ99__")); - assertNull(ThreadUtils.findThreadById(nonExistingId,"non_existent_thread_group_JJHHZZ__")); - assertNull(ThreadUtils.findThreadById(nonExistingId,"thread_group_DDZZ99__")); + assertSame(t1, ThreadUtils.findThreadById(t1.getId(), "thread_group_DDZZ99__")); + assertSame(t2, ThreadUtils.findThreadById(t2.getId(), "thread_group_DDZZ99__")); + assertNull(ThreadUtils.findThreadById(nonExistingId, "non_existent_thread_group_JJHHZZ__")); + assertNull(ThreadUtils.findThreadById(nonExistingId, "thread_group_DDZZ99__")); } finally { t1.interrupt(); t2.interrupt(); @@ -297,7 +297,7 @@ public class ThreadUtilsTest { final ThreadGroup threadGroup6 = new ThreadGroup(threadGroup4, "thread_group_6__"); final ThreadGroup threadGroup7 = new ThreadGroup(threadGroup4, "thread_group_7__"); final ThreadGroup threadGroup7Doubled = new ThreadGroup(threadGroup4, "thread_group_7__"); - final List threadGroups = Arrays.asList(threadGroup1,threadGroup2,threadGroup3,threadGroup4,threadGroup5,threadGroup6, threadGroup7, threadGroup7Doubled); + final List threadGroups = Arrays.asList(threadGroup1, threadGroup2, threadGroup3, threadGroup4, threadGroup5, threadGroup6, threadGroup7, threadGroup7Doubled); final Thread t1 = new TestThread("thread1_X__"); final Thread t2 = new TestThread(threadGroup1, "thread2_X__"); @@ -311,7 +311,7 @@ public class ThreadUtilsTest { final Thread t10 = new TestThread(threadGroup3, "thread10_X__"); final Thread t11 = new TestThread(threadGroup7, "thread11_X__"); final Thread t11Doubled = new TestThread(threadGroup7Doubled, "thread11_X__"); - final List threads = Arrays.asList(t1,t2,t3,t4,t5,t6,t7,t8,t9,t10, t11, t11Doubled); + final List threads = Arrays.asList(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t11Doubled); try { for (final Thread thread : threads) { @@ -362,7 +362,7 @@ public class ThreadUtilsTest { public void run() { latch.countDown(); try { - synchronized(this){ + synchronized(this) { this.wait(); } } catch (final InterruptedException e) { diff --git a/src/test/java/org/apache/commons/lang3/builder/CompareToBuilderTest.java b/src/test/java/org/apache/commons/lang3/builder/CompareToBuilderTest.java index ef3b7c534..950b66d8d 100644 --- a/src/test/java/org/apache/commons/lang3/builder/CompareToBuilderTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/CompareToBuilderTest.java @@ -218,7 +218,7 @@ public class CompareToBuilderTest { // transitive if (CompareToBuilder.reflectionCompare(x, y, testTransients, null, excludeFields) > 0 - && CompareToBuilder.reflectionCompare(y, z, testTransients, null, excludeFields) > 0){ + && CompareToBuilder.reflectionCompare(y, z, testTransients, null, excludeFields) > 0) { assertTrue(CompareToBuilder.reflectionCompare(x, z, testTransients, null, excludeFields) > 0); } @@ -745,9 +745,9 @@ public class CompareToBuilderTest { final short[][] array3 = new short[2][3]; for (short i = 0; i < array1.length; ++i) { for (short j = 0; j < array1[0].length; j++) { - array1[i][j] = (short)((i + 1) * (j + 1)); - array2[i][j] = (short)((i + 1) * (j + 1)); - array3[i][j] = (short)((i + 1) * (j + 1)); + array1[i][j] = (short) ((i + 1) * (j + 1)); + array2[i][j] = (short) ((i + 1) * (j + 1)); + array3[i][j] = (short) ((i + 1) * (j + 1)); } } array3[1][2] = 100; @@ -769,9 +769,9 @@ public class CompareToBuilderTest { final char[][] array3 = new char[2][3]; for (short i = 0; i < array1.length; ++i) { for (short j = 0; j < array1[0].length; j++) { - array1[i][j] = (char)((i + 1) * (j + 1)); - array2[i][j] = (char)((i + 1) * (j + 1)); - array3[i][j] = (char)((i + 1) * (j + 1)); + array1[i][j] = (char) ((i + 1) * (j + 1)); + array2[i][j] = (char) ((i + 1) * (j + 1)); + array3[i][j] = (char) ((i + 1) * (j + 1)); } } array3[1][2] = 100; @@ -793,9 +793,9 @@ public class CompareToBuilderTest { final byte[][] array3 = new byte[2][3]; for (byte i = 0; i < array1.length; ++i) { for (byte j = 0; j < array1[0].length; j++) { - array1[i][j] = (byte)((i + 1) * (j + 1)); - array2[i][j] = (byte)((i + 1) * (j + 1)); - array3[i][j] = (byte)((i + 1) * (j + 1)); + array1[i][j] = (byte) ((i + 1) * (j + 1)); + array2[i][j] = (byte) ((i + 1) * (j + 1)); + array3[i][j] = (byte) ((i + 1) * (j + 1)); } } array3[1][2] = 100; diff --git a/src/test/java/org/apache/commons/lang3/builder/JsonToStringStyleTest.java b/src/test/java/org/apache/commons/lang3/builder/JsonToStringStyleTest.java index 1e22842e3..3cf8f5887 100644 --- a/src/test/java/org/apache/commons/lang3/builder/JsonToStringStyleTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/JsonToStringStyleTest.java @@ -197,9 +197,9 @@ public class JsonToStringStyleTest { @Test public void testNestingPerson() { - final Person p = new Person(){ + final Person p = new Person() { @Override - public String toString(){ + public String toString() { return new ToStringBuilder(this).append("name", this.name) .append("age", this.age).append("smoker", this.smoker) .toString(); @@ -301,16 +301,16 @@ public class JsonToStringStyleTest { @Test public void testLANG1395() { - assertEquals("{\"name\":\"value\"}",new ToStringBuilder(base).append("name","value").toString()); - assertEquals("{\"name\":\"\"}",new ToStringBuilder(base).append("name","").toString()); - assertEquals("{\"name\":\"\\\"\"}",new ToStringBuilder(base).append("name",'"').toString()); - assertEquals("{\"name\":\"\\\\\"}",new ToStringBuilder(base).append("name",'\\').toString()); - assertEquals("{\"name\":\"Let's \\\"quote\\\" this\"}",new ToStringBuilder(base).append("name","Let's \"quote\" this").toString()); + assertEquals("{\"name\":\"value\"}", new ToStringBuilder(base).append("name", "value").toString()); + assertEquals("{\"name\":\"\"}", new ToStringBuilder(base).append("name", "").toString()); + assertEquals("{\"name\":\"\\\"\"}", new ToStringBuilder(base).append("name", '"').toString()); + assertEquals("{\"name\":\"\\\\\"}", new ToStringBuilder(base).append("name", '\\').toString()); + assertEquals("{\"name\":\"Let's \\\"quote\\\" this\"}", new ToStringBuilder(base).append("name", "Let's \"quote\" this").toString()); } @Test public void testLANG1396() { - assertEquals("{\"Let's \\\"quote\\\" this\":\"value\"}",new ToStringBuilder(base).append("Let's \"quote\" this","value").toString()); + assertEquals("{\"Let's \\\"quote\\\" this\":\"value\"}", new ToStringBuilder(base).append("Let's \"quote\" this", "value").toString()); } /** diff --git a/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeNullValuesTest.java b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeNullValuesTest.java index 8ddf9b4b7..c97d7e5f7 100644 --- a/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeNullValuesTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeNullValuesTest.java @@ -44,7 +44,7 @@ public class ReflectionToStringBuilderExcludeNullValuesTest { private final TestFixture BOTH_NULL = new TestFixture(null, null); @Test - public void test_NonExclude(){ + public void test_NonExclude() { //normal case= String toString = ReflectionToStringBuilder.toString(BOTH_NON_NULL, null, false, false, false, null); assertTrue(toString.contains(INTEGER_FIELD_NAME)); @@ -67,7 +67,7 @@ public class ReflectionToStringBuilderExcludeNullValuesTest { } @Test - public void test_excludeNull(){ + public void test_excludeNull() { //test normal case String toString = ReflectionToStringBuilder.toString(BOTH_NON_NULL, null, false, false, true, null); @@ -91,7 +91,7 @@ public class ReflectionToStringBuilderExcludeNullValuesTest { } @Test - public void test_ConstructorOption(){ + public void test_ConstructorOption() { ReflectionToStringBuilder builder = new ReflectionToStringBuilder(BOTH_NON_NULL, null, null, null, false, false, true); assertTrue(builder.isExcludeNullValues()); String toString = builder.toString(); @@ -115,7 +115,7 @@ public class ReflectionToStringBuilderExcludeNullValuesTest { } @Test - public void test_ConstructorOptionNormal(){ + public void test_ConstructorOptionNormal() { final ReflectionToStringBuilder builder = new ReflectionToStringBuilder(BOTH_NULL, null, null, null, false, false, false); assertFalse(builder.isExcludeNullValues()); String toString = builder.toString(); @@ -140,7 +140,7 @@ public class ReflectionToStringBuilderExcludeNullValuesTest { } @Test - public void test_ConstructorOption_ExcludeNull(){ + public void test_ConstructorOption_ExcludeNull() { ReflectionToStringBuilder builder = new ReflectionToStringBuilder(BOTH_NULL, null, null, null, false, false, false); builder.setExcludeNullValues(true); assertTrue(builder.isExcludeNullValues()); diff --git a/src/test/java/org/apache/commons/lang3/builder/ToStringBuilderTest.java b/src/test/java/org/apache/commons/lang3/builder/ToStringBuilderTest.java index 3366721e7..da973e7ca 100644 --- a/src/test/java/org/apache/commons/lang3/builder/ToStringBuilderTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/ToStringBuilderTest.java @@ -46,7 +46,7 @@ public class ToStringBuilderTest { * All tests should leave the registry empty. */ @AfterEach - public void after(){ + public void after() { validateNullToStringStyleRegistry(); } @@ -512,7 +512,7 @@ public class ToStringBuilderTest { this.typeIsSelf = this; } - public String getOtherType(){ + public String getOtherType() { return this.otherType; } @@ -845,7 +845,7 @@ public class ToStringBuilderTest { } @Test - public void testConstructToStringBuilder(){ + public void testConstructToStringBuilder() { final ToStringBuilder stringBuilder1 = new ToStringBuilder(base, null, null); final ToStringBuilder stringBuilder2 = new ToStringBuilder(base, ToStringStyle.DEFAULT_STYLE, new StringBuffer(1024)); assertEquals(ToStringStyle.DEFAULT_STYLE, stringBuilder1.getStyle()); diff --git a/src/test/java/org/apache/commons/lang3/exception/ContextedRuntimeExceptionTest.java b/src/test/java/org/apache/commons/lang3/exception/ContextedRuntimeExceptionTest.java index 16d36bf67..76f718c36 100644 --- a/src/test/java/org/apache/commons/lang3/exception/ContextedRuntimeExceptionTest.java +++ b/src/test/java/org/apache/commons/lang3/exception/ContextedRuntimeExceptionTest.java @@ -82,7 +82,9 @@ public class ContextedRuntimeExceptionTest extends AbstractExceptionContextTest< public void testContextedExceptionStringThrowableContext() { // Use an anonymous subclass to make sure users can provide custom implementations exceptionContext = new ContextedRuntimeException(TEST_MESSAGE_2, new Exception(TEST_MESSAGE), - new DefaultExceptionContext() {private static final long serialVersionUID = 1L;}); + new DefaultExceptionContext() { + private static final long serialVersionUID = 1L; + }); final String message = exceptionContext.getMessage(); final String trace = ExceptionUtils.getStackTrace(exceptionContext); assertTrue(trace.contains("ContextedException")); diff --git a/src/test/java/org/apache/commons/lang3/math/FractionTest.java b/src/test/java/org/apache/commons/lang3/math/FractionTest.java index 59a17b9dd..10daae01c 100644 --- a/src/test/java/org/apache/commons/lang3/math/FractionTest.java +++ b/src/test/java/org/apache/commons/lang3/math/FractionTest.java @@ -745,8 +745,8 @@ public class FractionTest { // if this fraction is added naively, it will overflow. // check that it doesn't. - f1 = Fraction.getFraction(1,32768*3); - f2 = Fraction.getFraction(1,59049); + f1 = Fraction.getFraction(1, 32768*3); + f2 = Fraction.getFraction(1, 59049); f = f1.add(f2); assertEquals(52451, f.getNumerator()); assertEquals(1934917632, f.getDenominator()); @@ -769,7 +769,7 @@ public class FractionTest { // denominator should not be a multiple of 2 or 3 to trigger overflow assertThrows( ArithmeticException.class, - () -> Fraction.getFraction(Integer.MIN_VALUE, 5).add(Fraction.getFraction(-1,5))); + () -> Fraction.getFraction(Integer.MIN_VALUE, 5).add(Fraction.getFraction(-1, 5))); final Fraction maxValue = Fraction.getFraction(-Integer.MAX_VALUE, 1); assertThrows(ArithmeticException.class, () -> maxValue.add(maxValue)); @@ -777,8 +777,8 @@ public class FractionTest { final Fraction negativeMaxValue = Fraction.getFraction(-Integer.MAX_VALUE, 1); assertThrows(ArithmeticException.class, () -> negativeMaxValue.add(negativeMaxValue)); - final Fraction f3 = Fraction.getFraction(3,327680); - final Fraction f4 = Fraction.getFraction(2,59049); + final Fraction f3 = Fraction.getFraction(3, 327680); + final Fraction f4 = Fraction.getFraction(2, 59049); assertThrows(ArithmeticException.class, () -> f3.add(f4)); // should overflow } @@ -840,8 +840,8 @@ public class FractionTest { // if this fraction is subtracted naively, it will overflow. // check that it doesn't. - f1 = Fraction.getFraction(1,32768*3); - f2 = Fraction.getFraction(1,59049); + f1 = Fraction.getFraction(1, 32768*3); + f2 = Fraction.getFraction(1, 59049); f = f1.subtract(f2); assertEquals(-13085, f.getNumerator()); assertEquals(1934917632, f.getDenominator()); @@ -867,7 +867,7 @@ public class FractionTest { // denominator should not be a multiple of 2 or 3 to trigger overflow assertThrows( ArithmeticException.class, - () -> Fraction.getFraction(Integer.MIN_VALUE, 5).subtract(Fraction.getFraction(1,5))); + () -> Fraction.getFraction(Integer.MIN_VALUE, 5).subtract(Fraction.getFraction(1, 5))); assertThrows( ArithmeticException.class, () -> Fraction.getFraction(Integer.MIN_VALUE, 1).subtract(Fraction.ONE)); @@ -879,7 +879,7 @@ public class FractionTest { // Should overflow assertThrows( ArithmeticException.class, - () -> Fraction.getFraction(3,327680).subtract(Fraction.getFraction(2,59049))); + () -> Fraction.getFraction(3, 327680).subtract(Fraction.getFraction(2, 59049))); } @Test diff --git a/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java b/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java index 58569d0fe..0cb8be7a0 100644 --- a/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java @@ -65,8 +65,8 @@ public class NumberUtilsTest { */ @Test public void testToIntStringI() { - assertEquals(12345, NumberUtils.toInt("12345", 5), "toInt(String,int) 1 failed"); - assertEquals(5, NumberUtils.toInt("1234.5", 5), "toInt(String,int) 2 failed"); + assertEquals(12345, NumberUtils.toInt("12345", 5), "toInt(String, int) 1 failed"); + assertEquals(5, NumberUtils.toInt("1234.5", 5), "toInt(String, int) 2 failed"); } /** @@ -89,8 +89,8 @@ public class NumberUtilsTest { */ @Test public void testToLongStringL() { - assertEquals(12345L, NumberUtils.toLong("12345", 5L), "toLong(String,long) 1 failed"); - assertEquals(5L, NumberUtils.toLong("1234.5", 5L), "toLong(String,long) 2 failed"); + assertEquals(12345L, NumberUtils.toLong("12345", 5L), "toLong(String, long) 1 failed"); + assertEquals(5L, NumberUtils.toLong("1234.5", 5L), "toLong(String, long) 2 failed"); } /** @@ -118,19 +118,19 @@ public class NumberUtilsTest { */ @Test public void testToFloatStringF() { - assertTrue(NumberUtils.toFloat("1.2345", 5.1f) == 1.2345f, "toFloat(String,int) 1 failed"); - assertTrue(NumberUtils.toFloat("a", 5.0f) == 5.0f, "toFloat(String,int) 2 failed"); + assertTrue(NumberUtils.toFloat("1.2345", 5.1f) == 1.2345f, "toFloat(String, int) 1 failed"); + assertTrue(NumberUtils.toFloat("a", 5.0f) == 5.0f, "toFloat(String, int) 2 failed"); // LANG-1060 - assertTrue(NumberUtils.toFloat("-001Z.2345", 5.0f) == 5.0f, "toFloat(String,int) 3 failed"); - assertTrue(NumberUtils.toFloat("+001AB.2345", 5.0f) == 5.0f, "toFloat(String,int) 4 failed"); - assertTrue(NumberUtils.toFloat("001Z.2345", 5.0f) == 5.0f, "toFloat(String,int) 5 failed"); + assertTrue(NumberUtils.toFloat("-001Z.2345", 5.0f) == 5.0f, "toFloat(String, int) 3 failed"); + assertTrue(NumberUtils.toFloat("+001AB.2345", 5.0f) == 5.0f, "toFloat(String, int) 4 failed"); + assertTrue(NumberUtils.toFloat("001Z.2345", 5.0f) == 5.0f, "toFloat(String, int) 5 failed"); } /** * Test for {(@link NumberUtils#createNumber(String)} */ @Test - public void testStringCreateNumberEnsureNoPrecisionLoss(){ + public void testStringCreateNumberEnsureNoPrecisionLoss() { final String shouldBeFloat = "1.23"; final String shouldBeDouble = "3.40282354e+38"; final String shouldBeBigDecimal = "1.797693134862315759e+308"; @@ -173,13 +173,13 @@ public class NumberUtilsTest { */ @Test public void testStringToDoubleStringD() { - assertTrue(NumberUtils.toDouble("1.2345", 5.1d) == 1.2345d, "toDouble(String,int) 1 failed"); - assertTrue(NumberUtils.toDouble("a", 5.0d) == 5.0d, "toDouble(String,int) 2 failed"); + assertTrue(NumberUtils.toDouble("1.2345", 5.1d) == 1.2345d, "toDouble(String, int) 1 failed"); + assertTrue(NumberUtils.toDouble("a", 5.0d) == 5.0d, "toDouble(String, int) 2 failed"); // LANG-1060 - assertTrue(NumberUtils.toDouble("001.2345", 5.1d) == 1.2345d, "toDouble(String,int) 3 failed"); - assertTrue(NumberUtils.toDouble("-001.2345", 5.1d) == -1.2345d, "toDouble(String,int) 4 failed"); - assertTrue(NumberUtils.toDouble("+001.2345", 5.1d) == 1.2345d, "toDouble(String,int) 5 failed"); - assertTrue(NumberUtils.toDouble("000.00", 5.1d) == 0d, "toDouble(String,int) 7 failed"); + assertTrue(NumberUtils.toDouble("001.2345", 5.1d) == 1.2345d, "toDouble(String, int) 3 failed"); + assertTrue(NumberUtils.toDouble("-001.2345", 5.1d) == -1.2345d, "toDouble(String, int) 4 failed"); + assertTrue(NumberUtils.toDouble("+001.2345", 5.1d) == 1.2345d, "toDouble(String, int) 5 failed"); + assertTrue(NumberUtils.toDouble("000.00", 5.1d) == 0d, "toDouble(String, int) 7 failed"); } /** @@ -216,8 +216,8 @@ public class NumberUtilsTest { */ @Test public void testToByteStringI() { - assertEquals(123, NumberUtils.toByte("123", (byte) 5), "toByte(String,byte) 1 failed"); - assertEquals(5, NumberUtils.toByte("12.3", (byte) 5), "toByte(String,byte) 2 failed"); + assertEquals(123, NumberUtils.toByte("123", (byte) 5), "toByte(String, byte) 1 failed"); + assertEquals(5, NumberUtils.toByte("12.3", (byte) 5), "toByte(String, byte) 2 failed"); } /** @@ -236,8 +236,8 @@ public class NumberUtilsTest { */ @Test public void testToShortStringI() { - assertEquals(12345, NumberUtils.toShort("12345", (short) 5), "toShort(String,short) 1 failed"); - assertEquals(5, NumberUtils.toShort("1234.5", (short) 5), "toShort(String,short) 2 failed"); + assertEquals(12345, NumberUtils.toShort("12345", (short) 5), "toShort(String, short) 1 failed"); + assertEquals(5, NumberUtils.toShort("1234.5", (short) 5), "toShort(String, short) 2 failed"); } /** @@ -429,7 +429,7 @@ public class NumberUtilsTest { } @Test - public void testLang1087(){ + public void testLang1087() { // no sign cases assertEquals(Float.class, NumberUtils.createNumber("0.0").getClass()); assertEquals(Float.valueOf("0.0"), NumberUtils.createNumber("0.0")); @@ -544,16 +544,16 @@ public class NumberUtilsTest { assertEquals(Long.valueOf(0x7fffffffffffffffL), NumberUtils.createNumber("0x7fffffffffffffff")); // Does not appear to be a way to create a literal BigInteger of this magnitude - assertEquals(new BigInteger("7fffffffffffffff0",16), NumberUtils.createNumber("0x7fffffffffffffff0")); + assertEquals(new BigInteger("7fffffffffffffff0", 16), NumberUtils.createNumber("0x7fffffffffffffff0")); assertEquals(Long.valueOf(0x7fffffffffffffffL), NumberUtils.createNumber("#7fffffffffffffff")); - assertEquals(new BigInteger("7fffffffffffffff0",16), NumberUtils.createNumber("#7fffffffffffffff0")); + assertEquals(new BigInteger("7fffffffffffffff0", 16), NumberUtils.createNumber("#7fffffffffffffff0")); assertEquals(Integer.valueOf(017777777777), NumberUtils.createNumber("017777777777")); // 31 bits assertEquals(Long.valueOf(037777777777L), NumberUtils.createNumber("037777777777")); // 32 bits assertEquals(Long.valueOf(0777777777777777777777L), NumberUtils.createNumber("0777777777777777777777")); // 63 bits - assertEquals(new BigInteger("1777777777777777777777",8), NumberUtils.createNumber("01777777777777777777777"));// 64 bits + assertEquals(new BigInteger("1777777777777777777777", 8), NumberUtils.createNumber("01777777777777777777777")); // 64 bits } @Test @@ -935,20 +935,20 @@ public class NumberUtilsTest { @Test public void testMinimumLong() { - assertEquals(12345L, NumberUtils.min(12345L, 12345L + 1L, 12345L + 2L), "minimum(long,long,long) 1 failed"); - assertEquals(12345L, NumberUtils.min(12345L + 1L, 12345L, 12345 + 2L), "minimum(long,long,long) 2 failed"); - assertEquals(12345L, NumberUtils.min(12345L + 1L, 12345L + 2L, 12345L), "minimum(long,long,long) 3 failed"); - assertEquals(12345L, NumberUtils.min(12345L + 1L, 12345L, 12345L), "minimum(long,long,long) 4 failed"); - assertEquals(12345L, NumberUtils.min(12345L, 12345L, 12345L), "minimum(long,long,long) 5 failed"); + assertEquals(12345L, NumberUtils.min(12345L, 12345L + 1L, 12345L + 2L), "minimum(long, long, long) 1 failed"); + assertEquals(12345L, NumberUtils.min(12345L + 1L, 12345L, 12345 + 2L), "minimum(long, long, long) 2 failed"); + assertEquals(12345L, NumberUtils.min(12345L + 1L, 12345L + 2L, 12345L), "minimum(long, long, long) 3 failed"); + assertEquals(12345L, NumberUtils.min(12345L + 1L, 12345L, 12345L), "minimum(long, long, long) 4 failed"); + assertEquals(12345L, NumberUtils.min(12345L, 12345L, 12345L), "minimum(long, long, long) 5 failed"); } @Test public void testMinimumInt() { - assertEquals(12345, NumberUtils.min(12345, 12345 + 1, 12345 + 2), "minimum(int,int,int) 1 failed"); - assertEquals(12345, NumberUtils.min(12345 + 1, 12345, 12345 + 2), "minimum(int,int,int) 2 failed"); - assertEquals(12345, NumberUtils.min(12345 + 1, 12345 + 2, 12345), "minimum(int,int,int) 3 failed"); - assertEquals(12345, NumberUtils.min(12345 + 1, 12345, 12345), "minimum(int,int,int) 4 failed"); - assertEquals(12345, NumberUtils.min(12345, 12345, 12345), "minimum(int,int,int) 5 failed"); + assertEquals(12345, NumberUtils.min(12345, 12345 + 1, 12345 + 2), "minimum(int, int, int) 1 failed"); + assertEquals(12345, NumberUtils.min(12345 + 1, 12345, 12345 + 2), "minimum(int, int, int) 2 failed"); + assertEquals(12345, NumberUtils.min(12345 + 1, 12345 + 2, 12345), "minimum(int, int, int) 3 failed"); + assertEquals(12345, NumberUtils.min(12345 + 1, 12345, 12345), "minimum(int, int, int) 4 failed"); + assertEquals(12345, NumberUtils.min(12345, 12345, 12345), "minimum(int, int, int) 5 failed"); } @Test @@ -956,10 +956,10 @@ public class NumberUtilsTest { final short low = 1234; final short mid = 1234 + 1; final short high = 1234 + 2; - assertEquals(low, NumberUtils.min(low, mid, high), "minimum(short,short,short) 1 failed"); - assertEquals(low, NumberUtils.min(mid, low, high), "minimum(short,short,short) 2 failed"); - assertEquals(low, NumberUtils.min(mid, high, low), "minimum(short,short,short) 3 failed"); - assertEquals(low, NumberUtils.min(low, mid, low), "minimum(short,short,short) 4 failed"); + assertEquals(low, NumberUtils.min(low, mid, high), "minimum(short, short, short) 1 failed"); + assertEquals(low, NumberUtils.min(mid, low, high), "minimum(short, short, short) 2 failed"); + assertEquals(low, NumberUtils.min(mid, high, low), "minimum(short, short, short) 3 failed"); + assertEquals(low, NumberUtils.min(low, mid, low), "minimum(short, short, short) 4 failed"); } @Test @@ -967,10 +967,10 @@ public class NumberUtilsTest { final byte low = 123; final byte mid = 123 + 1; final byte high = 123 + 2; - assertEquals(low, NumberUtils.min(low, mid, high), "minimum(byte,byte,byte) 1 failed"); - assertEquals(low, NumberUtils.min(mid, low, high), "minimum(byte,byte,byte) 2 failed"); - assertEquals(low, NumberUtils.min(mid, high, low), "minimum(byte,byte,byte) 3 failed"); - assertEquals(low, NumberUtils.min(low, mid, low), "minimum(byte,byte,byte) 4 failed"); + assertEquals(low, NumberUtils.min(low, mid, high), "minimum(byte, byte, byte) 1 failed"); + assertEquals(low, NumberUtils.min(mid, low, high), "minimum(byte, byte, byte) 2 failed"); + assertEquals(low, NumberUtils.min(mid, high, low), "minimum(byte, byte, byte) 3 failed"); + assertEquals(low, NumberUtils.min(low, mid, low), "minimum(byte, byte, byte) 4 failed"); } @Test @@ -999,20 +999,20 @@ public class NumberUtilsTest { @Test public void testMaximumLong() { - assertEquals(12345L, NumberUtils.max(12345L, 12345L - 1L, 12345L - 2L), "maximum(long,long,long) 1 failed"); - assertEquals(12345L, NumberUtils.max(12345L - 1L, 12345L, 12345L - 2L), "maximum(long,long,long) 2 failed"); - assertEquals(12345L, NumberUtils.max(12345L - 1L, 12345L - 2L, 12345L), "maximum(long,long,long) 3 failed"); - assertEquals(12345L, NumberUtils.max(12345L - 1L, 12345L, 12345L), "maximum(long,long,long) 4 failed"); - assertEquals(12345L, NumberUtils.max(12345L, 12345L, 12345L), "maximum(long,long,long) 5 failed"); + assertEquals(12345L, NumberUtils.max(12345L, 12345L - 1L, 12345L - 2L), "maximum(long, long, long) 1 failed"); + assertEquals(12345L, NumberUtils.max(12345L - 1L, 12345L, 12345L - 2L), "maximum(long, long, long) 2 failed"); + assertEquals(12345L, NumberUtils.max(12345L - 1L, 12345L - 2L, 12345L), "maximum(long, long, long) 3 failed"); + assertEquals(12345L, NumberUtils.max(12345L - 1L, 12345L, 12345L), "maximum(long, long, long) 4 failed"); + assertEquals(12345L, NumberUtils.max(12345L, 12345L, 12345L), "maximum(long, long, long) 5 failed"); } @Test public void testMaximumInt() { - assertEquals(12345, NumberUtils.max(12345, 12345 - 1, 12345 - 2), "maximum(int,int,int) 1 failed"); - assertEquals(12345, NumberUtils.max(12345 - 1, 12345, 12345 - 2), "maximum(int,int,int) 2 failed"); - assertEquals(12345, NumberUtils.max(12345 - 1, 12345 - 2, 12345), "maximum(int,int,int) 3 failed"); - assertEquals(12345, NumberUtils.max(12345 - 1, 12345, 12345), "maximum(int,int,int) 4 failed"); - assertEquals(12345, NumberUtils.max(12345, 12345, 12345), "maximum(int,int,int) 5 failed"); + assertEquals(12345, NumberUtils.max(12345, 12345 - 1, 12345 - 2), "maximum(int, int, int) 1 failed"); + assertEquals(12345, NumberUtils.max(12345 - 1, 12345, 12345 - 2), "maximum(int, int, int) 2 failed"); + assertEquals(12345, NumberUtils.max(12345 - 1, 12345 - 2, 12345), "maximum(int, int, int) 3 failed"); + assertEquals(12345, NumberUtils.max(12345 - 1, 12345, 12345), "maximum(int, int, int) 4 failed"); + assertEquals(12345, NumberUtils.max(12345, 12345, 12345), "maximum(int, int, int) 5 failed"); } @Test @@ -1020,10 +1020,10 @@ public class NumberUtilsTest { final short low = 1234; final short mid = 1234 + 1; final short high = 1234 + 2; - assertEquals(high, NumberUtils.max(low, mid, high), "maximum(short,short,short) 1 failed"); - assertEquals(high, NumberUtils.max(mid, low, high), "maximum(short,short,short) 2 failed"); - assertEquals(high, NumberUtils.max(mid, high, low), "maximum(short,short,short) 3 failed"); - assertEquals(high, NumberUtils.max(high, mid, high), "maximum(short,short,short) 4 failed"); + assertEquals(high, NumberUtils.max(low, mid, high), "maximum(short, short, short) 1 failed"); + assertEquals(high, NumberUtils.max(mid, low, high), "maximum(short, short, short) 2 failed"); + assertEquals(high, NumberUtils.max(mid, high, low), "maximum(short, short, short) 3 failed"); + assertEquals(high, NumberUtils.max(high, mid, high), "maximum(short, short, short) 4 failed"); } @Test @@ -1031,10 +1031,10 @@ public class NumberUtilsTest { final byte low = 123; final byte mid = 123 + 1; final byte high = 123 + 2; - assertEquals(high, NumberUtils.max(low, mid, high), "maximum(byte,byte,byte) 1 failed"); - assertEquals(high, NumberUtils.max(mid, low, high), "maximum(byte,byte,byte) 2 failed"); - assertEquals(high, NumberUtils.max(mid, high, low), "maximum(byte,byte,byte) 3 failed"); - assertEquals(high, NumberUtils.max(high, mid, high), "maximum(byte,byte,byte) 4 failed"); + assertEquals(high, NumberUtils.max(low, mid, high), "maximum(byte, byte, byte) 1 failed"); + assertEquals(high, NumberUtils.max(mid, low, high), "maximum(byte, byte, byte) 2 failed"); + assertEquals(high, NumberUtils.max(mid, high, low), "maximum(byte, byte, byte) 3 failed"); + assertEquals(high, NumberUtils.max(high, mid, high), "maximum(byte, byte, byte) 4 failed"); } @Test @@ -1464,7 +1464,7 @@ public class NumberUtilsTest { assertFalse( NumberUtils.isParsable("0xC1AB") ); assertFalse( NumberUtils.isParsable("65CBA2") ); assertFalse( NumberUtils.isParsable("pendro") ); - assertFalse( NumberUtils.isParsable("64,2") ); + assertFalse( NumberUtils.isParsable("64, 2") ); assertFalse( NumberUtils.isParsable("64.2.2") ); assertFalse( NumberUtils.isParsable("64.") ); assertFalse( NumberUtils.isParsable("64L") ); @@ -1576,15 +1576,15 @@ public class NumberUtilsTest { @Test public void compareShort() { - assertTrue(NumberUtils.compare((short)-3, (short)0) < 0); + assertTrue(NumberUtils.compare((short) -3, (short) 0) < 0); assertEquals(0, NumberUtils.compare((short) 113, (short) 113)); - assertTrue(NumberUtils.compare((short)213, (short)32) > 0); + assertTrue(NumberUtils.compare((short) 213, (short) 32) > 0); } @Test public void compareByte() { - assertTrue(NumberUtils.compare((byte)-3, (byte)0) < 0); + assertTrue(NumberUtils.compare((byte) -3, (byte) 0) < 0); assertEquals(0, NumberUtils.compare((byte) 113, (byte) 113)); - assertTrue(NumberUtils.compare((byte)123, (byte)32) > 0); + assertTrue(NumberUtils.compare((byte) 123, (byte) 32) > 0); } } diff --git a/src/test/java/org/apache/commons/lang3/mutable/MutableByteTest.java b/src/test/java/org/apache/commons/lang3/mutable/MutableByteTest.java index 7f5d41293..60ab0bc32 100644 --- a/src/test/java/org/apache/commons/lang3/mutable/MutableByteTest.java +++ b/src/test/java/org/apache/commons/lang3/mutable/MutableByteTest.java @@ -47,7 +47,7 @@ public class MutableByteTest { @Test public void testConstructorNull() { - assertThrows(NullPointerException.class, () -> new MutableByte((Number)null)); + assertThrows(NullPointerException.class, () -> new MutableByte((Number) null)); } @Test @@ -202,7 +202,7 @@ public class MutableByteTest { @Test public void testAddValuePrimitive() { final MutableByte mutNum = new MutableByte((byte) 1); - mutNum.add((byte)1); + mutNum.add((byte) 1); assertEquals((byte) 2, mutNum.byteValue()); } @@ -217,7 +217,7 @@ public class MutableByteTest { @Test public void testGetAndAddValuePrimitive() { - final MutableByte mutableByte = new MutableByte((byte)0); + final MutableByte mutableByte = new MutableByte((byte) 0); final byte result = mutableByte.getAndAdd((byte) 1); assertEquals((byte) 0, result); @@ -226,7 +226,7 @@ public class MutableByteTest { @Test public void testGetAndAddValueObject() { - final MutableByte mutableByte = new MutableByte((byte)0); + final MutableByte mutableByte = new MutableByte((byte) 0); final byte result = mutableByte.getAndAdd(Byte.valueOf((byte) 1)); assertEquals((byte) 0, result); @@ -235,7 +235,7 @@ public class MutableByteTest { @Test public void testAddAndGetValuePrimitive() { - final MutableByte mutableByte = new MutableByte((byte)0); + final MutableByte mutableByte = new MutableByte((byte) 0); final byte result = mutableByte.addAndGet((byte) 1); assertEquals((byte) 1, result); @@ -244,7 +244,7 @@ public class MutableByteTest { @Test public void testAddAndGetValueObject() { - final MutableByte mutableByte = new MutableByte((byte)0); + final MutableByte mutableByte = new MutableByte((byte) 0); final byte result = mutableByte.addAndGet(Byte.valueOf((byte) 1)); assertEquals((byte) 1, result); diff --git a/src/test/java/org/apache/commons/lang3/mutable/MutableDoubleTest.java b/src/test/java/org/apache/commons/lang3/mutable/MutableDoubleTest.java index 5bb417dbf..b0ee09f3e 100644 --- a/src/test/java/org/apache/commons/lang3/mutable/MutableDoubleTest.java +++ b/src/test/java/org/apache/commons/lang3/mutable/MutableDoubleTest.java @@ -47,7 +47,7 @@ public class MutableDoubleTest { @Test public void testConstructorNull() { - assertThrows(NullPointerException.class, () -> new MutableDouble((Number)null)); + assertThrows(NullPointerException.class, () -> new MutableDouble((Number) null)); } @Test diff --git a/src/test/java/org/apache/commons/lang3/mutable/MutableFloatTest.java b/src/test/java/org/apache/commons/lang3/mutable/MutableFloatTest.java index 4b479eca9..9fd1992f0 100644 --- a/src/test/java/org/apache/commons/lang3/mutable/MutableFloatTest.java +++ b/src/test/java/org/apache/commons/lang3/mutable/MutableFloatTest.java @@ -47,7 +47,7 @@ public class MutableFloatTest { @Test public void testConstructorNull() { - assertThrows(NullPointerException.class, () -> new MutableFloat((Number)null)); + assertThrows(NullPointerException.class, () -> new MutableFloat((Number) null)); } @Test diff --git a/src/test/java/org/apache/commons/lang3/mutable/MutableIntTest.java b/src/test/java/org/apache/commons/lang3/mutable/MutableIntTest.java index 27eb976a6..c4bc826ea 100644 --- a/src/test/java/org/apache/commons/lang3/mutable/MutableIntTest.java +++ b/src/test/java/org/apache/commons/lang3/mutable/MutableIntTest.java @@ -47,7 +47,7 @@ public class MutableIntTest { @Test public void testConstructorNull() { - assertThrows(NullPointerException.class, () -> new MutableInt((Number)null)); + assertThrows(NullPointerException.class, () -> new MutableInt((Number) null)); } @Test diff --git a/src/test/java/org/apache/commons/lang3/mutable/MutableLongTest.java b/src/test/java/org/apache/commons/lang3/mutable/MutableLongTest.java index 15ed28eae..66d2ee8a8 100644 --- a/src/test/java/org/apache/commons/lang3/mutable/MutableLongTest.java +++ b/src/test/java/org/apache/commons/lang3/mutable/MutableLongTest.java @@ -47,7 +47,7 @@ public class MutableLongTest { @Test public void testConstructorNull() { - assertThrows(NullPointerException.class, () -> new MutableLong((Number)null)); + assertThrows(NullPointerException.class, () -> new MutableLong((Number) null)); } @Test diff --git a/src/test/java/org/apache/commons/lang3/mutable/MutableShortTest.java b/src/test/java/org/apache/commons/lang3/mutable/MutableShortTest.java index 08df29806..89fb914e1 100644 --- a/src/test/java/org/apache/commons/lang3/mutable/MutableShortTest.java +++ b/src/test/java/org/apache/commons/lang3/mutable/MutableShortTest.java @@ -43,7 +43,7 @@ public class MutableShortTest { assertEquals((short) 2, new MutableShort("2").shortValue()); - assertThrows(NullPointerException.class, () -> new MutableShort((Number)null)); + assertThrows(NullPointerException.class, () -> new MutableShort((Number) null)); } @Test @@ -203,7 +203,7 @@ public class MutableShortTest { @Test public void testGetAndAddValuePrimitive() { - final MutableShort mutableShort = new MutableShort((short)0); + final MutableShort mutableShort = new MutableShort((short) 0); final short result = mutableShort.getAndAdd((short) 1); assertEquals((short) 0, result); @@ -212,7 +212,7 @@ public class MutableShortTest { @Test public void testGetAndAddValueObject() { - final MutableShort mutableShort = new MutableShort((short)0); + final MutableShort mutableShort = new MutableShort((short) 0); final short result = mutableShort.getAndAdd(Short.valueOf((short) 1)); assertEquals((short) 0, result); diff --git a/src/test/java/org/apache/commons/lang3/reflect/ConstructorUtilsTest.java b/src/test/java/org/apache/commons/lang3/reflect/ConstructorUtilsTest.java index 4519d5f09..50973ba07 100644 --- a/src/test/java/org/apache/commons/lang3/reflect/ConstructorUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/reflect/ConstructorUtilsTest.java @@ -90,7 +90,7 @@ public class ConstructorUtilsTest { public TestBean(final Integer first, final int... args) { toString = "(Integer, String...)"; varArgs = new String[args.length]; - for(int i = 0; i< args.length; ++i) { + for (int i = 0; i< args.length; ++i) { varArgs[i] = Integer.toString(args[i]); } } @@ -188,7 +188,7 @@ public class ConstructorUtilsTest { assertThrows( NoSuchMethodException.class, - () -> ConstructorUtils.invokeExactConstructor(TestBean.class,NumberUtils.BYTE_ONE)); + () -> ConstructorUtils.invokeExactConstructor(TestBean.class, NumberUtils.BYTE_ONE)); assertThrows( NoSuchMethodException.class, () -> ConstructorUtils.invokeExactConstructor(TestBean.class, NumberUtils.LONG_ONE)); diff --git a/src/test/java/org/apache/commons/lang3/reflect/FieldUtilsTest.java b/src/test/java/org/apache/commons/lang3/reflect/FieldUtilsTest.java index 9ed912330..8217a8992 100644 --- a/src/test/java/org/apache/commons/lang3/reflect/FieldUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/reflect/FieldUtilsTest.java @@ -231,7 +231,7 @@ public class FieldUtilsTest { FieldUtilsTest.class.getDeclaredField("privatelyShadowedChild") ); final List fieldUtilsTestAnnotatedFields = FieldUtils.getFieldsListWithAnnotation(FieldUtilsTest.class, Annotated.class); - assertEquals(annotatedFields.size(),fieldUtilsTestAnnotatedFields.size()); + assertEquals(annotatedFields.size(), fieldUtilsTestAnnotatedFields.size()); assertTrue(fieldUtilsTestAnnotatedFields.contains(annotatedFields.get(0))); assertTrue(fieldUtilsTestAnnotatedFields.contains(annotatedFields.get(1))); } diff --git a/src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java b/src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java index 66cf39d74..46327db8f 100644 --- a/src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java @@ -744,7 +744,7 @@ public class TypeUtilsTest { @Test public void testLang1114() throws Exception { final Type nonWildcardType = getClass().getDeclaredField("wildcardComparable").getGenericType(); - final Type wildcardType = ((ParameterizedType)nonWildcardType).getActualTypeArguments()[0]; + final Type wildcardType = ((ParameterizedType) nonWildcardType).getActualTypeArguments()[0]; assertFalse(TypeUtils.equals(wildcardType, nonWildcardType)); assertFalse(TypeUtils.equals(nonWildcardType, wildcardType)); diff --git a/src/test/java/org/apache/commons/lang3/text/ExtendedMessageFormatTest.java b/src/test/java/org/apache/commons/lang3/text/ExtendedMessageFormatTest.java index 624976569..f43bd9c1d 100644 --- a/src/test/java/org/apache/commons/lang3/text/ExtendedMessageFormatTest.java +++ b/src/test/java/org/apache/commons/lang3/text/ExtendedMessageFormatTest.java @@ -405,7 +405,7 @@ public class ExtendedMessageFormatTest { @Override public StringBuffer format(final Object obj, final StringBuffer toAppendTo, final FieldPosition pos) { - return toAppendTo.append(((String)obj).toLowerCase(Locale.ROOT)); + return toAppendTo.append(((String) obj).toLowerCase(Locale.ROOT)); } @Override public Object parseObject(final String source, final ParsePosition pos) { diff --git a/src/test/java/org/apache/commons/lang3/text/StrBuilderAppendInsertTest.java b/src/test/java/org/apache/commons/lang3/text/StrBuilderAppendInsertTest.java index 86a1b5c28..a2b04f285 100644 --- a/src/test/java/org/apache/commons/lang3/text/StrBuilderAppendInsertTest.java +++ b/src/test/java/org/apache/commons/lang3/text/StrBuilderAppendInsertTest.java @@ -202,7 +202,7 @@ public class StrBuilderAppendInsertTest { sb.append("abcbardef", 3, 3); assertEquals("foobar", sb.toString()); - sb.append( (CharSequence)"abcbardef", 4, 3); + sb.append((CharSequence) "abcbardef", 4, 3); assertEquals("foobarard", sb.toString()); } diff --git a/src/test/java/org/apache/commons/lang3/text/StrBuilderTest.java b/src/test/java/org/apache/commons/lang3/text/StrBuilderTest.java index 025456df1..548ce5020 100644 --- a/src/test/java/org/apache/commons/lang3/text/StrBuilderTest.java +++ b/src/test/java/org/apache/commons/lang3/text/StrBuilderTest.java @@ -418,11 +418,11 @@ public class StrBuilderTest { assertThrows( IndexOutOfBoundsException.class, () -> sb.setCharAt(0, 'f'), - "setCharAt(0,) expected IndexOutOfBoundsException"); + "setCharAt(0, ) expected IndexOutOfBoundsException"); assertThrows( IndexOutOfBoundsException.class, () -> sb.setCharAt(-1, 'f'), - "setCharAt(-1,) expected IndexOutOfBoundsException"); + "setCharAt(-1, ) expected IndexOutOfBoundsException"); sb.append("foo"); sb.setCharAt(0, 'b'); sb.setCharAt(1, 'a'); @@ -430,7 +430,7 @@ public class StrBuilderTest { assertThrows( IndexOutOfBoundsException.class, () -> sb.setCharAt(3, '!'), - "setCharAt(3,) expected IndexOutOfBoundsException"); + "setCharAt(3, ) expected IndexOutOfBoundsException"); assertEquals("bar", sb.toString()); } @@ -467,19 +467,19 @@ public class StrBuilderTest { sb.append("junit"); char[] a = sb.toCharArray(0, 20); // too large test - assertEquals(5, a.length, "toCharArray(int,int) result incorrect length"); - assertTrue(Arrays.equals("junit".toCharArray(), a), "toCharArray(int,int) result does not match"); + assertEquals(5, a.length, "toCharArray(int, int) result incorrect length"); + assertTrue(Arrays.equals("junit".toCharArray(), a), "toCharArray(int, int) result does not match"); a = sb.toCharArray(0, 4); - assertEquals(4, a.length, "toCharArray(int,int) result incorrect length"); - assertTrue(Arrays.equals("juni".toCharArray(), a), "toCharArray(int,int) result does not match"); + assertEquals(4, a.length, "toCharArray(int, int) result incorrect length"); + assertTrue(Arrays.equals("juni".toCharArray(), a), "toCharArray(int, int) result does not match"); a = sb.toCharArray(0, 4); - assertEquals(4, a.length, "toCharArray(int,int) result incorrect length"); - assertTrue(Arrays.equals("juni".toCharArray(), a), "toCharArray(int,int) result does not match"); + assertEquals(4, a.length, "toCharArray(int, int) result incorrect length"); + assertTrue(Arrays.equals("juni".toCharArray(), a), "toCharArray(int, int) result does not match"); a = sb.toCharArray(0, 1); - assertNotNull(a, "toCharArray(int,int) result is null"); + assertNotNull(a, "toCharArray(int, int) result is null"); assertThrows( IndexOutOfBoundsException.class, () -> sb.toCharArray(-1, 5), "no string index out of bound on -1"); @@ -500,12 +500,12 @@ public class StrBuilderTest { sb.append("junit"); a = sb.getChars(input); assertSame(input, a); - assertTrue(Arrays.equals(new char[] {'j','u','n','i','t',0,0,0,0,0},a)); + assertTrue(Arrays.equals(new char[] {'j', 'u', 'n', 'i', 't', 0, 0, 0, 0, 0}, a)); a = sb.getChars(null); - assertNotSame(input,a); - assertEquals(5,a.length); - assertTrue(Arrays.equals("junit".toCharArray(),a)); + assertNotSame(input, a); + assertEquals(5, a.length); + assertTrue(Arrays.equals("junit".toCharArray(), a)); input = new char[5]; a = sb.getChars(input); @@ -522,17 +522,17 @@ public class StrBuilderTest { sb.append("junit"); char[] a = new char[5]; - sb.getChars(0,5,a,0); - assertTrue(Arrays.equals(new char[] {'j','u','n','i','t'},a)); + sb.getChars(0, 5, a, 0); + assertTrue(Arrays.equals(new char[] {'j', 'u', 'n', 'i', 't'}, a)); final char[] b = new char[5]; - sb.getChars(0,2,b,3); - assertTrue(Arrays.equals(new char[] {0,0,0,'j','u'},b)); + sb.getChars(0, 2, b, 3); + assertTrue(Arrays.equals(new char[] {0, 0, 0, 'j', 'u'}, b)); - assertThrows(IndexOutOfBoundsException.class, () -> sb.getChars(-1,0,b,0)); - assertThrows(IndexOutOfBoundsException.class, () -> sb.getChars(0,-1,b,0)); - assertThrows(IndexOutOfBoundsException.class, () -> sb.getChars(0,20,b,0)); - assertThrows(IndexOutOfBoundsException.class, () -> sb.getChars(4,2,b,0)); + assertThrows(IndexOutOfBoundsException.class, () -> sb.getChars(-1, 0, b, 0)); + assertThrows(IndexOutOfBoundsException.class, () -> sb.getChars(0, -1, b, 0)); + assertThrows(IndexOutOfBoundsException.class, () -> sb.getChars(0, 20, b, 0)); + assertThrows(IndexOutOfBoundsException.class, () -> sb.getChars(4, 2, b, 0)); } //----------------------------------------------------------------------- @@ -1141,7 +1141,7 @@ public class StrBuilderTest { assertEquals ("hello", sb.subSequence(0, 5)); assertEquals ("hello goodbye".subSequence(0, 6), sb.subSequence(0, 6)); assertEquals ("goodbye", sb.subSequence(6, 13)); - assertEquals ("hello goodbye".subSequence(6,13), sb.subSequence(6, 13)); + assertEquals ("hello goodbye".subSequence(6, 13), sb.subSequence(6, 13)); } @Test @@ -1163,7 +1163,7 @@ public class StrBuilderTest { assertEquals ("hello goodbye".substring(0, 6), sb.substring(0, 6)); assertEquals ("goodbye", sb.substring(6, 13)); - assertEquals ("hello goodbye".substring(6,13), sb.substring(6, 13)); + assertEquals ("hello goodbye".substring(6, 13), sb.substring(6, 13)); assertEquals ("goodbye", sb.substring(6, 20)); diff --git a/src/test/java/org/apache/commons/lang3/text/StrSubstitutorTest.java b/src/test/java/org/apache/commons/lang3/text/StrSubstitutorTest.java index ea8c271ea..f2f224dd0 100644 --- a/src/test/java/org/apache/commons/lang3/text/StrSubstitutorTest.java +++ b/src/test/java/org/apache/commons/lang3/text/StrSubstitutorTest.java @@ -580,7 +580,7 @@ public class StrSubstitutorTest { * Test the replace of a properties object */ @Test - public void testSubstituteDefaultProperties(){ + public void testSubstituteDefaultProperties() { final String org = "${doesnotwork}"; System.setProperty("doesnotwork", "It works!"); diff --git a/src/test/java/org/apache/commons/lang3/text/StrTokenizerTest.java b/src/test/java/org/apache/commons/lang3/text/StrTokenizerTest.java index 406555072..8c05c5737 100644 --- a/src/test/java/org/apache/commons/lang3/text/StrTokenizerTest.java +++ b/src/test/java/org/apache/commons/lang3/text/StrTokenizerTest.java @@ -60,7 +60,7 @@ public class StrTokenizerTest { tok.setIgnoreEmptyTokens(false); final String tokens[] = tok.getTokenArray(); - final String expected[] = new String[]{"a", "b", "c", "d;\"e", "f", "", "", "",}; + final String expected[] = new String[]{"a", "b", "c", "d;\"e", "f", "", "", ""}; assertEquals(expected.length, tokens.length, ArrayUtils.toString(tokens)); for (int i = 0; i < expected.length; i++) { @@ -81,7 +81,7 @@ public class StrTokenizerTest { tok.setIgnoreEmptyTokens(false); final String tokens[] = tok.getTokenArray(); - final String expected[] = new String[]{"a", "b", "c ", "d;\"e", "f", " ", " ", "",}; + final String expected[] = new String[]{"a", "b", "c ", "d;\"e", "f", " ", " ", ""}; assertEquals(expected.length, tokens.length, ArrayUtils.toString(tokens)); for (int i = 0; i < expected.length; i++) { @@ -102,7 +102,7 @@ public class StrTokenizerTest { tok.setIgnoreEmptyTokens(false); final String tokens[] = tok.getTokenArray(); - final String expected[] = new String[]{"a", "b", " c", "d;\"e", "f", " ", " ", "",}; + final String expected[] = new String[]{"a", "b", " c", "d;\"e", "f", " ", " ", ""}; assertEquals(expected.length, tokens.length, ArrayUtils.toString(tokens)); for (int i = 0; i < expected.length; i++) { @@ -123,7 +123,7 @@ public class StrTokenizerTest { tok.setIgnoreEmptyTokens(true); final String tokens[] = tok.getTokenArray(); - final String expected[] = new String[]{"a", "b", "c", "d;\"e", "f",}; + final String expected[] = new String[]{"a", "b", "c", "d;\"e", "f"}; assertEquals(expected.length, tokens.length, ArrayUtils.toString(tokens)); for (int i = 0; i < expected.length; i++) { @@ -145,7 +145,7 @@ public class StrTokenizerTest { tok.setEmptyTokenAsNull(true); final String tokens[] = tok.getTokenArray(); - final String expected[] = new String[]{"a", "b", "c", "d;\"e", "f", null, null, null,}; + final String expected[] = new String[]{"a", "b", "c", "d;\"e", "f", null, null, null}; assertEquals(expected.length, tokens.length, ArrayUtils.toString(tokens)); for (int i = 0; i < expected.length; i++) { @@ -167,7 +167,7 @@ public class StrTokenizerTest { // tok.setTreatingEmptyAsNull(true); final String tokens[] = tok.getTokenArray(); - final String expected[] = new String[]{"a", "b", " c", "d;\"e", "f", null, null, null,}; + final String expected[] = new String[]{"a", "b", " c", "d;\"e", "f", null, null, null}; int nextCount = 0; while (tok.hasNext()) { @@ -200,7 +200,7 @@ public class StrTokenizerTest { tok.setIgnoreEmptyTokens(false); final String tokens[] = tok.getTokenArray(); - final String expected[] = new String[]{"a", "", "", "b", "c", "d e", "f", "",}; + final String expected[] = new String[]{"a", "", "", "b", "c", "d e", "f", ""}; assertEquals(expected.length, tokens.length, ArrayUtils.toString(tokens)); for (int i = 0; i < expected.length; i++) { @@ -221,7 +221,7 @@ public class StrTokenizerTest { tok.setIgnoreEmptyTokens(true); final String tokens[] = tok.getTokenArray(); - final String expected[] = new String[]{"a", "b", "c", "d e", "f",}; + final String expected[] = new String[]{"a", "b", "c", "d e", "f"}; assertEquals(expected.length, tokens.length, ArrayUtils.toString(tokens)); for (int i = 0; i < expected.length; i++) { diff --git a/src/test/java/org/apache/commons/lang3/text/WordUtilsTest.java b/src/test/java/org/apache/commons/lang3/text/WordUtilsTest.java index 201ddf354..2037a4703 100644 --- a/src/test/java/org/apache/commons/lang3/text/WordUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/text/WordUtilsTest.java @@ -424,7 +424,7 @@ public class WordUtilsTest { // Prior to fix, this was throwing StringIndexOutOfBoundsException WordUtils.wrap("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa " + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa " - + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",70); + + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 70); } @Test diff --git a/src/test/java/org/apache/commons/lang3/text/translate/EntityArraysTest.java b/src/test/java/org/apache/commons/lang3/text/translate/EntityArraysTest.java index 41610e5f3..8d8376a86 100644 --- a/src/test/java/org/apache/commons/lang3/text/translate/EntityArraysTest.java +++ b/src/test/java/org/apache/commons/lang3/text/translate/EntityArraysTest.java @@ -37,11 +37,11 @@ public class EntityArraysTest { // LANG-659 - check arrays for duplicate entries @Test - public void testHTML40_EXTENDED_ESCAPE(){ + public void testHTML40_EXTENDED_ESCAPE() { final Set col0 = new HashSet<>(); final Set col1 = new HashSet<>(); final String [][] sa = EntityArrays.HTML40_EXTENDED_ESCAPE(); - for(int i =0; i col0 = new HashSet<>(); final Set col1 = new HashSet<>(); final String [][] sa = EntityArrays.ISO8859_1_ESCAPE(); boolean success = true; - for(int i =0; i map= new HashMap<>(); + final Map map= new HashMap<>(); int i= 0; - for(final DateParser parser:parsers) { + for (final DateParser parser:parsers) { map.put(parser, Integer.valueOf(i++)); } i= 0; - for(final DateParser parser:parsers) { + for (final DateParser parser:parsers) { assertEquals(i++, map.get(parser).intValue()); } } @@ -202,7 +202,7 @@ public class FastDateParserTest { // http://docs.oracle.com/javase/6/docs/technotes/guides/intl/calendar.doc.html if (locale.equals(FastDateParser.JAPANESE_IMPERIAL)) { - if(year < 1868) { + if (year < 1868) { cal.set(Calendar.ERA, 0); cal.set(Calendar.YEAR, 1868-year); } @@ -236,10 +236,10 @@ public class FastDateParserTest { @Test // Check that all Locales can parse the formats we use public void testParses() throws Exception { - for(final String format : new String[]{LONG_FORMAT, SHORT_FORMAT}) { - for(final Locale locale : Locale.getAvailableLocales()) { - for(final TimeZone tz : new TimeZone[]{NEW_YORK, REYKJAVIK, GMT}) { - for(final int year : new int[]{2003, 1940, 1868, 1867, 1, -1, -1940}) { + for (final String format : new String[]{LONG_FORMAT, SHORT_FORMAT}) { + for (final Locale locale : Locale.getAvailableLocales()) { + for (final TimeZone tz : new TimeZone[]{NEW_YORK, REYKJAVIK, GMT}) { + for (final int year : new int[]{2003, 1940, 1868, 1867, 1, -1, -1940}) { final Calendar cal= getEraStart(year, tz, locale); final Date centuryStart= cal.getTime(); @@ -260,10 +260,10 @@ public class FastDateParserTest { @Test public void testTzParses() throws Exception { // Check that all Locales can parse the time formats we use - for(final Locale locale : Locale.getAvailableLocales()) { + for (final Locale locale : Locale.getAvailableLocales()) { final FastDateParser fdp= new FastDateParser("yyyy/MM/dd z", TimeZone.getDefault(), locale); - for(final TimeZone tz : new TimeZone[]{NEW_YORK, REYKJAVIK, GMT}) { + for (final TimeZone tz : new TimeZone[]{NEW_YORK, REYKJAVIK, GMT}) { final Calendar cal= Calendar.getInstance(tz, locale); cal.clear(); cal.set(Calendar.YEAR, 2000); @@ -327,7 +327,7 @@ public class FastDateParserTest { cal.set(Calendar.ERA, GregorianCalendar.BC); } - for(final Locale locale : Locale.getAvailableLocales() ) { + for (final Locale locale : Locale.getAvailableLocales() ) { // ja_JP_JP cannot handle dates before 1868 properly if (eraBC && locale.equals(FastDateParser.JAPANESE_IMPERIAL)) { continue; @@ -395,13 +395,13 @@ public class FastDateParserTest { @Test public void testSpecialCharacters() throws Exception { - testSdfAndFdp("q" ,"", true); // bad pattern character (at present) - testSdfAndFdp("Q" ,"", true); // bad pattern character - testSdfAndFdp("$" ,"$", false); // OK - testSdfAndFdp("?.d" ,"?.12", false); // OK + testSdfAndFdp("q" , "", true); // bad pattern character (at present) + testSdfAndFdp("Q" , "", true); // bad pattern character + testSdfAndFdp("$" , "$", false); // OK + testSdfAndFdp("?.d" , "?.12", false); // OK testSdfAndFdp("''yyyyMMdd'A''B'HHmmssSSS''", "'20030210A'B153320989'", false); // OK testSdfAndFdp("''''yyyyMMdd'A''B'HHmmssSSS''", "''20030210A'B153320989'", false); // OK - testSdfAndFdp("'$\\Ed'" ,"$\\Ed", false); // OK + testSdfAndFdp("'$\\Ed'" , "$\\Ed", false); // OK // quoted charaters are case sensitive testSdfAndFdp("'QED'", "QED", false); @@ -413,13 +413,13 @@ public class FastDateParserTest { @Test public void testLANG_832() throws Exception { - testSdfAndFdp("'d'd" ,"d3", false); // OK - testSdfAndFdp("'d'd'","d3", true); // should fail (unterminated quote) + testSdfAndFdp("'d'd" , "d3", false); // OK + testSdfAndFdp("'d'd'", "d3", true); // should fail (unterminated quote) } @Test public void testLANG_831() throws Exception { - testSdfAndFdp("M E","3 Tue", true); + testSdfAndFdp("M E", "3 Tue", true); } private void testSdfAndFdp(final String format, final String date, final boolean shouldFail) @@ -433,7 +433,7 @@ public class FastDateParserTest { final SimpleDateFormat sdf = new SimpleDateFormat(format, Locale.US); sdf.setTimeZone(NEW_YORK); dsdf = sdf.parse(date); - assertFalse(shouldFail, "Expected SDF failure, but got " + dsdf + " for ["+format+","+date+"]"); + assertFalse(shouldFail, "Expected SDF failure, but got " + dsdf + " for ["+format+", "+date+"]"); } catch (final Exception e) { s = e; if (!shouldFail) { @@ -444,7 +444,7 @@ public class FastDateParserTest { try { final DateParser fdp = getInstance(format, NEW_YORK, Locale.US); dfdp = fdp.parse(date); - assertFalse(shouldFail, "Expected FDF failure, but got " + dfdp + " for ["+format+","+date+"]"); + assertFalse(shouldFail, "Expected FDF failure, but got " + dfdp + " for ["+format+", "+date+"]"); } catch (final Exception e) { f = e; if (!shouldFail) {