Class PropertyQuery<V>
- java.lang.Object
-
- org.keycloak.models.utils.reflection.PropertyQuery<V>
-
public class PropertyQuery<V> extends Object
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:
PropertyQueries
,PropertyCriteria
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PropertyQuery<V>
addCriteria(PropertyCriteria criteria)
Add a criteria to queryProperty<V>
getFirstResult()
Get the first result from the query, causing the query to be run.Property<V>
getFirstWritableResult()
Get the first result from the query that is not marked as read only, causing the query to be run.Map<String,Property<V>>
getResultList()
Get the result from the query, causing the query to be run.Property<V>
getSingleResult()
Get a single result from the query, causing the query to be run.Map<String,Property<V>>
getWritableResultList()
Get the non read only results from the query, causing the query to be run.Property<V>
getWritableSingleResult()
Get a single result from the query that is not marked as read only, causing the query to be run.
-
-
-
Method Detail
-
addCriteria
public PropertyQuery<V> addCriteria(PropertyCriteria criteria)
Add a criteria to query- Parameters:
criteria
- the criteria to add
-
getFirstResult
public Property<V> 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
public Property<V> 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
public Property<V> 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
public Property<V> 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
public Map<String,Property<V>> 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
-
-