keycloak
公開メンバ関数 | 関数 | 非公開メンバ関数 | 非公開変数類 | 全メンバ一覧
org.keycloak.models.utils.reflection.PropertyQuery< V > クラステンプレート
org.keycloak.models.utils.reflection.PropertyQuery< V > 連携図
Collaboration graph

公開メンバ関数

PropertyQuery< V > addCriteria (PropertyCriteria criteria)
 
Property< V > getFirstResult ()
 
Property< V > getFirstWritableResult ()
 
Property< V > getSingleResult ()
 
Property< V > getWritableSingleResult ()
 
Map< String, Property< V > > getResultList ()
 
Map< String, Property< V > > getWritableResultList ()
 

関数

 PropertyQuery (Class<?> targetClass)
 

非公開メンバ関数

Map< String, Property< V > > getResultList (boolean writable)
 

非公開変数類

final Class<?> targetClass
 
final List< PropertyCriteriacriteria
 

詳解

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.

参照
PropertyQueries
PropertyCriteria

構築子と解体子

◆ PropertyQuery()

org.keycloak.models.utils.reflection.PropertyQuery< V >.PropertyQuery ( Class<?>  targetClass)
inlinepackage
42  {
43  if (targetClass == null) {
44  throw new IllegalArgumentException("targetClass parameter may not be null");
45  }
46 
47  this.targetClass = targetClass;
48  this.criteria = new ArrayList<PropertyCriteria>();
49  }
final List< PropertyCriteria > criteria
Definition: PropertyQuery.java:40
final Class<?> targetClass
Definition: PropertyQuery.java:39

関数詳解

◆ addCriteria()

Add a criteria to query

引数
criteriathe criteria to add
56  {
57  this.criteria.add(criteria);
58  return this;
59  }
final List< PropertyCriteria > criteria
Definition: PropertyQuery.java:40

◆ getFirstResult()

Get the first result from the query, causing the query to be run.

戻り値
the first result, or null if there are no results
66  {
67  Map<String, Property<V>> results = getResultList();
68  return results.isEmpty() ? null : results.values().iterator().next();
69  }
Map< String, Property< V > > getResultList()
Definition: PropertyQuery.java:130

◆ getFirstWritableResult()

Property<V> org.keycloak.models.utils.reflection.PropertyQuery< V >.getFirstWritableResult ( )
inline

Get the first result from the query that is not marked as read only, causing the query to be run.

戻り値
the first writable result, or null if there are no results
76  {
77  Map<String, Property<V>> results = getWritableResultList();
78  return results.isEmpty() ? null : results.values().iterator().next();
79  }
Map< String, Property< V > > getWritableResultList()
Definition: PropertyQuery.java:139

◆ getResultList() [1/2]

Map<String, Property<V> > org.keycloak.models.utils.reflection.PropertyQuery< V >.getResultList ( )
inline

Get the result from the query, causing the query to be run.

戻り値
the results, or an empty list if there are no results
130  {
131  return getResultList(false);
132  }
Map< String, Property< V > > getResultList()
Definition: PropertyQuery.java:130

◆ getResultList() [2/2]

Map<String, Property<V> > org.keycloak.models.utils.reflection.PropertyQuery< V >.getResultList ( boolean  writable)
inlineprivate

Get the result from the query, causing the query to be run.

引数
writableif this query should only return properties that are not read only
戻り値
the results, or an empty list if there are no results
150  {
151  Map<String, Property<V>> properties = new HashMap<String, Property<V>>();
152 
153  // First check public accessor methods (we ignore private methods)
154  for (Method method : targetClass.getMethods()) {
155  if (!(method.getName().startsWith("is") || method.getName().startsWith("get"))) {
156  continue;
157  }
158 
159  boolean match = true;
160  for (PropertyCriteria c : criteria) {
161  if (!c.methodMatches(method)) {
162  match = false;
163  break;
164  }
165  }
166 
167  if (match) {
168  MethodProperty<V> property = Properties.<V>createProperty(method);
169 
170  if (!writable || !property.isReadOnly()) {
171  properties.put(property.getName(), property);
172  }
173  }
174  }
175 
176  return Collections.unmodifiableMap(properties);
177  }
final List< PropertyCriteria > criteria
Definition: PropertyQuery.java:40
final Class<?> targetClass
Definition: PropertyQuery.java:39

◆ 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.

戻り値
the single result
例外
RuntimeExceptionif the query does not return exactly one result
89  {
90  Map<String, Property<V>> results = getResultList();
91  if (results.size() == 1) {
92  return results.values().iterator().next();
93  } else if (results.isEmpty()) {
94  throw new RuntimeException(
95  "Expected one property match, but the criteria did not match any properties on " +
96  targetClass.getName());
97  } else {
98  throw new RuntimeException("Expected one property match, but the criteria matched " + results.size() +
99  " properties on " + targetClass.getName());
100  }
101  }
Map< String, Property< V > > getResultList()
Definition: PropertyQuery.java:130
final Class<?> targetClass
Definition: PropertyQuery.java:39

◆ getWritableResultList()

Map<String, Property<V> > org.keycloak.models.utils.reflection.PropertyQuery< V >.getWritableResultList ( )
inline

Get the non read only results from the query, causing the query to be run.

戻り値
the results, or an empty list if there are no results
139  {
140  return getResultList(true);
141  }
Map< String, Property< V > > getResultList()
Definition: PropertyQuery.java:130

◆ getWritableSingleResult()

Property<V> org.keycloak.models.utils.reflection.PropertyQuery< V >.getWritableSingleResult ( )
inline

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.

戻り値
the single writable result
例外
RuntimeExceptionif the query does not return exactly one result
111  {
112  Map<String, Property<V>> results = getWritableResultList();
113  if (results.size() == 1) {
114  return results.values().iterator().next();
115  } else if (results.isEmpty()) {
116  throw new RuntimeException(
117  "Expected one property match, but the criteria did not match any properties on " +
118  targetClass.getName());
119  } else {
120  throw new RuntimeException("Expected one property match, but the criteria matched " +
121  results.size() + " properties on " + targetClass.getName());
122  }
123  }
Map< String, Property< V > > getWritableResultList()
Definition: PropertyQuery.java:139
final Class<?> targetClass
Definition: PropertyQuery.java:39

メンバ詳解

◆ criteria

◆ targetClass

final Class<?> org.keycloak.models.utils.reflection.PropertyQuery< V >.targetClass
private

このクラス詳解は次のファイルから抽出されました: