/** * Throw an IllegalArgumentException if the argument is invalid. * * @param test true if the argument is valid * @param message the message * @param arguments the arguments * @throws IllegalArgumentException if the argument is invalid */ public static void checkArgument(boolean test, String message, Object... arguments) { if (!test) { throw newIllegalArgumentException(message, arguments); } }
/** * Serialize the object to a byte array. * * @param obj the object to serialize * @return the byte array */ private static byte[] serialize(Object obj) { try { ByteArrayOutputStream out = new ByteArrayOutputStream(); ObjectOutputStream os = new ObjectOutputStream(out); os.writeObject(obj); return out.toByteArray(); } catch (Throwable e) { throw DataUtils.newIllegalArgumentException("Could not serialize {0}", obj, e); } }
/** * De-serialize the byte array to an object. * * @param data the byte array * @return the object */ private static Object deserialize(byte[] data) { try { ByteArrayInputStream in = new ByteArrayInputStream(data); ObjectInputStream is = new ObjectInputStream(in); return is.readObject(); } catch (Throwable e) { throw DataUtils.newIllegalArgumentException("Could not deserialize {0}", Arrays.toString(data), e); } }
public <K, V> StorageMap<K, V> openMap(String name, String mapType, StorageDataType keyType, StorageDataType valueType, Map<String, String> parameters) { if (mapType == null || mapType.equalsIgnoreCase("AOMap")) { return openAOMap(name, keyType, valueType, parameters); } else if (mapType.equalsIgnoreCase("BTreeMap")) { return openBTreeMap(name, keyType, valueType, parameters); } else if (mapType.equalsIgnoreCase("BufferedMap")) { return openBufferedMap(name, keyType, valueType, parameters); } else { throw DataUtils.newIllegalArgumentException("Unknow map type: {0}", mapType); } }
break; default: throw DataUtils.newIllegalArgumentException("Unsupported id {0}", Arrays.toString(id));
throw DataUtils.newIllegalArgumentException("Unsupported id {0}", Arrays.toString(idBuffer.array()));
throw DataUtils.newIllegalArgumentException("Unsupported id {0}", Arrays.toString(id));
break; default: throw DataUtils.newIllegalArgumentException("Unsupported id {0}", Arrays.toString(id));
FilePath parent = f.getParent(); if (parent != null && !parent.exists()) { throw DataUtils.newIllegalArgumentException("Directory does not exist: {0}", parent);
throw DataUtils.newIllegalArgumentException("The value may not be null");