/** * {@inheritDoc} */ @Override public void validateValue(String name, Object value) { if (!(value instanceof Double)) { throw new SearchException("Expecting a Double value for attribute [" + name + "] but was " + type(value)); } } },
/** * Create a range criteria between the given min/max (inclusive). This is the same as calling <code>between(min, max, true, true)</code> * * @param min the minimum value in the range * @param max the maximum value in the range * @return criteria instance */ public Criteria between(T min, T max) { return between(min, max, true, true); }
/** * {@inheritDoc} */ @Override public <T> Attribute<T> getSearchAttribute(String attributeName) { return new Attribute(attributeName); }
private void processOrdering(List<Ordering> orderings) { for (Ordering ordering : orderings) { String attributeName = ordering.getAttribute().getAttributeName(); if (Direction.DESCENDING.equals(ordering.getDirection())) { attributeDescending(attributeName); } else { attributeAscending(attributeName); } } }
/** * {@inheritDoc} */ public <T> T getAttribute(Attribute<T> attribute) { String name = attribute.getAttributeName(); if (!query.requestedAttributes().contains(attribute)) { throw new SearchException("Attribute [" + name + "] not included in query"); } return (T) basicGetAttribute(name); }
/** * {@inheritDoc} */ @Override public void validateValue(String name, Object value) { if (!(value instanceof Integer)) { throw new SearchException("Expecting an Integer value for attribute [" + name + "] but was " + type(value)); } } },
@Override public Set<Attribute<?>> getAttributes() { return Collections.<Attribute<?>>singleton(new Attribute(attributeName)); }
/** * {@inheritDoc} */ @Override public void validateValue(String name, Object value) { if (!(value instanceof Short)) { throw new SearchException("Expecting a Short value for attribute [" + name + "] but was " + type(value)); } } },
/** * {@inheritDoc} */ @Override public void validateValue(String name, Object value) { if (!(value instanceof Boolean)) { throw new SearchException("Expecting a Boolean value for attribute [" + name + "] but was " + type(value)); } } },
/** * {@inheritDoc} */ @Override public void validateValue(String name, Object value) { if (!(value instanceof Byte)) { throw new SearchException("Expecting a Byte value for attribute [" + name + "] but was " + type(value)); } } },
/** * {@inheritDoc} */ @Override public void validateValue(String name, Object value) { if (!(value instanceof Float)) { throw new SearchException("Expecting a Float value for attribute [" + name + "] but was " + type(value)); } } },
/** * {@inheritDoc} */ @Override public void validateValue(String name, Object value) { if (!(value instanceof Long)) { throw new SearchException("Expecting a Long value for attribute [" + name + "] but was " + type(value)); } } },
private void checkFrozen() { if (frozen) { throw new SearchException("Query is frozen and cannot be mutated"); } }
/** * {@inheritDoc} */ @Override public void validateValue(String name, Object value) { if (!(value instanceof Enum)) { throw new SearchException("Expecting a enum value for attribute [" + name + "] but was " + type(value)); } } },
/** * {@inheritDoc} */ @Override public void validateValue(String name, Object value) { if (!(value instanceof Character)) { throw new SearchException("Expecting a Character value for attribute [" + name + "] but was " + type(value)); } } },
/** * {@inheritDoc} */ @Override public void validateValue(String name, Object value) { if (!(value instanceof String)) { throw new SearchException("Expecting a String value for attribute [" + name + "] but was " + type(value)); } } };
public void setCacheName(String cacheName) { String[] tokens = cacheName.split("\\."); if (tokens.length > 2) { throw new SearchException("Cache manager name not specified."); } else if (tokens.length == 2) { this.cacheManagerName = tokens[0]; this.cacheName = tokens[1]; this.cacheManagerNameWasAttempted = true; } else { this.cacheName = cacheName; } }
/** * {@inheritDoc} */ @Override public void validateValue(String name, Object value) { if (value == null || value.getClass() != java.util.Date.class) { throw new SearchException("Expecting a java.util.Date value for attribute [" + name + "] but was " + type(value)); } } },
/** * {@inheritDoc} */ @Override public void validateValue(String name, Object value) { if (value == null || value.getClass() != java.sql.Date.class) { throw new SearchException("Expecting a java.sql.Date value for attribute [" + name + "] but was " + type(value)); } } },
/** * {@inheritDoc} */ public List<Object> getAggregatorResults() throws SearchException { if (this.aggregateResults.isEmpty()) { throw new SearchException("No aggregators present in query"); } return this.aggregateResults; }