Class QuerydslBindings
java.lang.Object
org.springframework.data.querydsl.binding.QuerydslBindings
QuerydslBindings
allows definition of path specific bindings.
new QuerydslBindings() {
{
bind(QUser.user.address.city).first((path, value) -> path.like(value.toString()));
bind(String.class).first((path, value) -> path.like(value.toString()));
}
}
The bindings can either handle a single - see QuerydslBindings.PathBinder.first(SingleValueBinding)
- (the first in case
multiple ones are supplied) or multiple - see QuerydslBindings.PathBinder.all(MultiValueBinding)
- value binding. If exactly
one path is deployed, an QuerydslBindings.AliasingPathBinder
is returned which - as the name suggests - allows aliasing of
paths, i.e. exposing the path under a different name.
QuerydslBindings
are usually manipulated using a QuerydslBinderCustomizer
, either implemented
directly or using a default method on a Spring Data repository.
- Since:
- 1.11
- Author:
- Christoph Strobl, Oliver Gierke, Mark Paluch, Johannes Englmeier
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionclass
QuerydslBindings.AliasingPathBinder<P extends com.querydsl.core.types.Path<? extends T>,
T> A specialQuerydslBindings.PathBinder
that additionally registers the binding under a dedicated alias.class
QuerydslBindings.PathBinder<P extends com.querydsl.core.types.Path<? extends T>,
T> A binder forPath
s.final class
A binder for types. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal <T> QuerydslBindings.TypeBinder<T>
Returns a newQuerydslBindings.TypeBinder
for the given type.final <T extends com.querydsl.core.types.Path<S>,
S>
QuerydslBindings.AliasingPathBinder<T,S> bind
(T path) Returns anQuerydslBindings.AliasingPathBinder
for the givenPath
to define bindings for them.final <T extends com.querydsl.core.types.Path<S>,
S>
QuerydslBindings.PathBinder<T,S> bind
(T... paths) Returns a newQuerydslBindings.PathBinder
for the givenPath
s to define bindings for them.final QuerydslBindings
excludeUnlistedProperties
(boolean excludeUnlistedProperties) Returns whether to exclude all properties for which no explicit binding has been defined or it has been explicitly allowed.final void
excluding
(com.querydsl.core.types.Path<?>... paths) Exclude properties from binding.<S extends com.querydsl.core.types.Path<? extends T>,
T>
Optional<MultiValueBinding<S,T>> Returns theSingleValueBinding
for the givenPropertyPath
.final void
including
(com.querydsl.core.types.Path<?>... paths) Include properties for binding.
-
Constructor Details
-
QuerydslBindings
public QuerydslBindings()Creates a newQuerydslBindings
instance.
-
-
Method Details
-
bind
public final <T extends com.querydsl.core.types.Path<S>,S> QuerydslBindings.AliasingPathBinder<T,S> bind(T path) Returns anQuerydslBindings.AliasingPathBinder
for the givenPath
to define bindings for them.- Parameters:
path
- must not be null.- Returns:
-
bind
@SafeVarargs public final <T extends com.querydsl.core.types.Path<S>,S> QuerydslBindings.PathBinder<T,S> bind(T... paths) Returns a newQuerydslBindings.PathBinder
for the givenPath
s to define bindings for them.- Parameters:
paths
- must not be null or empty.- Returns:
-
bind
Returns a newQuerydslBindings.TypeBinder
for the given type.- Parameters:
type
- must not be null.- Returns:
-
excluding
public final void excluding(com.querydsl.core.types.Path<?>... paths) Exclude properties from binding. Exclusion of all properties of a nested type can be done by exclusion on a higher level. E.g.address
would exclude bothaddress.city
andaddress.street
.- Parameters:
paths
- must not be null or empty.
-
including
public final void including(com.querydsl.core.types.Path<?>... paths) Include properties for binding. Include the property considered a binding candidate.- Parameters:
paths
- must not be null or empty.
-
excludeUnlistedProperties
Returns whether to exclude all properties for which no explicit binding has been defined or it has been explicitly allowed. This defaults to false which means that for properties without an explicitly defined binding a type specific default binding will be applied.- Parameters:
excludeUnlistedProperties
-- Returns:
- See Also:
-
getBindingForPath
public <S extends com.querydsl.core.types.Path<? extends T>,T> Optional<MultiValueBinding<S,T>> getBindingForPath(org.springframework.data.querydsl.binding.PathInformation path) Returns theSingleValueBinding
for the givenPropertyPath
. Prefers a path configured for the specific path but falls back to the builder registered for a given type.- Parameters:
path
- must not be null.- Returns:
- can be null.
-