Skip to content

Commit

Permalink
[Enhancement #176] Add integration test for Criteria API isMember pre…
Browse files Browse the repository at this point in the history
…dicate.

Fix attribute resolution in SOQL parser.
  • Loading branch information
ledsoft committed Jul 21, 2023
1 parent f27471b commit a9372ab
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 105 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
import java.util.Set;

/**
* Instances of the type ManagedType represent entity, mapped superclass, and
* embeddable types.
* Instances of the type ManagedType represent entity, mapped superclass, and embeddable types.
*
* @param <X> The represented type.
*/
Expand All @@ -33,80 +32,75 @@ public interface ManagedType<X> extends Type<X> {
Set<Attribute<? super X, ?>> getAttributes();

/**
* Return the attributes declared by the managed type. Returns empty set if
* the managed type has no declared attributes.
* Return the attributes declared by the managed type. Returns empty set if the managed type has no declared
* attributes.
*
* @return declared attributes of the managed type
*/
Set<Attribute<X, ?>> getDeclaredAttributes();

/**
* Return the single-valued attribute of the managed type that corresponds
* to the specified name and Java type.
* Return the single-valued attribute of the managed type that corresponds to the specified name and Java type.
*
* @param name the name of the represented attribute
* @param type the type of the represented attribute
* @return single-valued attribute with given name and type
* @throws IllegalArgumentException if attribute of the given name and type is not present in the managed type
*/
<Y> SingularAttribute<? super X, Y> getSingularAttribute(String name,
Class<Y> type);
<Y> SingularAttribute<? super X, Y> getSingularAttribute(String name, Class<Y> type);

/**
* Return the single-valued attribute declared by the managed type that
* corresponds to the specified name and Java type.
* Return the single-valued attribute declared by the managed type that corresponds to the specified name and Java
* type.
*
* @param name the name of the represented attribute
* @param type the type of the represented attribute
* @return declared single-valued attribute of the given name and type
* @throws IllegalArgumentException if attribute of the given name and type is not declared in the managed type
*/
<Y> SingularAttribute<X, Y> getDeclaredSingularAttribute(String name,
Class<Y> type);
<Y> SingularAttribute<X, Y> getDeclaredSingularAttribute(String name, Class<Y> type);

/**
* Return the single-valued attributes of the managed type. Returns empty
* set if the managed type has no single-valued attributes.
* Return the single-valued attributes of the managed type. Returns empty set if the managed type has no
* single-valued attributes.
*
* @return single-valued attributes
*/
Set<SingularAttribute<? super X, ?>> getSingularAttributes();

/**
* Return the single-valued attributes declared by the managed type. Returns
* empty set if the managed type has no declared single-valued attributes.
* Return the single-valued attributes declared by the managed type. Returns empty set if the managed type has no
* declared single-valued attributes.
*
* @return declared single-valued attributes
*/
Set<SingularAttribute<X, ?>> getDeclaredSingularAttributes();

/**
* Return the Collection-valued attribute of the managed type that
* corresponds to the specified name and Java element type.
* Return the Collection-valued attribute of the managed type that corresponds to the specified name and Java
* element type.
*
* @param name the name of the represented attribute
* @param elementType the element type of the represented attribute
* @return CollectionAttribute of the given name and element type
* @throws IllegalArgumentException if attribute of the given name and type is not present in the managed type
*/
<E> CollectionAttribute<? super X, E> getCollection(String name,
Class<E> elementType);
<E> CollectionAttribute<? super X, E> getCollection(String name, Class<E> elementType);

/**
* Return the Collection-valued attribute declared by the managed type that
* corresponds to the specified name and Java element type.
* Return the Collection-valued attribute declared by the managed type that corresponds to the specified name and
* Java element type.
*
* @param name the name of the represented attribute
* @param elementType the element type of the represented attribute
* @return declared CollectionAttribute of the given name and element type
* @throws IllegalArgumentException if attribute of the given name and type is not declared in the managed type
*/
<E> CollectionAttribute<X, E> getDeclaredCollection(String name,
Class<E> elementType);
<E> CollectionAttribute<X, E> getDeclaredCollection(String name, Class<E> elementType);

/**
* Return the Set-valued attribute of the managed type that corresponds to
* the specified name and Java element type.
* Return the Set-valued attribute of the managed type that corresponds to the specified name and Java element
* type.
*
* @param name the name of the represented attribute
* @param elementType the element type of the represented attribute
Expand All @@ -116,8 +110,8 @@ <E> CollectionAttribute<X, E> getDeclaredCollection(String name,
<E> SetAttribute<? super X, E> getSet(String name, Class<E> elementType);

/**
* Return the Set-valued attribute declared by the managed type that
* corresponds to the specified name and Java element type.
* Return the Set-valued attribute declared by the managed type that corresponds to the specified name and Java
* element type.
*
* @param name the name of the represented attribute
* @param elementType the element type of the represented attribute
Expand All @@ -128,8 +122,8 @@ <E> CollectionAttribute<X, E> getDeclaredCollection(String name,
<E> SetAttribute<X, E> getDeclaredSet(String name, Class<E> elementType);

/**
* Return the List-valued attribute of the managed type that corresponds to
* the specified name and Java element type.
* Return the List-valued attribute of the managed type that corresponds to the specified name and Java element
* type.
*
* @param name the name of the represented attribute
* @param elementType the element type of the represented attribute
Expand All @@ -139,8 +133,8 @@ <E> CollectionAttribute<X, E> getDeclaredCollection(String name,
<E> ListAttribute<? super X, E> getList(String name, Class<E> elementType);

/**
* Return the List-valued attribute declared by the managed type that
* corresponds to the specified name and Java element type.
* Return the List-valued attribute declared by the managed type that corresponds to the specified name and Java
* element type.
*
* @param name the name of the represented attribute
* @param elementType the element type of the represented attribute
Expand All @@ -150,80 +144,67 @@ <E> CollectionAttribute<X, E> getDeclaredCollection(String name,
<E> ListAttribute<X, E> getDeclaredList(String name, Class<E> elementType);

/**
* Return the Map-valued attribute of the managed type that corresponds to
* the specified name and Java key and value types.
* Return the Map-valued attribute of the managed type that corresponds to the specified name and Java key and value
* types.
*
* @param name the name of the represented attribute
* @param keyType the key type of the represented attribute
* @param valueType the value type of the represented attribute
* @return MapAttribute of the given name and key and value types
* @throws IllegalArgumentException if attribute of the given name and type is not present in the managed type
*/
<K, V> MapAttribute<? super X, K, V> getMap(String name, Class<K> keyType,
Class<V> valueType);
<K, V> MapAttribute<? super X, K, V> getMap(String name, Class<K> keyType, Class<V> valueType);

/**
* Return the Map-valued attribute declared by the managed type that
* corresponds to the specified name and Java key and value types.
* Return the Map-valued attribute declared by the managed type that corresponds to the specified name and Java key
* and value types.
*
* @param name the name of the represented attribute
* @param keyType the key type of the represented attribute
* @param valueType the value type of the represented attribute
* @return declared MapAttribute of the given name and key and value types
* @throws IllegalArgumentException if attribute of the given name and type is not declared in the managed type
*/
<K, V> MapAttribute<X, K, V> getDeclaredMap(String name, Class<K> keyType,
Class<V> valueType);
<K, V> MapAttribute<X, K, V> getDeclaredMap(String name, Class<K> keyType, Class<V> valueType);

/**
* Return all multi-valued attributes (Collection-, Set-, List-, and
* Map-valued attributes) of the managed type. Returns empty set if the
* managed type has no multi-valued attributes.
* Return all multi-valued attributes (Collection-, Set-, List-, and Map-valued attributes) of the managed type.
* Returns empty set if the managed type has no multi-valued attributes.
*
* @return Collection-, Set-, List-, and Map-valued attributes
*/
Set<PluralAttribute<? super X, ?, ?>> getPluralAttributes();

/**
* Return all multi-valued attributes (Collection-, Set-, List-, and
* Map-valued attributes) declared by the managed type. Returns empty set if
* the managed type has no declared multi-valued attributes.
* Return all multi-valued attributes (Collection-, Set-, List-, and Map-valued attributes) declared by the managed
* type. Returns empty set if the managed type has no declared multi-valued attributes.
*
* @return declared Collection-, Set-, List-, and Map-valued
* <p>
* attributes
* @return declared Collection-, Set-, List-, and Map-valued attributes
*/
Set<PluralAttribute<X, ?, ?>> getDeclaredPluralAttributes();

// String-based:

/**
* Return the attribute of the managed type that corresponds to the
* specified name.
* Return the attribute of the managed type that corresponds to the specified name.
*
* @param name the name of the represented attribute
* @return attribute with given name
* @throws IllegalArgumentException if attribute of the given
* <p>
* name is not present in the managed type
* @throws IllegalArgumentException if attribute of the given name is not present in the managed type
*/
Attribute<? super X, ?> getAttribute(String name);

/**
* Return the attribute declared by the managed type that corresponds to the
* specified name.
* Return the attribute declared by the managed type that corresponds to the specified name.
*
* @param name the name of the represented attribute
* @return attribute with given name
* @throws IllegalArgumentException if attribute of the given
* <p>
* name is not declared in the managed type
* @throws IllegalArgumentException if attribute of the given name is not declared in the managed type
*/
Attribute<X, ?> getDeclaredAttribute(String name);

/**
* Return the single-valued attribute of the managed type that corresponds
* to the specified name.
* Return the single-valued attribute of the managed type that corresponds to the specified name.
*
* @param name the name of the represented attribute
* @return single-valued attribute with the given name
Expand All @@ -232,20 +213,16 @@ <K, V> MapAttribute<X, K, V> getDeclaredMap(String name, Class<K> keyType,
SingularAttribute<? super X, ?> getSingularAttribute(String name);

/**
* Return the single-valued attribute declared by the managed type that
* corresponds to the specified name.
* Return the single-valued attribute declared by the managed type that corresponds to the specified name.
*
* @param name the name of the represented attribute
* @return declared single-valued attribute of the given
* <p>
* name
* @return declared single-valued attribute of the given name
* @throws IllegalArgumentException if attribute of the given name is not declared in the managed type
*/
SingularAttribute<X, ?> getDeclaredSingularAttribute(String name);

/**
* Return the Collection-valued attribute of the managed type that
* corresponds to the specified name.
* Return the Collection-valued attribute of the managed type that corresponds to the specified name.
*
* @param name the name of the represented attribute
* @return CollectionAttribute of the given name
Expand All @@ -254,8 +231,7 @@ <K, V> MapAttribute<X, K, V> getDeclaredMap(String name, Class<K> keyType,
CollectionAttribute<? super X, ?> getCollection(String name);

/**
* Return the Collection-valued attribute declared by the managed type that
* corresponds to the specified name.
* Return the Collection-valued attribute declared by the managed type that corresponds to the specified name.
*
* @param name the name of the represented attribute
* @return declared CollectionAttribute of the given name
Expand All @@ -264,8 +240,7 @@ <K, V> MapAttribute<X, K, V> getDeclaredMap(String name, Class<K> keyType,
CollectionAttribute<X, ?> getDeclaredCollection(String name);

/**
* Return the Set-valued attribute of the managed type that corresponds to
* the specified name.
* Return the Set-valued attribute of the managed type that corresponds to the specified name.
*
* @param name the name of the represented attribute
* @return SetAttribute of the given name
Expand All @@ -274,8 +249,7 @@ <K, V> MapAttribute<X, K, V> getDeclaredMap(String name, Class<K> keyType,
SetAttribute<? super X, ?> getSet(String name);

/**
* Return the Set-valued attribute declared by the managed type that
* corresponds to the specified name.
* Return the Set-valued attribute declared by the managed type that corresponds to the specified name.
*
* @param name the name of the represented attribute
* @return declared SetAttribute of the given name
Expand All @@ -284,8 +258,7 @@ <K, V> MapAttribute<X, K, V> getDeclaredMap(String name, Class<K> keyType,
SetAttribute<X, ?> getDeclaredSet(String name);

/**
* Return the List-valued attribute of the managed type that corresponds to
* the specified name.
* Return the List-valued attribute of the managed type that corresponds to the specified name.
*
* @param name the name of the represented attribute
* @return ListAttribute of the given name
Expand All @@ -294,8 +267,7 @@ <K, V> MapAttribute<X, K, V> getDeclaredMap(String name, Class<K> keyType,
ListAttribute<? super X, ?> getList(String name);

/**
* Return the List-valued attribute declared by the managed type that
* corresponds to the specified name.
* Return the List-valued attribute declared by the managed type that corresponds to the specified name.
*
* @param name the name of the represented attribute
* @return declared ListAttribute of the given name
Expand All @@ -304,8 +276,7 @@ <K, V> MapAttribute<X, K, V> getDeclaredMap(String name, Class<K> keyType,
ListAttribute<X, ?> getDeclaredList(String name);

/**
* Return the Map-valued attribute of the managed type that corresponds to
* the specified name.
* Return the Map-valued attribute of the managed type that corresponds to the specified name.
*
* @param name the name of the represented attribute
* @return MapAttribute of the given name
Expand All @@ -314,8 +285,7 @@ <K, V> MapAttribute<X, K, V> getDeclaredMap(String name, Class<K> keyType,
MapAttribute<? super X, ?, ?> getMap(String name);

/**
* Return the Map-valued attribute declared by the managed type that
* corresponds to the specified name.
* Return the Map-valued attribute declared by the managed type that corresponds to the specified name.
*
* @param name the name of the represented attribute
* @return declared MapAttribute of the given name
Expand All @@ -331,23 +301,19 @@ <K, V> MapAttribute<X, K, V> getDeclaredMap(String name, Class<K> keyType,
Set<QueryAttribute<? super X, ?>> getQueryAttributes();

/**
* Check if a query based attribute of the managed type that corresponds to the
* specified name exists.
* Check if a query based attribute of the managed type that corresponds to the specified name exists.
*
* @param name the name of the represented attribute
* @return {@code true} if the query attribute exists
*/
boolean hasQueryAttribute(String name);

/**
* Return the query based attribute of the managed type that corresponds to the
* specified name.
* Return the query based attribute of the managed type that corresponds to the specified name.
*
* @param name the name of the represented attribute
* @return attribute with given name
* @throws IllegalArgumentException if attribute of the given
* <p>
* name is not present in the managed type
* @throws IllegalArgumentException if attribute of the given name is not present in the managed type
*/
QueryAttribute<? super X, ?> getQueryAttribute(String name);

Expand All @@ -371,8 +337,8 @@ <K, V> MapAttribute<X, K, V> getDeclaredMap(String name, Class<K> keyType,
/**
* Gets specification of a field with the specified name.
* <p>
* In contrast to {@link #getAttribute(String)}, calling this method can also return field specification for
* a query based attribute, types or properties field.
* In contrast to {@link #getAttribute(String)}, calling this method can also return field specification for a query
* based attribute, types or properties field.
*
* @param fieldName Name of the field
* @return Field specification
Expand All @@ -384,8 +350,8 @@ <K, V> MapAttribute<X, K, V> getDeclaredMap(String name, Class<K> keyType,
/**
* Gets all field specifications of this entity type.
* <p>
* In contrast to {@link #getAttributes()}, this method returns also specifications of query based attributes, types and properties (if
* present).
* In contrast to {@link #getAttributes()}, this method returns also specifications of query based attributes, types
* and properties (if present).
*
* @return Field specifications
*/
Expand Down
Loading

0 comments on commit a9372ab

Please sign in to comment.