Class PropertyQuery<V>
java.lang.Object
org.keycloak.models.utils.reflection.PropertyQuery<V>
Queries a target class for properties that match certain criteria. A property may either be a private or public field, declared by the target class or inherited from a superclass, or a public method declared by the target class or inherited from any of its superclasses. For properties that are exposed via a method, the property must be a JavaBean style property, i.e. it must provide both an accessor and mutator method according to the JavaBean specification.
This class is not thread-safe, however the result returned by the getResultList() method is.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionaddCriteria
(PropertyCriteria criteria) Add a criteria to queryGet the first result from the query, causing the query to be run.Get the first result from the query that is not marked as read only, causing the query to be run.Get the result from the query, causing the query to be run.Get a single result from the query, causing the query to be run.Get the non read only results from the query, causing the query to be run.Get a single result from the query that is not marked as read only, causing the query to be run.
-
Method Details
-
addCriteria
Add a criteria to query- Parameters:
criteria
- the criteria to add
-
getFirstResult
Get the first result from the query, causing the query to be run.- Returns:
- the first result, or null if there are no results
-
getFirstWritableResult
Get the first result from the query that is not marked as read only, causing the query to be run.- Returns:
- the first writable result, or null if there are no results
-
getSingleResult
Get a single result from the query, causing the query to be run. An exception is thrown if the query does not return exactly one result.- Returns:
- the single result
- Throws:
RuntimeException
- if the query does not return exactly one result
-
getWritableSingleResult
Get a single result from the query that is not marked as read only, causing the query to be run. An exception is thrown if the query does not return exactly one result.- Returns:
- the single writable result
- Throws:
RuntimeException
- if the query does not return exactly one result
-
getResultList
Get the result from the query, causing the query to be run.- Returns:
- the results, or an empty list if there are no results
-
getWritableResultList
Get the non read only results from the query, causing the query to be run.- Returns:
- the results, or an empty list if there are no results
-