Uses of Annotation Interface
org.springframework.lang.Contract
Packages that use Contract
Package
Description
Support for AOP-based scoping of target objects, with configurable backend.
Convenience classes for using Spring's AOP API.
Support package for annotation-driven bean configuration.
Core support package for annotations, meta-annotations, and merged
annotations with attribute overrides.
Type conversion system API.
SpEL's central implementation package.
General utility classes for use in unit and integration tests.
Miscellaneous utility classes, such as utilities for working with strings,
classes, collections, reflection, etc.
Useful generic
java.util.function
helper classes.-
Uses of Contract in org.springframework.aop.scope
Methods in org.springframework.aop.scope with annotations of type ContractModifier and TypeMethodDescriptionstatic boolean
ScopedProxyUtils.isScopedTarget
(@Nullable String beanName) Determine if thebeanName
is the name of a bean that references the target bean within a scoped proxy. -
Uses of Contract in org.springframework.aop.support
Methods in org.springframework.aop.support with annotations of type ContractModifier and TypeMethodDescriptionstatic boolean
AopUtils.isAopProxy
(@Nullable Object object) Check whether the given object is a JDK dynamic proxy or a CGLIB proxy.static boolean
AopUtils.isCglibProxy
(@Nullable Object object) Check whether the given object is a CGLIB proxy.static boolean
AopUtils.isJdkDynamicProxy
(@Nullable Object object) Check whether the given object is a JDK dynamic proxy. -
Uses of Contract in org.springframework.beans.factory.annotation
Methods in org.springframework.beans.factory.annotation with annotations of type ContractModifier and TypeMethodDescriptionstatic boolean
InjectionMetadata.needsRefresh
(@Nullable InjectionMetadata metadata, Class<?> clazz) Check whether the given injection metadata needs to be refreshed. -
Uses of Contract in org.springframework.core.annotation
Methods in org.springframework.core.annotation with annotations of type Contract -
Uses of Contract in org.springframework.core.convert
Methods in org.springframework.core.convert with annotations of type ContractModifier and TypeMethodDescriptionstatic @Nullable TypeDescriptor
TypeDescriptor.array
(@Nullable TypeDescriptor elementTypeDescriptor) Create a new type descriptor as an array of the specified type.static @Nullable TypeDescriptor
Create a new type descriptor for an object. -
Uses of Contract in org.springframework.expression.spel
Methods in org.springframework.expression.spel with annotations of type ContractModifier and TypeMethodDescriptionstatic boolean
CodeFlow.isBooleanCompatible
(@Nullable String descriptor) Determine whether the descriptor is for a boolean primitive or boolean reference type.static boolean
CodeFlow.isPrimitive
(@Nullable String descriptor) Determine whether the descriptor is for a primitive type orvoid
.static boolean
CodeFlow.isPrimitiveArray
(@Nullable String descriptor) Determine whether the descriptor is for a primitive array (for example, "[[I").static boolean
CodeFlow.isPrimitiveOrUnboxableSupportedNumber
(@Nullable String descriptor) Determine if the supplied descriptor is for a supported number.static boolean
CodeFlow.isPrimitiveOrUnboxableSupportedNumberOrBoolean
(@Nullable String descriptor) Determine if the supplied descriptor is for a supported number type or boolean. -
Uses of Contract in org.springframework.test.util
Methods in org.springframework.test.util with annotations of type ContractModifier and TypeMethodDescriptionstatic void
AssertionErrors.assertFalse
(String message, boolean condition) Assert the given condition isfalse
and raise anAssertionError
otherwise.static void
AssertionErrors.assertNotNull
(String message, @Nullable Object object) Assert that the given object is notnull
and raise anAssertionError
otherwise.static void
AssertionErrors.assertNull
(String message, @Nullable Object object) Assert that the given object isnull
and raise anAssertionError
otherwise.static void
AssertionErrors.assertTrue
(String message, boolean condition) Assert the given condition istrue
and raise anAssertionError
otherwise.static void
Fail a test with the given message. -
Uses of Contract in org.springframework.util
Methods in org.springframework.util with annotations of type ContractModifier and TypeMethodDescriptionStringUtils.concatenateStringArrays
(String @Nullable [] array1, String @Nullable [] array2) Concatenate the givenString
arrays into one, with overlapping array elements included twice.static boolean
CollectionUtils.contains
(@Nullable Enumeration<? extends @Nullable Object> enumeration, @Nullable Object element) Check whether the givenEnumeration
contains the given element.static boolean
CollectionUtils.contains
(@Nullable Iterator<? extends @Nullable Object> iterator, @Nullable Object element) Check whether the givenIterator
contains the given element.static boolean
Check whether the given array contains the given element.static boolean
CollectionUtils.containsInstance
(@Nullable Collection<? extends @Nullable Object> collection, @Nullable Object element) Check whether the givenCollection
contains the given element instance.static boolean
StringUtils.containsWhitespace
(@Nullable CharSequence str) Check whether the givenCharSequence
contains any whitespace characters.static boolean
StringUtils.containsWhitespace
(@Nullable String str) Check whether the givenString
contains any whitespace characters.static boolean
FileSystemUtils.deleteRecursively
(@Nullable File root) Delete the suppliedFile
- for directories, recursively delete any nested directories or files as well.static boolean
FileSystemUtils.deleteRecursively
(@Nullable Path root) Delete the suppliedPath
— for directories, recursively delete any nested directories or files as well.SerializationUtils.deserialize
(byte @Nullable [] bytes) Deprecated.This utility uses Java Object Serialization, which allows arbitrary code to be run and is known for being the source of many Remote Code Execution (RCE) vulnerabilities.ClassUtils.determineCommonAncestor
(@Nullable Class<?> clazz1, @Nullable Class<?> clazz2) Determine the common ancestor of the given classes, if any.static boolean
StringUtils.endsWithIgnoreCase
(@Nullable String str, @Nullable String suffix) Test if the givenString
ends with the specified suffix, ignoring upper/lower case.static <T> @Nullable T
CollectionUtils.findValueOfType
(@Nullable Collection<?> collection, @Nullable Class<T> type) Find a single value of the given type in the given Collection.static <T> @Nullable T
CollectionUtils.firstElement
(@Nullable List<T> list) Retrieve the first element of the given List, accessing the zero index.static <T> @Nullable T
CollectionUtils.firstElement
(@Nullable Set<T> set) Retrieve the first element of the given Set, usingSortedSet.first()
or otherwise using the iterator.ClassUtils.getDescriptiveType
(@Nullable Object value) Return a descriptive name for the given object's type: usually simply the class name, but component type class name + "[]" for arrays, and an appended list of implemented interfaces for JDK proxies.StringUtils.getFilename
(@Nullable String path) Extract the filename from the given Java resource path.StringUtils.getFilenameExtension
(@Nullable String path) Extract the filename extension from the given Java resource path.static void
Assert that the given String is not empty; that is, it must not benull
and not the empty String.static void
Assert that the given String is not empty; that is, it must not benull
and not the empty String.static boolean
StringUtils.hasLength
(@Nullable CharSequence str) Check that the givenCharSequence
is neithernull
nor of length 0.static boolean
Check that the givenString
is neithernull
nor of length 0.static void
Assert that the given String contains valid text content; that is, it must not benull
and must contain at least one non-whitespace character.static void
Assert that the given String contains valid text content; that is, it must not benull
and must contain at least one non-whitespace character.static boolean
StringUtils.hasText
(@Nullable CharSequence str) Check whether the givenCharSequence
contains actual text.static boolean
Check whether the givenString
contains actual text.static boolean
Determine whether the given object is an array: either an Object array or a primitive array.static void
Assert.isAssignable
(Class<?> superType, @Nullable Class<?> subType) Assert thatsuperType.isAssignableFrom(subType)
istrue
.static void
Assert.isAssignable
(Class<?> superType, @Nullable Class<?> subType, String message) Assert thatsuperType.isAssignableFrom(subType)
istrue
.static void
Assert.isAssignable
(Class<?> superType, @Nullable Class<?> subType, Supplier<String> messageSupplier) Assert thatsuperType.isAssignableFrom(subType)
istrue
.static boolean
TypeUtils.isAssignableBound
(@Nullable Type lhsType, @Nullable Type rhsType) static boolean
ClassUtils.isCglibProxyClass
(@Nullable Class<?> clazz) Deprecated.in favor of custom (possibly narrower) checks or simply a check for containingClassUtils.CGLIB_CLASS_SEPARATOR
static boolean
ClassUtils.isCglibProxyClassName
(@Nullable String className) Deprecated.in favor of custom (possibly narrower) checks or simply a check for containingClassUtils.CGLIB_CLASS_SEPARATOR
static boolean
CollectionUtils.isEmpty
(@Nullable Collection<? extends @Nullable Object> collection) Returntrue
if the supplied Collection isnull
or empty.static boolean
Returntrue
if the supplied Map isnull
or empty.static boolean
Determine whether the given object is empty.static boolean
Determine whether the given array is empty: i.e.static boolean
Deprecated.in favor ofStringUtils.hasLength(String)
andStringUtils.hasText(String)
(orObjectUtils.isEmpty(Object)
)static boolean
ReflectionUtils.isEqualsMethod
(@Nullable Method method) Determine whether the given method is an "equals" method.static boolean
ReflectionUtils.isHashCodeMethod
(@Nullable Method method) Determine whether the given method is a "hashCode" method.static void
Assert.isInstanceOf
(Class<?> type, @Nullable Object obj) Assert that the provided object is an instance of the provided class.static void
Assert.isInstanceOf
(Class<?> type, @Nullable Object obj, String message) Assert that the provided object is an instance of the provided class.static void
Assert that the provided object is an instance of the provided class.static void
Assert that an object isnull
.static void
Assert that an object isnull
.static boolean
ReflectionUtils.isObjectMethod
(@Nullable Method method) Determine whether the given method is originally declared byObject
.static boolean
ReflectionUtils.isToStringMethod
(@Nullable Method method) Determine whether the given method is a "toString" method.static void
Assert a boolean expression, throwing anIllegalArgumentException
if the expression evaluates tofalse
.static void
Assert a boolean expression, throwing anIllegalArgumentException
if the expression evaluates tofalse
.static boolean
Return whether the given resource location is a URL: either a special "classpath" pseudo URL or a standard URL.static boolean
ClassUtils.isVisible
(Class<?> clazz, @Nullable ClassLoader classLoader) Check whether the given class is visible in the given ClassLoader.static boolean
ClassUtils.isVoidType
(@Nullable Class<?> type) Determine if the given type represents eitherVoid
orvoid
.static <T> @Nullable T
CollectionUtils.lastElement
(@Nullable List<T> list) Retrieve the last element of the given List, accessing the highest index.static <T> @Nullable T
CollectionUtils.lastElement
(@Nullable Set<T> set) Retrieve the last element of the given Set, usingSortedSet.last()
or otherwise iterating over all elements (assuming a linked set).static boolean
StringUtils.matchesCharacter
(@Nullable String str, char singleCharacter) Test if the givenString
matches the given single character.static boolean
ClassUtils.matchesTypeName
(Class<?> clazz, @Nullable String typeName) Check whether the given class matches the user-specified type name.static void
Assert that an array contains elements; that is, it must not benull
and must contain at least one element.static void
Assert that an array contains elements; that is, it must not benull
and must contain at least one element.static void
Assert.notEmpty
(@Nullable Collection<?> collection, String message) Assert that a collection contains elements; that is, it must not benull
and must contain at least one element.static void
Assert.notEmpty
(@Nullable Collection<?> collection, Supplier<String> messageSupplier) Assert that a collection contains elements; that is, it must not benull
and must contain at least one element.static void
Assert that a Map contains entries; that is, it must not benull
and must contain at least one entry.static void
Assert that a Map contains entries; that is, it must not benull
and must contain at least one entry.static void
Assert that an object is notnull
.static void
Assert that an object is notnull
.static boolean
ObjectUtils.nullSafeEquals
(@Nullable Object o1, @Nullable Object o2) Determine if the given objects are equal, returningtrue
if both arenull
orfalse
if only one isnull
.static @Nullable ClassLoader
ClassUtils.overrideThreadContextClassLoader
(@Nullable ClassLoader classLoaderToUse) Override the thread context ClassLoader with the environment's bean ClassLoader if necessary, i.e.Quote the givenString
with single quotes.StringUtils.quoteIfString
(@Nullable Object obj) Turn the given Object into aString
with single quotes if it is aString
; keeping the Object as-is else.ClassUtils.resolvePrimitiveClassName
(@Nullable String name) Resolve the given class name as primitive class, if appropriate, according to the JVM's naming rules for primitive classes.static void
ReflectionUtils.rethrowException
(@Nullable Throwable throwable) Rethrow the givenexception
, which is presumably the target exception of anInvocationTargetException
.static void
ReflectionUtils.rethrowRuntimeException
(@Nullable Throwable ex) Rethrow the givenexception
, which is presumably the target exception of anInvocationTargetException
.static byte @Nullable []
Serialize the given object to a byte array.static boolean
PatternMatchUtils.simpleMatch
(@Nullable String pattern, @Nullable String str) Match a String against the given pattern, supporting direct equality as well as the following simple pattern styles:xxx*
,*xxx
,*xxx*
, andxxx*yyy
(with an arbitrary number of pattern parts).static boolean
PatternMatchUtils.simpleMatch
(String @Nullable [] patterns, @Nullable String str) Match a String against the given patterns, supporting direct equality as well as the following simple pattern styles:xxx*
,*xxx
,*xxx*
, andxxx*yyy
(with an arbitrary number of pattern parts).static boolean
PatternMatchUtils.simpleMatchIgnoreCase
(@Nullable String pattern, @Nullable String str) Variant ofPatternMatchUtils.simpleMatch(String, String)
that ignores upper/lower case.static boolean
PatternMatchUtils.simpleMatchIgnoreCase
(String @Nullable [] patterns, @Nullable String str) Variant ofPatternMatchUtils.simpleMatch(String[], String)
that ignores upper/lower case.Split aString
at the first occurrence of the delimiter.static @Nullable Properties
StringUtils.splitArrayElementsIntoProperties
(String @Nullable [] array, String delimiter, @Nullable String charsToDelete) Take an array of strings and split each element based on the given delimiter.static boolean
StringUtils.startsWithIgnoreCase
(@Nullable String str, @Nullable String prefix) Test if the givenString
starts with the specified prefix, ignoring upper/lower case.static void
Assert a boolean expression, throwing anIllegalStateException
if the expression evaluates tofalse
.static void
Assert a boolean expression, throwing anIllegalStateException
if the expression evaluates tofalse
.ObjectUtils.unwrapOptional
(@Nullable Object obj) Unwrap the given object which is potentially aOptional
. -
Uses of Contract in org.springframework.util.function
Methods in org.springframework.util.function with annotations of type ContractModifier and TypeMethodDescriptionstatic <T> @Nullable SingletonSupplier
<T> SingletonSupplier.ofNullable
(@Nullable T instance) Build aSingletonSupplier
with the given singleton instance.static <T> @Nullable SingletonSupplier
<T> SingletonSupplier.ofNullable
(@Nullable Supplier<@Nullable T> supplier) Build aSingletonSupplier
with the given supplier.Resolve a givenSupplier
, getting its result or immediately returning the given Object as-is if not aSupplier
.static <T> @Nullable T
Resolve the givenSupplier
, getting its result or immediately returningnull
if the supplier itself wasnull
.