public AbstractServerHttpResponse(DataBufferFactory dataBufferFactory, HttpHeaders headers) { Assert.notNull(dataBufferFactory, "DataBufferFactory must not be null"); Assert.notNull(headers, "HttpHeaders must not be null"); this.dataBufferFactory = dataBufferFactory; this.headers = headers; this.cookies = new LinkedMultiValueMap<>(); }
/** * A convenient, alternative constructor to use with a custom path separator. * @param pathSeparator the path separator to use, must not be {@code null}. * @since 4.1 */ public AntPathMatcher(String pathSeparator) { Assert.notNull(pathSeparator, "'pathSeparator' is required"); this.pathSeparator = pathSeparator; this.pathSeparatorPatternCache = new PathSeparatorPatternCache(pathSeparator); }
public SpelNodeImpl(int startPos, int endPos, SpelNodeImpl... operands) { this.startPos = startPos; this.endPos = endPos; if (!ObjectUtils.isEmpty(operands)) { this.children = operands; for (SpelNodeImpl operand : operands) { Assert.notNull(operand, "Operand must not be null"); operand.parent = this; } } }
@Override public void addTransformer(ClassFileTransformer transformer) { Assert.notNull(transformer, "Transformer must not be null"); ReflectionUtils.invokeMethod(this.addTransformerMethod, this.classLoader, transformer); }
/** * Replaces all placeholders of format {@code ${name}} with the corresponding * property from the supplied {@link Properties}. * @param value the value containing the placeholders to be replaced * @param properties the {@code Properties} to use for replacement * @return the supplied value with placeholders replaced inline */ public String replacePlaceholders(String value, final Properties properties) { Assert.notNull(properties, "'properties' must not be null"); return replacePlaceholders(value, properties::getProperty); }
/** * Return a variant of the given {@link OutputStream} where calling * {@link OutputStream#close() close()} has no effect. * @param out the OutputStream to decorate * @return a version of the OutputStream that ignores calls to close */ public static OutputStream nonClosing(OutputStream out) { Assert.notNull(out, "No OutputStream specified"); return new NonClosingOutputStream(out); }
/** * Return a variant of the given {@link InputStream} where calling * {@link InputStream#close() close()} has no effect. * @param in the InputStream to decorate * @return a version of the InputStream that ignores calls to close */ public static InputStream nonClosing(InputStream in) { Assert.notNull(in, "No InputStream specified"); return new NonClosingInputStream(in); }
/** * Provide a request parameter identifying the request for this FlashMap. * @param name the expected parameter name (skipped if empty) * @param value the expected value (skipped if empty) */ public FlashMap addTargetRequestParam(String name, String value) { if (StringUtils.hasText(name) && StringUtils.hasText(value)) { this.targetRequestParams.add(name, value); } return this; }
/** * Get the native Hibernate FlushMode, adapting between Hibernate 5.0/5.1 and 5.2+. * @param session the Hibernate Session to get the flush mode from * @return the FlushMode (never {@code null}) * @since 4.3 */ static FlushMode getFlushMode(Session session) { FlushMode flushMode = (FlushMode) ReflectionUtils.invokeMethod(getFlushMode, session); Assert.state(flushMode != null, "No FlushMode from Session"); return flushMode; }
/** * Set multiple JAXB context paths. The given array of context paths gets * converted to a colon-delimited string, as supported by JAXB. */ public void setContextPaths(String... contextPaths) { Assert.notEmpty(contextPaths, "'contextPaths' must not be empty"); this.contextPath = StringUtils.arrayToDelimitedString(contextPaths, ":"); }
@Override protected Boolean execute(@Nullable Reference<K, V> ref, @Nullable Entry<K, V> entry) { if (entry != null && ObjectUtils.nullSafeEquals(entry.getValue(), value)) { if (ref != null) { ref.release(); } return true; } return false; } });
/** * Construct a new, empty instance of the {@code HttpHeaders} object. */ public HttpHeaders() { this(CollectionUtils.toMultiValueMap(new LinkedCaseInsensitiveMap<>(8, Locale.ENGLISH))); }
private void findAvailableUdpPorts(int numRequested, int minPort, int maxPort) { SortedSet<Integer> ports = SocketUtils.findAvailableUdpPorts(numRequested, minPort, maxPort); assertAvailablePorts(ports, numRequested, minPort, maxPort); } private void assertPortInRange(int port, int minPort, int maxPort) {
public AbstractClientHttpRequest(HttpHeaders headers) { Assert.notNull(headers, "HttpHeaders must not be null"); this.headers = headers; this.cookies = new LinkedMultiValueMap<>(); }
/** * Invoke JUnit's private {@code withRules()} method using reflection. */ private Statement withRulesReflectively(FrameworkMethod frameworkMethod, Object testInstance, Statement statement) { Object result = ReflectionUtils.invokeMethod(withRulesMethod, this, frameworkMethod, testInstance, statement); Assert.state(result instanceof Statement, "withRules mismatch"); return (Statement) result; }
private void findAvailableUdpPorts(int numRequested) { SortedSet<Integer> ports = SocketUtils.findAvailableUdpPorts(numRequested); assertAvailablePorts(ports, numRequested, PORT_RANGE_MIN, PORT_RANGE_MAX); }