List of usage examples for org.springframework.util Assert notNull
public static void notNull(@Nullable Object object, Supplier<String> messageSupplier)
From source file:org.codehaus.groovy.grails.plugins.searchable.compass.mapping.CompassMappingUtils.java
/** * Get the Compass alias for the given Class * * @param clazz the class/* w w w.j a v a2 s. c o m*/ * @return the Compass alias */ public static String getDefaultAlias(Class clazz) { Assert.notNull(clazz, "clazz cannot be null"); String alias = clazz.getName(); if (alias.indexOf(".") != -1) { alias = alias.substring(alias.lastIndexOf(".") + 1, alias.length()); } return "ALIAS" + alias + "ALIAS"; }
From source file:com.trenako.web.infrastructure.SearchRequestUrlParser.java
/** * Parses the {@code path} string, matching the {@code SearchCriteria} property names. * <p>//from w w w .j a va 2s.co m * This method is able to manage paths with wrong sequences, in this case * the values outside the correct sequence are simply ignored. * </p> * * @param path the {@code path} string * @return a {@code Map} with the extracted values */ public static Map<String, String> parseUrl(String path) { Assert.notNull(path, "Path must be not null"); Map<String, String> values = new HashMap<>(); Stack<String> stack = new Stack<>(); String[] tokens = path.split("/"); for (String tk : tokens) { if (SEARCH_CRITERIA_KEYS.contains(tk)) { if (!stack.isEmpty()) { // a different key name was found, but no value was provided // (ie /key1/key2/value2) stack.pop(); } stack.push(tk); } else { if (!stack.isEmpty()) { // match this value with the key name in the stack values.put(stack.pop(), tk); } } } return values; }
From source file:com.frank.search.solr.core.query.GeoDistanceFunction.java
/** * Creates new {@link GeoDistanceFunction.Builder} * //from w ww . j a v a 2 s . co m * @param field must not be null * @return */ public static Builder distanceFrom(Field field) { Assert.notNull(field, "Field cannot be 'null' for geodistance function."); return distanceFrom(field.getName()); }
From source file:Main.java
public static final void writeXml(Transformer transformer, OutputStream outputEntry, Document document) { Assert.notNull(transformer, "Transformer required"); Assert.notNull(outputEntry, "Output entry required"); Assert.notNull(document, "Document required"); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); try {// w ww . j a v a2 s .c o m transformer.transform(new DOMSource(document), createUnixStreamResultForEntry(outputEntry)); } catch (Exception ex) { throw new IllegalStateException(ex); } }
From source file:org.hdiv.web.util.TagUtils.java
/** * Determine whether the supplied {@link Tag} has any ancestor tag of the * supplied type.//from ww w. j a v a 2s . c om * * @param tag the tag whose ancestors are to be checked * @param ancestorTagClass the ancestor {@link Class} being searched for * @return <code>true</code> if the supplied {@link Tag} has any ancestor * tag of the supplied type * @throws IllegalArgumentException if either of the supplied arguments is * <code>null</code>; or if the supplied * <code>ancestorTagClass</code> is not type-assignable to the * {@link Tag} class */ public static Tag getAncestorOfType(Tag tag, Class ancestorTagClass) { Assert.notNull(tag, "Tag cannot be null"); Assert.notNull(ancestorTagClass, "Ancestor tag class cannot be null"); if (!Tag.class.isAssignableFrom(ancestorTagClass)) { throw new IllegalArgumentException( "Class '" + ancestorTagClass.getName() + "' is not a valid Tag type"); } Tag ancestor = tag.getParent(); while (ancestor != null) { if (ancestorTagClass.isAssignableFrom(ancestor.getClass())) { return ancestor; } ancestor = ancestor.getParent(); } return null; }
From source file:Main.java
public static final void writeMalformedXml(Transformer transformer, OutputStream outputEntry, NodeList nodes) { Assert.notNull(transformer, "Transformer required"); Assert.notNull(outputEntry, "Output entry required"); Assert.notNull(nodes, "NodeList required"); transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); try {/* w w w .j av a 2 s . c o m*/ for (int i = 0; i < nodes.getLength(); i++) { transformer.transform(new DOMSource(nodes.item(i)), createUnixStreamResultForEntry(outputEntry)); } } catch (Exception ex) { throw new IllegalStateException(ex); } }
From source file:demo.support.NavUtils.java
/** * Returns distance (in meters) between 2 points. * * @param point1 Must not be null/*from w w w. jav a 2s. c om*/ * @param point2 Must not be null * @return distance in meters */ public static double getDistance(Point point1, Point point2) { Assert.notNull(point1, "point1 must not be null"); Assert.notNull(point2, "point2 must not be null"); final SpatialContext ctx = SpatialContext.GEO; com.spatial4j.core.shape.Point p1 = ctx.makePoint(point1.getLongitude(), point1.getLatitude()); com.spatial4j.core.shape.Point p2 = ctx.makePoint(point2.getLongitude(), point2.getLatitude()); return DistanceUtils.degrees2Dist(ctx.getDistCalc().distance(p1, p2), DistanceUtils.EARTH_MEAN_RADIUS_KM) * 1000; }
From source file:com.frank.search.solr.core.query.QueryFunction.java
/** * @param criteria/* www. ja va2 s .com*/ * @return */ public static QueryFunction query(Criteria criteria) { Assert.notNull(criteria, "Cannot create query function for 'null' criteria."); return query(new SimpleQuery(criteria)); }
From source file:com.frank.search.solr.core.query.IfFunction.java
public static Builder when(Function function) { Assert.notNull(function, "Function cannot be 'null' for if clause."); return new Builder(function); }
From source file:org.springmodules.validation.bean.context.ValidationContextHolder.java
/** * Sets the ${ValidationContext} to be held by this holder. * * @param context/*from w w w . j ava 2 s.c o m*/ */ public static void setValidationContext(ValidationContext context) { Assert.notNull(context, "Cannot set a null validation context. To clear this holder please call clearContext() instead"); contextHolder.set(context); }