Package org.springframework.hateoas
Class CollectionModel<T>
java.lang.Object
org.springframework.hateoas.RepresentationModel<CollectionModel<T>>
org.springframework.hateoas.CollectionModel<T>
- All Implemented Interfaces:
- Iterable<T>,- ResolvableTypeProvider
- Direct Known Subclasses:
- CollectionModelMixin,- PagedModel,- SlicedModel,- VndErrors
public class CollectionModel<T>
extends RepresentationModel<CollectionModel<T>>
implements Iterable<T>, ResolvableTypeProvider
General helper to easily create a wrapper for a collection of entities.
- Author:
- Oliver Gierke, Greg Turnquist
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedCreates an emptyCollectionModelinstance.protectedCollectionModel(Iterable<T> content) protectedCollectionModel(Iterable<T> content, Iterable<Link> links, ResolvableType fallbackType) 
- 
Method SummaryModifier and TypeMethodDescriptionstatic <T> CollectionModel<T>empty()Creates a new empty collection model.static <T> CollectionModel<T>Creates a new empty collection model with the given type defined as fallback type.static <T> CollectionModel<T>Creates a new empty collection model with the given links.static <T> CollectionModel<T>empty(ParameterizedTypeReference<T> type) Creates a new empty collection model with the given type defined as fallback type.static <T> CollectionModel<T>empty(ResolvableType elementType) Creates a new empty collection model with the given type defined as fallback type.static <T> CollectionModel<T>Creates a new empty collection model with the given links.booleanReturns the underlying elements.inthashCode()iterator()static <T> CollectionModel<T>Creates aCollectionModelinstance with the given content.static <T> CollectionModel<T>s Creates aCollectionModelinstance with the given content andLinks.static <T> CollectionModel<T>Creates aCollectionModelinstance with the given content andLinks (optional).toString()withFallbackType(Class<? super T> type, Class<?>... generics) Declares the given type as fallback element type in case the underlying collection is empty.Declares the given type as fallback element type in case the underlying collection is empty.Declares the given type as fallback element type in case the underlying collection is empty.static <T extends EntityModel<S>,S> 
 CollectionModel<T>Creates a newCollectionModelinstance by wrapping the given domain class instances into aEntityModel.Methods inherited from class org.springframework.hateoas.RepresentationModeladd, add, add, addAllIf, addIf, getLink, getLink, getLinks, getLinks, getLinks, getRequiredLink, getRequiredLink, hasLink, hasLink, hasLinks, mapLink, mapLinkIf, of, of, removeLinksMethods inherited from class java.lang.Objectclone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.IterableforEach, spliterator
- 
Constructor Details- 
CollectionModelprotected CollectionModel()Creates an emptyCollectionModelinstance.
- 
CollectionModel
- 
CollectionModel
 
- 
- 
Method Details- 
emptyCreates a new empty collection model.- Type Parameters:
- T-
- Returns:
- Since:
- 1.1
 
- 
emptyCreates a new empty collection model with the given type defined as fallback type.- Type Parameters:
- T-
- Returns:
- Since:
- 1.4
- See Also:
 
- 
emptyCreates a new empty collection model with the given type defined as fallback type.- Type Parameters:
- T-
- Returns:
- Since:
- 1.4
- See Also:
 
- 
emptyCreates a new empty collection model with the given type defined as fallback type.- Type Parameters:
- T-
- Returns:
- Since:
- 1.4
- See Also:
 
- 
emptyCreates a new empty collection model with the given links.- Type Parameters:
- T-
- Parameters:
- links- must not be null.
- Returns:
- Since:
- 1.1
 
- 
emptyCreates a new empty collection model with the given links.- Type Parameters:
- T-
- Parameters:
- links- must not be null.
- Returns:
- Since:
- 1.1
 
- 
ofCreates aCollectionModelinstance with the given content.- Parameters:
- content- must not be null.
- Returns:
- Since:
- 1.1
- See Also:
 
- 
ofCreates aCollectionModelinstance with the given content andLinks (optional).- Parameters:
- content- must not be null.
- links- the links to be added to the- CollectionModel.
- Returns:
- Since:
- 1.1
- See Also:
 
- 
ofs Creates aCollectionModelinstance with the given content andLinks.- Parameters:
- content- must not be null.
- links- the links to be added to the- CollectionModel.
- Returns:
- Since:
- 1.1
- See Also:
 
- 
wrapCreates a newCollectionModelinstance by wrapping the given domain class instances into aEntityModel.- Parameters:
- content- must not be null.
- Returns:
 
- 
getContentReturns the underlying elements.- Returns:
- the content will never be null.
 
- 
withFallbackTypeDeclares the given type as fallback element type in case the underlying collection is empty. This allows client components to still apply type matches at runtime.- Parameters:
- type- must not be null.
- Returns:
- will never be null.
- Since:
- 1.4
 
- 
withFallbackTypeDeclares the given type as fallback element type in case the underlying collection is empty. This allows client components to still apply type matches at runtime.- Parameters:
- type- must not be null.
- Returns:
- will never be null.
- Since:
- 1.4
 
- 
withFallbackTypeDeclares the given type as fallback element type in case the underlying collection is empty. This allows client components to still apply type matches at runtime.- Parameters:
- type- must not be null.
- Returns:
- will never be null.
- Since:
- 1.4
 
- 
getResolvableType- Specified by:
- getResolvableTypein interface- ResolvableTypeProvider
 
- 
iterator
- 
toString- Overrides:
- toStringin class- RepresentationModel<CollectionModel<T>>
 
- 
equals- Overrides:
- equalsin class- RepresentationModel<CollectionModel<T>>
 
- 
hashCodepublic int hashCode()- Overrides:
- hashCodein class- RepresentationModel<CollectionModel<T>>
 
 
-