zaber.motion.ArrayUtility Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of motion-library Show documentation
Show all versions of motion-library Show documentation
A library that aims to provide easy-to-use API for communication with Zaber devices using Zaber ASCII Protocol.
package zaber.motion;
public final class ArrayUtility {
private ArrayUtility() {
}
public static boolean[] toPrimitiveArray(Boolean[] array) {
if (array == null) {
return null;
} else if (array.length == 0) {
return new boolean[0];
}
boolean[] result = new boolean[array.length];
for (int i = 0; i < array.length; i++) {
result[i] = array[i];
}
return result;
}
public static double[] toPrimitiveArray(Double[] array) {
if (array == null) {
return null;
} else if (array.length == 0) {
return new double[0];
}
double[] result = new double[array.length];
for (int i = 0; i < array.length; i++) {
result[i] = array[i];
}
return result;
}
public static int[] toPrimitiveArray(Integer[] array) {
if (array == null) {
return null;
} else if (array.length == 0) {
return new int[0];
}
int[] result = new int[array.length];
for (int i = 0; i < array.length; i++) {
result[i] = array[i];
}
return result;
}
public static Boolean[] toObjectArray(boolean[] array) {
if (array == null) {
return null;
} else if (array.length == 0) {
return new Boolean[0];
}
Boolean[] result = new Boolean[array.length];
for (int i = 0; i < array.length; i++) {
result[i] = array[i];
}
return result;
}
public static Integer[] toObjectArray(int[] array) {
if (array == null) {
return null;
} else if (array.length == 0) {
return new Integer[0];
}
Integer[] result = new Integer[array.length];
for (int i = 0; i < array.length; i++) {
result[i] = array[i];
}
return result;
}
public static Double[] toObjectArray(double[] array) {
if (array == null) {
return null;
} else if (array.length == 0) {
return new Double[0];
}
Double[] result = new Double[array.length];
for (int i = 0; i < array.length; i++) {
result[i] = array[i];
}
return result;
}
}