Refine search
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 boolean equals(@Nullable Object other) { if (this == other) { return true; } if (other == null || other.getClass() != getClass()) { return false; } HttpEntity<?> otherEntity = (HttpEntity<?>) other; return (ObjectUtils.nullSafeEquals(this.headers, otherEntity.headers) && ObjectUtils.nullSafeEquals(this.body, otherEntity.body)); }
@Override public final int hashCode() { return (ObjectUtils.nullSafeHashCode(this.key) ^ ObjectUtils.nullSafeHashCode(this.value)); } }
@Override public Object getValue(@Nullable String name) { Object value = this.delegate.getValue(name); if (ObjectUtils.isArray(value)) { value = StringUtils.arrayToCommaDelimitedString(ObjectUtils.toObjectArray(value)); } return value; } }
private static String getMethodMapping(Method method) { Assert.notNull(method, "'method' must not be null"); RequestMapping requestMapping = AnnotatedElementUtils.findMergedAnnotation(method, RequestMapping.class); if (requestMapping == null) { throw new IllegalArgumentException("No @RequestMapping on: " + method.toGenericString()); } String[] paths = requestMapping.path(); if (ObjectUtils.isEmpty(paths) || StringUtils.isEmpty(paths[0])) { return "/"; } if (paths.length > 1 && logger.isTraceEnabled()) { logger.trace("Using first of multiple paths on " + method.toGenericString()); } return paths[0]; }
protected String[] getTargetDestinations(@Nullable Annotation annotation, Message<?> message, String defaultPrefix) { if (annotation != null) { String[] value = (String[]) AnnotationUtils.getValue(annotation); if (!ObjectUtils.isEmpty(value)) { return value; } } String name = DestinationPatternsMessageCondition.LOOKUP_DESTINATION_HEADER; String destination = (String) message.getHeaders().get(name); if (!StringUtils.hasText(destination)) { throw new IllegalStateException("No lookup destination header in " + message); } return (destination.startsWith("/") ? new String[] {defaultPrefix + destination} : new String[] {defaultPrefix + '/' + destination}); }
/** * Set the accept-version header. Must be one of "1.1", "1.2", or both. * Applies to the CONNECT frame. * @since 5.0.7 */ public void setAcceptVersion(@Nullable String... acceptVersions) { if (ObjectUtils.isEmpty(acceptVersions)) { set(ACCEPT_VERSION, null); return; } Arrays.stream(acceptVersions).forEach(version -> Assert.isTrue(version != null && (version.equals("1.1") || version.equals("1.2")), "Invalid version: " + version)); set(ACCEPT_VERSION, StringUtils.arrayToCommaDelimitedString(acceptVersions)); }
/** * Convert the supplied {@link ManagedNotification} into the corresponding * {@link javax.management.modelmbean.ModelMBeanNotificationInfo}. */ public static ModelMBeanNotificationInfo convertToModelMBeanNotificationInfo(ManagedNotification notificationInfo) { String[] notifTypes = notificationInfo.getNotificationTypes(); if (ObjectUtils.isEmpty(notifTypes)) { throw new IllegalArgumentException("Must specify at least one notification type"); } String name = notificationInfo.getName(); if (!StringUtils.hasText(name)) { throw new IllegalArgumentException("Must specify notification name"); } String description = notificationInfo.getDescription(); return new ModelMBeanNotificationInfo(notifTypes, name, description); }
private Object[] appendArguments(@Nullable Object[] sourceArguments, Object[] additionalArguments) { if (ObjectUtils.isEmpty(sourceArguments)) { return additionalArguments; } Object[] arguments = new Object[sourceArguments.length + additionalArguments.length]; System.arraycopy(sourceArguments, 0, arguments, 0, sourceArguments.length); System.arraycopy(additionalArguments, 0, arguments, sourceArguments.length, additionalArguments.length); return arguments; }
/** * Add the specified basenames to the existing basename configuration. * <p>Note: If a given basename already exists, the position of its entry * will remain as in the original set. New entries will be added at the * end of the list, to be searched after existing basenames. * @since 4.3 * @see #setBasenames * @see java.util.ResourceBundle */ public void addBasenames(String... basenames) { if (!ObjectUtils.isEmpty(basenames)) { for (String basename : basenames) { Assert.hasText(basename, "Basename must not be empty"); this.basenameSet.add(basename.trim()); } } }
private void assertNumberOfConditions(CompositeRequestCondition other) { Assert.isTrue(getLength() == other.getLength(), "Cannot combine CompositeRequestConditions with a different number of conditions. " + ObjectUtils.nullSafeToString(this.requestConditions) + " and " + ObjectUtils.nullSafeToString(other.requestConditions)); }
/** * Determine whether the given {@code @InitBinder} method should be used * to initialize the given {@link WebDataBinder} instance. By default we * check the specified attribute names in the annotation value, if any. */ protected boolean isBinderMethodApplicable(HandlerMethod initBinderMethod, WebDataBinder dataBinder) { InitBinder ann = initBinderMethod.getMethodAnnotation(InitBinder.class); Assert.state(ann != null, "No InitBinder annotation"); String[] names = ann.value(); return (ObjectUtils.isEmpty(names) || ObjectUtils.containsElement(names, dataBinder.getObjectName())); }
@Override @Nullable public String[] getHeaderValues(String headerName) { String[] headerValues = StringUtils.toStringArray(getRequest().getHeaders(headerName)); return (!ObjectUtils.isEmpty(headerValues) ? headerValues : null); }
@Override public void processPropertyAccessException(PropertyAccessException ex, BindingResult bindingResult) { // Create field error with the exceptions's code, e.g. "typeMismatch". String field = ex.getPropertyName(); Assert.state(field != null, "No field in exception"); String[] codes = bindingResult.resolveMessageCodes(ex.getErrorCode(), field); Object[] arguments = getArgumentsForBindError(bindingResult.getObjectName(), field); Object rejectedValue = ex.getValue(); if (ObjectUtils.isArray(rejectedValue)) { rejectedValue = StringUtils.arrayToCommaDelimitedString(ObjectUtils.toObjectArray(rejectedValue)); } FieldError error = new FieldError(bindingResult.getObjectName(), field, rejectedValue, true, codes, arguments, ex.getLocalizedMessage()); error.wrap(ex); bindingResult.addError(error); }
/** * Assert that an array contains elements; that is, it must not be * {@code null} and must contain at least one element. * <pre class="code"> * Assert.notEmpty(array, () -> "The " + arrayType + " array must contain elements"); * </pre> * @param array the array to check * @param messageSupplier a supplier for the exception message to use if the * assertion fails * @throws IllegalArgumentException if the object array is {@code null} or contains no elements * @since 5.0 */ public static void notEmpty(@Nullable Object[] array, Supplier<String> messageSupplier) { if (ObjectUtils.isEmpty(array)) { throw new IllegalArgumentException(nullSafeGet(messageSupplier)); } }
public JettyWebSocketSession(Session session, HandshakeInfo info, DataBufferFactory factory, @Nullable MonoProcessor<Void> completionMono) { super(session, ObjectUtils.getIdentityHexString(session), info, factory, completionMono); // TODO: suspend causes failures if invoked at this stage // suspendReceiving(); }
@Override public NettyDataBuffer write(ByteBuffer... buffers) { if (!ObjectUtils.isEmpty(buffers)) { for (ByteBuffer buffer : buffers) { this.byteBuf.writeBytes(buffer); } } return this; }
/** * Merge the given array into the given Collection. * @param array the array to merge (may be {@code null}) * @param collection the target Collection to merge the array into */ @SuppressWarnings("unchecked") public static <E> void mergeArrayIntoCollection(@Nullable Object array, Collection<E> collection) { Object[] arr = ObjectUtils.toObjectArray(array); for (Object elem : arr) { collection.add((E) elem); } }
/** * Remove duplicate strings from the given array. * <p>As of 4.2, it preserves the original order, as it uses a {@link LinkedHashSet}. * @param array the {@code String} array (potentially empty) * @return an array without duplicates, in natural sort order */ public static String[] removeDuplicateStrings(String[] array) { if (ObjectUtils.isEmpty(array)) { return array; } Set<String> set = new LinkedHashSet<>(Arrays.asList(array)); return toStringArray(set); }