Java Code Examples for org.springframework.util.Assert#noNullElements()

The following examples show how to use org.springframework.util.Assert#noNullElements() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SolrRealtimeGetRequest.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public SolrRealtimeGetRequest(Collection<? extends Serializable> ids) {
	super(METHOD.GET, "/get");

	Assert.notEmpty(ids, "At least one 'id' is required for real time get request.");
	Assert.noNullElements(ids.toArray(), "Real time get request can't be made for 'null' id.");

	toStringIds(ids);
}
 
Example 2
Source File: Isbn.java    From Spring-Boot-2.0-Cookbook-Second-Edition with MIT License 5 votes vote down vote up
public static Isbn parseFrom(String isbn) {
    Assert.notNull(isbn);
    String[] parts = isbn.split("-");
    Assert.state(parts.length == 5);
    Assert.noNullElements(parts);
    return new Isbn(parts[0], parts[1], parts[2], parts[3], parts[4]);
}
 
Example 3
Source File: Policy.java    From spring-vault with Apache License 2.0 5 votes vote down vote up
/**
 * Create a {@link Policy} from one or more {@code rules}.
 * @param rules must not be {@literal null}.
 * @return the {@link Policy} object containing {@code rules}.
 */
public static Policy of(Rule... rules) {

	Assert.notNull(rules, "Rules must not be null");
	Assert.noNullElements(rules, "Rules must not contain null elements");

	return new Policy(new LinkedHashSet<>(Arrays.asList(rules)));
}
 
Example 4
Source File: Isbn.java    From Spring-Boot-2.0-Cookbook-Second-Edition with MIT License 5 votes vote down vote up
public static Isbn parseFrom(String isbn) {
    Assert.notNull(isbn);
    String[] parts = isbn.split("-");
    Assert.state(parts.length == 5);
    Assert.noNullElements(parts);
    return new Isbn(parts[0], parts[1], parts[2], parts[3], parts[4]);
}
 
Example 5
Source File: AbstractRefreshableConfigApplicationContext.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Set the config locations for this application context.
 * <p>If not set, the implementation may use a default as appropriate.
 */
public void setConfigLocations(String... locations) {
	if (locations != null) {
		Assert.noNullElements(locations, "Config locations must not be null");
		this.configLocations = new String[locations.length];
		for (int i = 0; i < locations.length; i++) {
			this.configLocations[i] = resolvePath(locations[i]).trim();
		}
	}
	else {
		this.configLocations = null;
	}
}
 
Example 6
Source File: AbstractRefreshableConfigApplicationContext.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * Set the config locations for this application context.
 * <p>If not set, the implementation may use a default as appropriate.
 */
public void setConfigLocations(String... locations) {
	if (locations != null) {
		Assert.noNullElements(locations, "Config locations must not be null");
		this.configLocations = new String[locations.length];
		for (int i = 0; i < locations.length; i++) {
			this.configLocations[i] = resolvePath(locations[i]).trim();
		}
	}
	else {
		this.configLocations = null;
	}
}
 
Example 7
Source File: PubSubHeaderMapper.java    From spring-cloud-gcp with Apache License 2.0 5 votes vote down vote up
/**
 * Set the patterns of the headers to be mapped in {@link #toHeaders(Map)}.
 * First patterns take precedence.
 * @param inboundHeaderPatterns header patterns to be mapped
 */
public void setInboundHeaderPatterns(String... inboundHeaderPatterns) {
	Assert.notNull(inboundHeaderPatterns, "Header patterns can't be null.");
	Assert.noNullElements(inboundHeaderPatterns, "No header pattern can be null.");
	this.inboundHeaderPatterns =
			Arrays.copyOf(inboundHeaderPatterns, inboundHeaderPatterns.length);
}
 
Example 8
Source File: SearchFilter.java    From spring-boot with Apache License 2.0 5 votes vote down vote up
/**
 * 构造一个 between and 查询条件
 * CriteriaBuilder between  包含两个边界 : betweenFrom <= object <= betweenTo
 *
 * @param fieldName
 * @param operator
 * @param betweenFrom
 * @param betweenTo
 */
public SearchFilter(String fieldName, Operator operator, Object betweenFrom, Object betweenTo) {

    Assert.isTrue(operator.equals(Operator.BETWEEN), "between 操作,operator 必须为 Operator.BETWEEN");
    Assert.hasText(fieldName, "fieldName 没有填写");
    Assert.noNullElements(new Object[]{betweenFrom, betweenTo}, "between 操作,betweenFrom , betweenTo 均不能为 null");

    this.fieldName = fieldName;
    this.betweenFrom = betweenFrom;
    this.betweenTo = betweenTo;
    this.operator = operator;

}
 
Example 9
Source File: FacetOptions.java    From dubbox with Apache License 2.0 5 votes vote down vote up
/**
 * Creates new instance faceting on given fields
 * 
 * @param fieldnames
 */
public FacetOptions(Field... fields) {
	Assert.notNull(fields, "Fields must not be null.");
	Assert.noNullElements(fields, "Cannot facet on null field.");

	for (Field field : fields) {
		addFacetOnField(field);
	}
}
 
Example 10
Source File: VaultVersionedKeyValueTemplate.java    From spring-vault with Apache License 2.0 5 votes vote down vote up
@Override
public void delete(String path, Version... versionsToDelete) {

	Assert.hasText(path, "Path must not be empty");
	Assert.noNullElements(versionsToDelete, "Versions must not be null");

	if (versionsToDelete.length == 0) {
		delete(path);
		return;
	}

	List<Integer> versions = toVersionList(versionsToDelete);

	doWrite(createBackendPath("delete", path), Collections.singletonMap("versions", versions));
}
 
Example 11
Source File: MockMvc.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * Private constructor, not for direct instantiation.
 * @see org.springframework.test.web.servlet.setup.MockMvcBuilders
 */
MockMvc(TestDispatcherServlet servlet, Filter... filters) {
	Assert.notNull(servlet, "DispatcherServlet is required");
	Assert.notNull(filters, "Filters cannot be null");
	Assert.noNullElements(filters, "Filters cannot contain null values");

	this.servlet = servlet;
	this.filters = filters;
	this.servletContext = servlet.getServletContext();
}
 
Example 12
Source File: AbstractRefreshableConfigApplicationContext.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * Set the config locations for this application context.
 * <p>If not set, the implementation may use a default as appropriate.
 */
public void setConfigLocations(@Nullable String... locations) {
	if (locations != null) {
		Assert.noNullElements(locations, "Config locations must not be null");
		// 注释 1.2 将配置资源路径放入 configLocations 数组中
		this.configLocations = new String[locations.length];
		for (int i = 0; i < locations.length; i++) {
			this.configLocations[i] = resolvePath(locations[i]).trim();
		}
	}
	else {
		this.configLocations = null;
	}
}
 
Example 13
Source File: DynamicResourceDatabasePopulator.java    From multitenant with Apache License 2.0 4 votes vote down vote up
private void assertContentsOfScriptArray(Resource... scripts) {
	Assert.notNull(scripts, "Scripts array must not be null");
	Assert.noNullElements(scripts, "Scripts array must not contain null elements");
}
 
Example 14
Source File: ProbeEndpointsStrategy.java    From Moss with Apache License 2.0 4 votes vote down vote up
public ProbeEndpointsStrategy(InstanceWebClient instanceWebClient, String[] endpoints) {
    Assert.notNull(endpoints, "'endpoints' must not be null.");
    Assert.noNullElements(endpoints, "'endpoints' must not contain null.");
    this.endpoints = Arrays.stream(endpoints).map(EndpointDefinition::create).collect(Collectors.toList());
    this.instanceWebClient = instanceWebClient;
}
 
Example 15
Source File: MockFilterChain.java    From spring4-understanding with Apache License 2.0 2 votes vote down vote up
/**
 * Create a {@code FilterChain} with Filter's and a Servlet.
 *
 * @param servlet the {@link Servlet} to invoke in this {@link FilterChain}
 * @param filters the {@link Filter}'s to invoke in this {@link FilterChain}
 * @since 3.2
 */
public MockFilterChain(Servlet servlet, Filter... filters) {
	Assert.notNull(filters, "filters cannot be null");
	Assert.noNullElements(filters, "filters cannot contain null values");
	this.filters = initFilterList(servlet, filters);
}
 
Example 16
Source File: MockFilterChain.java    From java-technology-stack with MIT License 2 votes vote down vote up
/**
 * Create a {@code FilterChain} with Filter's and a Servlet.
 * @param servlet the {@link Servlet} to invoke in this {@link FilterChain}
 * @param filters the {@link Filter}'s to invoke in this {@link FilterChain}
 * @since 3.2
 */
public MockFilterChain(Servlet servlet, Filter... filters) {
	Assert.notNull(filters, "filters cannot be null");
	Assert.noNullElements(filters, "filters cannot contain null values");
	this.filters = initFilterList(servlet, filters);
}
 
Example 17
Source File: MockFilterChain.java    From java-technology-stack with MIT License 2 votes vote down vote up
/**
 * Create a {@code FilterChain} with Filter's and a Servlet.
 * @param servlet the {@link Servlet} to invoke in this {@link FilterChain}
 * @param filters the {@link Filter}'s to invoke in this {@link FilterChain}
 * @since 3.2
 */
public MockFilterChain(Servlet servlet, Filter... filters) {
	Assert.notNull(filters, "filters cannot be null");
	Assert.noNullElements(filters, "filters cannot contain null values");
	this.filters = initFilterList(servlet, filters);
}
 
Example 18
Source File: MockFilterChain.java    From spring4-understanding with Apache License 2.0 2 votes vote down vote up
/**
 * Create a {@code FilterChain} with Filter's and a Servlet.
 *
 * @param servlet the {@link Servlet} to invoke in this {@link FilterChain}
 * @param filters the {@link Filter}'s to invoke in this {@link FilterChain}
 * @since 3.2
 */
public MockFilterChain(Servlet servlet, Filter... filters) {
	Assert.notNull(filters, "filters cannot be null");
	Assert.noNullElements(filters, "filters cannot contain null values");
	this.filters = initFilterList(servlet, filters);
}
 
Example 19
Source File: MockFilterChain.java    From spring-analysis-note with MIT License 2 votes vote down vote up
/**
 * Create a {@code FilterChain} with Filter's and a Servlet.
 * @param servlet the {@link Servlet} to invoke in this {@link FilterChain}
 * @param filters the {@link Filter}'s to invoke in this {@link FilterChain}
 * @since 3.2
 */
public MockFilterChain(Servlet servlet, Filter... filters) {
	Assert.notNull(filters, "filters cannot be null");
	Assert.noNullElements(filters, "filters cannot contain null values");
	this.filters = initFilterList(servlet, filters);
}
 
Example 20
Source File: MockFilterChain.java    From spring-analysis-note with MIT License 2 votes vote down vote up
/**
 * Create a {@code FilterChain} with Filter's and a Servlet.
 * @param servlet the {@link Servlet} to invoke in this {@link FilterChain}
 * @param filters the {@link Filter}'s to invoke in this {@link FilterChain}
 * @since 3.2
 */
public MockFilterChain(Servlet servlet, Filter... filters) {
	Assert.notNull(filters, "filters cannot be null");
	Assert.noNullElements(filters, "filters cannot contain null values");
	this.filters = initFilterList(servlet, filters);
}