/** * @see #getTypeName(Class) */ protected String getTypeName(T delegate) { return getTypeName((Class<? extends T>) delegate.getClass()); }
/** * Removes any elements from the passed-in collection that aren't of the given type. This is a * convenience method for subclass-aware resources that want to limit query results to a given * type. * * @param collection * @param type a user-friendly type name */ protected void filterByType(Collection<T> collection, String type) { for (Iterator<T> i = collection.iterator(); i.hasNext();) { T instance = i.next(); if (!getTypeName(instance).equals(type)) i.remove(); } }
/** * If this resource supports subclasses, then we add a type property to the input, and return it * * @param simple simplified representation which will be decorated with the user-friendly type * name * @param delegate the object that simple represents */ private void maybeDecorateWithType(SimpleObject simple, T delegate) { if (hasTypesDefined()) simple.add(RestConstants.PROPERTY_FOR_TYPE, getTypeName(delegate)); }