/** * Wrap a {@link Collection} in an {@link ObjectCollection}. * * @param objects The collection of objects. * @param <E> The type of objects. * @return The collection as an {@link ObjectCollection}. */ public static <E> ObjectCollection<E> objectCollection(Collection<E> objects) { if (objects instanceof ObjectCollection) { return (ObjectCollection<E>) objects; } else { return new ObjectCollectionWrapper<>(objects); } }
/** * Wrap a {@link Collection} in an {@link ObjectCollection}. * * @param objects The collection of objects. * @param <E> The type of objects. * @return The collection as an {@link ObjectCollection}. */ public static <E> ObjectCollection<E> objectCollection(Collection<E> objects) { if (objects instanceof ObjectCollection) { return (ObjectCollection<E>) objects; } else { return new ObjectCollectionWrapper<>(objects); } }