default boolean isEqual(Object o) { if (this == o) return true; if (!(o instanceof Attribute)) return false; Attribute that = (Attribute) o; // TODO: reinstate this cachedHashCode comparison once EqualsVerifier supports cached hash code "shortcut": //if (cachedHashCode != that.cachedHashCode) return false; if (!that.canEqual(this)) return false; if (!getAttributeName().equals(that.getAttributeName())) return false; if (!getAttributeType().equals(that.getAttributeType())) return false; if (!getEffectiveObjectType().equals(that.getEffectiveObjectType())) return false; return true; }
@Override public Class<O> getEffectiveObjectType() { return objectType == null ? Attribute.readGenericObjectType(getClass(), getAttributeName()) : objectType; }
default int calculateHashCode() { int result = getEffectiveObjectType().hashCode(); result = 31 * result + getAttributeType().hashCode(); result = 31 * result + getAttributeName().hashCode(); return result; }
/** * <p> Creates a {@link In} query which asserts that an attribute has at least one value matching any value in a set of values. * <p> Note that <b><u>this can result in more efficient queries</u></b> than several {@link Equal} queries "OR"ed together using other means. * * @param entityIndex The index to which the query refers * @param disjoint Set it to {@code true} if deduplication is not necessary because the results are disjoint. Set it to {@code false} deduplication is needed * @param attributeValues The set of values to match * @param <A> The type of the attribute * @param <O> The type of the object containing the attribute * @return An {@link In} query */ @Deprecated static <O extends Entity, A> Query<EntityHandle<O>> in(EntityIndex<O, A> entityIndex, boolean disjoint, Collection<A> attributeValues) { int n = attributeValues.size(); switch (n) { case 0: return none(entityIndex.getAttribute().getEffectiveObjectType()); case 1: A singleValue = attributeValues.iterator().next(); return equal(entityIndex, singleValue); default: // Copy the values into a Set if necessary... Set<A> values = (attributeValues instanceof Set ? (Set<A>)attributeValues : new HashSet<A>(attributeValues)); return new In<>(entityIndex.getAttribute(), disjoint, values); } }
t = ((ReflectableAttribute) attribute).getAttributeReflectedType(); } else { t = attribute.getAttributeType(); attributeDeserializer = serialization.getDeserializer(attrTypeHandler); ResolvedType objectType = new TypeResolver().resolve(attribute.getEffectiveObjectType()); ObjectTypeHandler objectTypeHandler = (ObjectTypeHandler) TypeHandler.lookup(objectType); if (!(objectTypeHandler instanceof ObjectTypeHandler)) { throw new RuntimeException("Index " + attribute.getAttributeName() + " is not an object, but " + objectType.getBriefDescription()); } else {
/** * <p> Creates a {@link In} query which asserts that an attribute has at least one value matching any value in a set of values. * <p> Note that <b><u>this can result in more efficient queries</u></b> than several {@link Equal} queries "OR"ed together using other means. * * @param entityIndex The index to which the query refers * @param disjoint Set it to {@code true} if deduplication is not necessary because the results are disjoint. Set it to {@code false} deduplication is needed * @param attributeValues The set of values to match * @param <A> The type of the attribute * @param <O> The type of the object containing the attribute * @return An {@link In} query */ static <O extends Entity, A> Query<EntityHandle<O>> in(EntityIndex<O, A> entityIndex, boolean disjoint, Collection<A> attributeValues) { int n = attributeValues.size(); switch (n) { case 0: return none(entityIndex.getAttribute().getEffectiveObjectType()); case 1: A singleValue = attributeValues.iterator().next(); return equal(entityIndex, singleValue); default: // Copy the values into a Set if necessary... Set<A> values = (attributeValues instanceof Set ? (Set<A>)attributeValues : new HashSet<A>(attributeValues)); return new In<>(entityIndex.getAttribute(), disjoint, values); } }
@Override public Class<O> getEffectiveObjectType() { return objectType == null ? Attribute.readGenericObjectType(getClass(), getAttributeName()) : objectType; }