Skip to content

Commit e857710

Browse files
committed
Use private static method instead of class
1 parent a0b1ed7 commit e857710

File tree

1 file changed

+29
-31
lines changed

1 file changed

+29
-31
lines changed

lib/src/main/java/com/github/kevinsawicki/http/HttpRequest.java

Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ private static StringBuilder addParam(final Object key, final Object valueObj,
338338
final StringBuilder result) {
339339
Object value = valueObj;
340340
if (value != null && value.getClass().isArray())
341-
value = ArrayUtils.arrayToList(value);
341+
value = arrayToList(value);
342342
if (value instanceof Iterable<?>) {
343343
Iterator<?> iterator = ((Iterable<?>) value).iterator();
344344
while (true) {
@@ -828,36 +828,34 @@ public RequestOutputStream write(final String value) throws IOException {
828828
}
829829
}
830830

831-
private static class ArrayUtils {
832-
833-
/**
834-
* Represents array of any type as list of objects so we can easily iterate over it
835-
* @param array of elements
836-
* @return list with the same elements
837-
*/
838-
public static List<Object> arrayToList(Object array) {
839-
List<Object> result = new ArrayList<Object>();
840-
if (array instanceof Object[])
841-
result = Arrays.asList((Object[]) array);
842-
// Arrays of the primitive types can't be cast to array of Object, so this:
843-
else if (array instanceof int[])
844-
for (int value : (int[]) array) result.add(value);
845-
else if (array instanceof boolean[])
846-
for (boolean value : (boolean[]) array) result.add(value);
847-
else if (array instanceof long[])
848-
for (long value : (long[]) array) result.add(value);
849-
else if (array instanceof float[])
850-
for (float value : (float[]) array) result.add(value);
851-
else if (array instanceof double[])
852-
for (double value : (double[]) array) result.add(value);
853-
else if (array instanceof short[])
854-
for (short value : (short[]) array) result.add(value);
855-
else if (array instanceof byte[])
856-
for (byte value : (byte[]) array) result.add(value);
857-
else if (array instanceof char[])
858-
for (char value : (char[]) array) result.add(value);
859-
return result;
860-
}
831+
/**
832+
* Represents array of any type as list of objects so we can easily iterate over it
833+
* @param array of elements
834+
* @return list with the same elements
835+
*/
836+
private static List<Object> arrayToList(final Object array) {
837+
if (array instanceof Object[])
838+
return Arrays.asList((Object[]) array);
839+
840+
List<Object> result = new ArrayList<Object>();
841+
// Arrays of the primitive types can't be cast to array of Object, so this:
842+
if (array instanceof int[])
843+
for (int value : (int[]) array) result.add(value);
844+
else if (array instanceof boolean[])
845+
for (boolean value : (boolean[]) array) result.add(value);
846+
else if (array instanceof long[])
847+
for (long value : (long[]) array) result.add(value);
848+
else if (array instanceof float[])
849+
for (float value : (float[]) array) result.add(value);
850+
else if (array instanceof double[])
851+
for (double value : (double[]) array) result.add(value);
852+
else if (array instanceof short[])
853+
for (short value : (short[]) array) result.add(value);
854+
else if (array instanceof byte[])
855+
for (byte value : (byte[]) array) result.add(value);
856+
else if (array instanceof char[])
857+
for (char value : (char[]) array) result.add(value);
858+
return result;
861859
}
862860

863861
/**

0 commit comments

Comments
 (0)