public static void containsNoNulls(Iterable<?> collection, String message) { for (Object object : collection) { notNull(object, message); } }
public static void containsNoNulls(Iterable<?> collection, String message) { for (Object object : collection) { notNull(object, message); } }
public static void containsNoNulls(Object[] array, String message) { for (Object object : array) { notNull(object, message); } }
public static void containsNoNulls(Object[] array, String message) { for (Object object : array) { notNull(object, message); } }
public static void notBlank(StringBuilder object, String message) { Validate.notNull(object, message); if (object.length() == 0) { throw new IllegalArgumentException(message); } }
public static void notBlank(StringBuilder object, String message) { Validate.notNull(object, message); if (object.length() == 0) { throw new IllegalArgumentException(message); } }
/** * <p> * Loads all available providers for the passed SPI (Service Provider * Interface) and returns them as an {@link ArrayList}. * * @param spi * The service provider interface used to load existing * implementations. * @return a list of providers. */ public static <S> List<S> getProvidersAsList(Class<S> spi) { Validate.notNull(spi, "The SPI (Service Provider Interface) must be specified"); ServiceLoader<S> services = ServiceLoader.load(spi); List<S> retval = new ArrayList<S>(); for (S service : services) { retval.add(service); } return retval; }
/** * <p> * Loads all available providers for the passed SPI (Service Provider * Interface) and returns them as an {@link ArrayList}. * * @param spi * The service provider interface used to load existing * implementations. * @return a list of providers. */ public static <S> List<S> getProvidersAsList(Class<S> spi) { Validate.notNull(spi, "The SPI (Service Provider Interface) must be specified"); ServiceLoader<S> services = ServiceLoader.load(spi); List<S> retval = new ArrayList<S>(); for (S service : services) { retval.add(service); } return retval; }
/** * <p> * First convert the supplied {@link Properties} into a {@link Map} and then * call {@link #substitute(String, Map)}. * </p> * * @param source * the string containing possible variable references * @param variablesAndValues * the {@link Map} to use to resolve the variables' values. * @return The updated source {@link String}. * @throws IllegalArgumentException * <ul> * <li>if the source {@link String} is null</li> * <li>if the {@link Map} of variables is null</li> * <li> * or if the source {@link String} references a variable which * doesn't exist in the variable {@link Map}.</li> * </ul> */ public static String substitute(String source, Properties variablesAndValues) { Validate.notNull(source, "The source cannot be null"); Validate.notNull(variablesAndValues, "The Properties cannot be null"); Map<String, String> map = new HashMap<String, String>(); for (String key : variablesAndValues.stringPropertyNames()) { map.put(key, variablesAndValues.getProperty(key)); } return substitute(source, map); }
/** * <p> * First convert the supplied {@link Properties} into a {@link Map} and then * call {@link #substitute(String, Map)}. * </p> * * @param source * the string containing possible variable references * @param variablesAndValues * the {@link Map} to use to resolve the variables' values. * @return The updated source {@link String}. * @throws IllegalArgumentException * <ul> * <li>if the source {@link String} is null</li> * <li>if the {@link Map} of variables is null</li> * <li> * or if the source {@link String} references a variable which * doesn't exist in the variable {@link Map}.</li> * </ul> */ public static String substitute(String source, Properties variablesAndValues) { Validate.notNull(source, "The source cannot be null"); Validate.notNull(variablesAndValues, "The Properties cannot be null"); Map<String, String> map = new HashMap<String, String>(); for (String key : variablesAndValues.stringPropertyNames()) { map.put(key, variablesAndValues.getProperty(key)); } return substitute(source, map); }
/** * <p> * Generates a MD5 hash using information of the provided {@link Asset}. * </p> * <p> * The set of information used to generate the hash depends on the location * key. * </p> * <ul> * <li>{@code webapp}, {@code jar}, {@code webjar}, {@code classpath} and * {@code remote}: bundle name + asset name + asset type</li> * <li>{@code api}: bundle name + asset name + asset type + current URI</li> * </ul> * * @param asset * The asset holding information used to generate the hash. * @return a MD5 hash. */ public static String generateStorageKey(Asset asset, HttpServletRequest request) { Validate.notNull(asset.getConfigLocationKey(), "The location key of the provided asset cannot be null"); StringBuilder keyContext = new StringBuilder(); keyContext.append(asset.getBundle()); keyContext.append(asset.getName()); keyContext.append(asset.getType().name()); if (asset.getConfigLocationKey().equalsIgnoreCase(ApiLocator.LOCATION_KEY)) { keyContext.append(UrlUtils.getCurrentUri(request)); } return DigestUtils.md5Digest(keyContext.toString()); }
/** * <p> * Generates a MD5 hash using information of the provided {@link Asset}. * </p> * <p> * The set of information used to generate the hash depends on the location * key. * </p> * <ul> * <li>{@code webapp}, {@code jar}, {@code webjar}, {@code classpath} and * {@code remote}: bundle name + asset name + asset type</li> * <li>{@code api}: bundle name + asset name + asset type + current URI</li> * </ul> * * @param asset * The asset holding information used to generate the hash. * @return a MD5 hash. */ public static String generateStorageKey(Asset asset, HttpServletRequest request) { Validate.notNull(asset.getConfigLocationKey(), "The location key of the provided asset cannot be null"); StringBuilder keyContext = new StringBuilder(); keyContext.append(asset.getBundle()); keyContext.append(asset.getName()); keyContext.append(asset.getType().name()); if (asset.getConfigLocationKey().equalsIgnoreCase(ApiLocator.LOCATION_KEY)) { keyContext.append(UrlUtils.getCurrentUri(request)); } return DigestUtils.md5Digest(keyContext.toString()); }
Validate.notNull(request, "The HTTP request cannot be null");
Validate.notNull(request, "The HTTP request cannot be null");