buildcraft/api/buildcraft/api/core/JavaTools.java
2017-11-10 19:30:36 +01:00

44 lines
1.3 KiB
Java
Executable file

/**
* Copyright (c) 2011-2017, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* The BuildCraft API is distributed under the terms of the MIT License.
* Please check the contents of the license, which should be located
* as "LICENSE.API" in the BuildCraft source code distribution.
*/
package buildcraft.api.core;
import java.util.Arrays;
public final class JavaTools {
private JavaTools(){
}
public static <T> T[] concat(T[] first, T[] second) {
T[] result = Arrays.copyOf(first, first.length + second.length);
System.arraycopy(second, 0, result, first.length, second.length);
return result;
}
public static int[] concat(int[] first, int[] second) {
int[] result = Arrays.copyOf(first, first.length + second.length);
System.arraycopy(second, 0, result, first.length, second.length);
return result;
}
public static float[] concat(float[] first, float[] second) {
float[] result = Arrays.copyOf(first, first.length + second.length);
System.arraycopy(second, 0, result, first.length, second.length);
return result;
}
public static String surroundWithQuotes(String stringToSurroundWithQuotes) {
return String.format("\"%s\"", stringToSurroundWithQuotes);
}
public static String stripSurroundingQuotes(String stringToStripQuotes) {
return stringToStripQuotes.replaceAll("^\"|\"$", "");
}
}