From 2ab2242f6034e6b986b9c9de7e4d4d5876cf345f Mon Sep 17 00:00:00 2001
From: David Avendasora
+ * This method will automatically
+ * {@link ERXArrayUtilities#removeNullValues(NSArray) remove}
+ * {@code NSKeyValueCoding.Null} elements,
+ * {@link ERXArrayUtilities#flatten(NSArray) flatten} all elements that are
+ * arrays and {@link ERXArrayUtilities#distinct(NSArray) remove} all
+ * duplicate objects.
+ *
+ * A type-safe wrapper for {@link #valueForKeyPath(String)} that calls
+ * {@code valueForKeyPath(erxKey.key())} and attempts to cast the result to
+ * {@code NSArray
+ * Then, depending upon the parameters, removes
+ * {@link NSKeyValueCoding.Null} elements, flattens any {@link NSArray}
+ * elements and then filters out duplicate values.
+ *
+ * If the value cannot be cast it will throw a {@link ClassCastException}
+ * .
+ *
- * This method will automatically
- * {@link ERXArrayUtilities#removeNullValues(NSArray) remove}
- * {@code NSKeyValueCoding.Null} elements,
- * {@link ERXArrayUtilities#flatten(NSArray) flatten} all elements that are
- * arrays and {@link ERXArrayUtilities#distinct(NSArray) remove} all
- * duplicate objects.
+ * A type-safe wrapper for {@link #valueForKey(String)} that automatically
+ * does the following (in order) to the resulting array prior to returning
+ * it:
+ *
+ *
* true
, which can only possibly happen if
+ * {@link ERXKey#type()} has been set.)
- * Then, depending upon the parameters, removes - * {@link NSKeyValueCoding.Null} elements, flattens any {@link NSArray} - * elements and then filters out duplicate values. + * Then, depending upon the parameters, + *
true
, which can only possibly happen if
+ * {@link ERXKey#type()} has been set.)
* If the value cannot be cast it will throw a {@link ClassCastException}
@@ -1147,14 +1161,16 @@ public
+ * Indicates that this key represents an {@link EOAttribute} defined in
+ * the {@link EOModel}. Since it is defined in the model it can be used
+ * when instantiating Objects that impact SQL generation, e.g.,
+ * {@link EOQualifier} and {@link EOSortOrdering}.
+ *
+ * Indicates that this key represents an {@link EORelationship} defined
+ * in the {@link EOModel} that will return
+ * Indicates that this key represents an {@link EORelationship} defined
+ * in the {@link EOModel} that will return
+ * Indicates that this key represents an {@link NSArray.Operator}, e.g.,
+ * {@link NSArray._SumNumberOperator @sum},
+ * {@link ERXArrayUtilities.FlattenOperator @flatten},
+ * {@link ERXArrayUtilities.FlattenOperator @fetchSpec},
+ * {@link NSArray._MinOperator @min}
+ *
+ * Note: this Type is not recognized by the
+ * {@link ERXKeyFilter#matches(ERXKey, Type)} and will not be included
+ * in {@link ERXKeyFilter#includeAll()},
+ * {@link ERXKeyFilter#includeAttributes()} nor
+ * {@link ERXKeyFilter#includeAttributesAndToOneRelationships()} because
+ * {@link ERXKeyFilter} can only be used with {@link ERXKey}s that
+ * represent a single key {@link NSArray.Operator}s represent a keypath.
+ *
+ * Indicates that this key represents a visible method or ivar that
+ * returns an object of type T, but does not have a corresponding
+ * relationship entry in the {@link EOModel} and therefore cannot be
+ * used to instantiate objects that will impact SQL generation. e.g.,
+ * {@link EOQualifier} and {@link EOSortOrdering}.
+ *
+ * Note: this ERXKey.Type is not recognized by the
+ * {@link ERXKeyFilter#matches(ERXKey, Type)} and will not be included
+ * in {@link ERXKeyFilter#includeAll()},
+ * {@link ERXKeyFilter#includeAttributes()} nor
+ * {@link ERXKeyFilter#includeAttributesAndToOneRelationships()}.
+ *
+ * TODO: Additional work needs to be done to validate that ERRest's use
+ * of ERXKeyFilter is compatible with this ERXKey.Type.
+ *
+ * Indicates that this key represents a visible instance member that
+ * returns an instance of {@link EOEnterpriseObject} of type T, but does
+ * not have a corresponding relationship entry in the {@link EOModel}
+ * and therefore cannot be used to instantiate objects that will impact
+ * SQL generation. e.g., {@link EOQualifier} and {@link EOSortOrdering}.
+ *
+ * Note: this ERXKey.Type is not recognized by the
+ * {@link ERXKeyFilter#matches(ERXKey, Type)} and will not be included
+ * in {@link ERXKeyFilter#includeAll()},
+ * {@link ERXKeyFilter#includeAttributes()} nor
+ * {@link ERXKeyFilter#includeAttributesAndToOneRelationships()}.
+ *
+ * TODO: Additional work needs to be done to validate that ERRest's use
+ * of ERXKeyFilter is compatible with this ERXKey.Type.
+ *
+ * Indicates that this key represents a visible instance member that
+ * returns an array of {@link EOEnterpriseObject} instances of type T,
+ * but does not have a corresponding relationship entry in the
+ * {@link EOModel} and therefore cannot be used to instantiate objects
+ * that will impact SQL generation. e.g., {@link EOQualifier} and
+ * {@link EOSortOrdering}.
+ *
+ * Note: this ERXKey.Type is not recognized by the
+ * {@link ERXKeyFilter#matches(ERXKey, Type)} and will not be included
+ * in {@link ERXKeyFilter#includeAll()},
+ * {@link ERXKeyFilter#includeAttributes()} nor
+ * {@link ERXKeyFilter#includeAttributesAndToOneRelationships()}.
+ *
+ * TODO: Additional work needs to be done to validate that ERRest's use
+ * of ERXKeyFilter is compatible with this ERXKey.Type.
+ *
+ * Note: if {@link #type()} has not been set, then this will return
+ * false
for
+ * {@link EORelationship#isToMany()}. Since it is defined in the model
+ * it can be used when instantiating Objects that impact SQL generation,
+ * e.g., {@link EOQualifier} and {@link EOSortOrdering}.
+ * true
for
+ * {@link EORelationship#isToMany()}. Since it is defined in the model
+ * it can be used when instantiating Objects that impact SQL generation,
+ * e.g., {@link EOQualifier} and {@link EOSortOrdering}.
+ *
+ * public static final ERXKey<$attribute.javaClassName> ${attribute.uppercaseUnderscoreName} = new ERXKey<$attribute.javaClassName>("$attribute.name", ERXKey.Type.Attribute);
+ *
+ * public static final ERXKey<$relationship.actualDestination.classNameWithDefault> ${relationship.uppercaseUnderscoreName} = new ERXKey<$relationship.actualDestination.classNameWithDefault>("$relationship.name", ERXKey.Type.ToOneRelationship);
+ *
+ * public static final ERXKey<$relationship.actualDestination.classNameWithDefault> ${relationship.uppercaseUnderscoreName} = new ERXKey<$relationship.actualDestination.classNameWithDefault>("$relationship.name", ERXKey.Type.ToManyRelationship);
+ *
*
* @param key
- * the underlying keypath
+ * the underlying key or keypath
* @param type
+ * the {@link Type}
*/
public ERXKey(String key, Type type) {
_key = key;
- setType(type);
+ _type = type;
}
/**
@@ -1551,6 +1681,23 @@ public ERXKey(String key, String locale) {
_key = key + "_" + locale;
}
+ /**
+ * Constructs a localized ERXKey, specifying what {@link Type} it is.
+ *
+ * @param key
+ * the underlying keypath
+ * @param locale
+ * the locale for the key
+ * @param type
+ * the {@link Type}
+ *
+ * @see #ERXKey(String, Type)
+ */
+ public ERXKey(String key, String locale, Type type) {
+ _key = key + "_" + locale;
+ _type = type;
+ }
+
/**
* Equivalent to ERXS.asc(key())
*
@@ -2657,6 +2804,12 @@ public ERXSortOrderings dot(NSArrayfalse
. To set it, you have the following options:
+ *
+ *
+ *
true
if {@link #type()} returns either
+ * {@link ERXKey.Type.Attribute} or
+ * {@link ERXKey.Type.NonModelAttribute}, false
+ * otherwise.
+ *
+ * @see isToOneRelationship
+ * @see isToManyRelationship
+ */
public boolean isAttribute() {
return type() == ERXKey.Type.Attribute || type() == ERXKey.Type.NonModelAttribute;
}
+ /**
+ * Checks this key's {@link ERXKey.Type} to determine if it represents a
+ * to-one {@link EORelationship}.
+ *
+ * Note: if {@link #type()} has not been set, then this will return
+ * false
. To set it, you have the following options:
+ *
true
if {@link #type()} returns either
+ * {@link ERXKey.Type.ToOneRelationship} or
+ * {@link ERXKey.Type.NonModelToOneRelationship}, false
+ * otherwise.
+ *
+ * @see isAttribute
+ * @see isToManyRelationship
+ */
public boolean isToOneRelationship() {
return type() == ERXKey.Type.ToOneRelationship || type() == ERXKey.Type.NonModelToOneRelationship;
}
+ /**
+ * Checks this key's {@link ERXKey.Type} to determine if it represents a
+ * to-many {@link EORelationship}.
+ *
+ * Note: if {@link #type()} has not been set, then this will return
+ * false
. To set it, you have the following options:
+ *
true
if {@link #type()} returns either
+ * {@link ERXKey.Type.ToOneRelationship} or
+ * {@link ERXKey.Type.NonModelToOneRelationship}, false
+ * otherwise.
+ *
+ * @see isAttribute
+ * @see isToOneRelationship
+ */
public boolean isToManyRelationship() {
return type() == ERXKey.Type.ToManyRelationship || type() == ERXKey.Type.NonModelToManyRelationship;
}