List of usage examples for org.springframework.util Assert notNull
public static void notNull(@Nullable Object object, Supplier<String> messageSupplier)
From source file:springfox.documentation.swagger2.web.ForwardedHeader.java
/** * Creates a new {@link ForwardedHeader} from the given source. * * @param source can be {@literal null}. * @return//w w w . j a v a 2 s . c om */ public static ForwardedHeader of(String source) { if (!StringUtils.hasText(source)) { return NO_HEADER; } Map<String, String> elements = new HashMap<String, String>(); for (String part : source.split(";")) { String[] keyValue = part.split("="); if (keyValue.length != 2) { continue; } elements.put(keyValue[0].trim(), keyValue[1].trim()); } Assert.notNull(elements, "Forwarded elements must not be null!"); Assert.isTrue(!elements.isEmpty(), "At least one forwarded element needs to be present!"); return new ForwardedHeader(elements); }
From source file:fr.mby.utils.common.prefs.StreamPreferencesFactory.java
/** * //from www .j ava 2 s . c om */ public StreamPreferencesFactory(final InputStream inputStream, final OutputStream outputStream) { super(); Assert.notNull(inputStream, "No InputStream provided !"); Assert.notNull(outputStream, "No OutputStream provided !"); this.instance = new StreamPreferences(inputStream, outputStream); }
From source file:demo.geocoders.MapquestGeocoder.java
public MapquestGeocoder(@Value("${mapquest.key}") String key, RestTemplate restTemplate) { this.restTemplate = restTemplate; this.key = key; Assert.notNull(this.restTemplate, "the restTemplate must not be null!"); Assert.notNull(this.key, "the license key must not be null!"); }
From source file:curly.commons.security.negotiation.ResourceOperationsResolverAdapter.java
@Override public void onSave(T entity, U user) { Assert.notNull(entity, "Entity must be not null!"); Assert.notNull(user, "User must be not null"); if (isNewOwner(entity.getOwner())) { entity.setOwner(user.getId().toString()); } else if (!isOwnedBy(entity, user)) { throw new OperationViolationException("Cannot match owner id with user's"); }//from w ww . ja v a 2 s . c o m }
From source file:gov.nih.nci.cabig.ctms.acegi.grid.authentication.GridAuthenticationProvider.java
protected void doAfterPropertiesSet() { Assert.notNull(this.authenticationClient, "A GridBasicAuthenticationClient is required."); Assert.notNull(this.userDetailsService, "A UserDetailsService is required."); Assert.notNull(this.validator, "A GridProxyValidator is required."); }
From source file:com.weibo.wesync.notify.xml.DomUtils.java
/** * Retrieve all child elements of the given DOM element that match any of the given element names. Only look at the * direct child level of the given element; do not go into further depth (in contrast to the DOM API's * <code>getElementsByTagName</code> method). * * @param ele the DOM element to analyze * @param childEleNames the child element names to look for * @return a List of child <code>org.w3c.dom.Element</code> instances * @see org.w3c.dom.Element/*w w w .j a va2s. c o m*/ * @see org.w3c.dom.Element#getElementsByTagName */ public static List<Element> getChildElementsByTagName(Element ele, String[] childEleNames) { Assert.notNull(ele, "Element must not be null"); Assert.notNull(childEleNames, "Element names collection must not be null"); List<String> childEleNameList = Arrays.asList(childEleNames); NodeList nl = ele.getChildNodes(); List<Element> childEles = new ArrayList<Element>(); for (int i = 0; i < nl.getLength(); i++) { Node node = nl.item(i); if (node instanceof Element && nodeNameMatch(node, childEleNameList)) { childEles.add((Element) node); } } return childEles; }
From source file:org.geowebcache.georss.PollDef.java
public PollDef(final TileLayer layer, final GeoRSSFeedDefinition pollDef) { Assert.notNull(layer, "layer is null"); Assert.notNull(pollDef, "GeoRSSFeedDefinition is null"); this.layer = layer; this.pollDef = pollDef; }
From source file:cn.wanghaomiao.seimi.utils.StructValidator.java
public static boolean validateAllowRules(String[] rules, String target) { if (ArrayUtils.isEmpty(rules)) { return true; }/*from www .j a v a 2 s .c o m*/ Assert.notNull(target, "rule target can not be null"); for (String rule : rules) { if (target.matches(rule)) { return true; } } return false; }
From source file:org.hdiv.config.annotation.ParamExclusionRegistration.java
public void forUrls(String urlPattern) { Assert.notNull(urlPattern, "A URL path is required"); this.urlPattern = urlPattern; }
From source file:com.ewcms.publication.task.MemoryTaskQueue.java
@Override public void register(Taskable task) { Assert.notNull(task, "task is null"); try {//from www .j av a 2 s . c o m if (!hasTask(task)) { saveNewTask(task); tasks.put(task); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); } }