List of usage examples for java.lang IllegalArgumentException IllegalArgumentException
public IllegalArgumentException()
IllegalArgumentException
with no detail message. From source file:Main.java
public static boolean containsDuplicates(Collection<?> coll) { if (coll == null) throw new IllegalArgumentException(); Set<Object> set = new HashSet<>(coll); return set.size() != coll.size(); }
From source file:Main.java
public static ShortBuffer makeShortBuffer(short[] array) { if (array == null) throw new IllegalArgumentException(); ByteBuffer byteBuffer = ByteBuffer.allocateDirect(2 * array.length); byteBuffer.order(ByteOrder.nativeOrder()); ShortBuffer shortBuffer = byteBuffer.asShortBuffer(); shortBuffer.put(array);//from w w w . j ava2 s. co m shortBuffer.position(0); return shortBuffer; }
From source file:Main.java
static public boolean containsCaseInsensitive(Collection<String> items, final String queryItem) throws IllegalArgumentException { if (items == null || queryItem == null) { throw new IllegalArgumentException(); }//from w ww .ja v a 2s. co m for (String item : items) { if (queryItem.equalsIgnoreCase(item)) { return true; } } return false; }
From source file:Main.java
private static int hex2Dec(char hexChar) { if (hexChar >= '0' && hexChar <= '9') { return hexChar - '0'; } else if (hexChar >= 'A' && hexChar <= 'F') { return hexChar - 'A' + 10; } else {/* www . j a va2 s. c o m*/ throw new IllegalArgumentException(); } }
From source file:com.bstek.dorado.idesupport.StandaloneRuleSetExporter.java
public static void main(String[] args) throws Exception { String ruleSetFile = null;//w w w . ja v a 2s. c o m String doradoHome = null; if (args.length >= 2) { ruleSetFile = args[0]; doradoHome = args[1]; } else { throw new IllegalArgumentException(); } if (StringUtils.isEmpty(doradoHome)) { doradoHome = System.getenv("DORADO_HOME"); } StandaloneRuleSetExporter instance = new StandaloneRuleSetExporter(doradoHome); FileOutputStream fos = new FileOutputStream(ruleSetFile); PrintWriter writer = new PrintWriter(new OutputStreamWriter(fos, Constants.DEFAULT_CHARSET)); try { instance.exportRuleSet(writer); } finally { writer.flush(); writer.close(); fos.close(); } }
From source file:Main.java
/** * Rounds a double via passed in amount and places * @param value// w w w . ja v a 2 s. c o m * @param places * @return */ public static double round(double value, int places) { if (places < 0) throw new IllegalArgumentException(); BigDecimal bd = new BigDecimal(value); bd = bd.setScale(places, RoundingMode.HALF_UP); return bd.doubleValue(); }
From source file:Main.java
/** * Rounds a double up via passed in amount and places * @param value// ww w . j a v a 2 s . co m * @param places * @return */ public static double roundUp(double value, int places) { if (places < 0) throw new IllegalArgumentException(); BigDecimal bd = new BigDecimal(value); bd = bd.setScale(places, RoundingMode.CEILING); return bd.doubleValue(); }
From source file:Main.java
/** * Rounds a double down via passed in amount and places * @param value// w w w. jav a2s. c om * @param places * @return */ public static double roundDown(double value, int places) { if (places < 0) throw new IllegalArgumentException(); BigDecimal bd = new BigDecimal(value); bd = bd.setScale(places, RoundingMode.FLOOR); return bd.doubleValue(); }
From source file:Main.java
public static double dot(double[] v1, float[] v2) { if (v1.length != v2.length) { throw new IllegalArgumentException(); }//from ww w . ja v a 2s.com double dot = 0.0; for (int i = 0; i < v1.length; i++) { dot += v1[i] * v2[i]; } return dot; }
From source file:Main.java
/** * Creates temporary file in external storage, or in case when extrnal storage is not available * temporary file is created in the internal storage. * @param context - Context//from w w w . j a v a2s .c o m * @return instance of java.io.File or null if error occured. */ public static File createTempFile(Context context) { if (context == null) throw new IllegalArgumentException(); File saveToDir = context.getExternalCacheDir(); if (saveToDir == null) { saveToDir = context.getCacheDir(); } File tempFile = null; try { tempFile = File.createTempFile("parrot", "", saveToDir); } catch (IOException e) { e.printStackTrace(); return null; } return tempFile; }