Class ProjectionDefinitionConfiguration
java.lang.Object
org.springframework.data.rest.core.config.ProjectionDefinitionConfiguration
- All Implemented Interfaces:
ProjectionDefinitions
Wrapper class to register projection definitions for later lookup by name and source type.
- Author:
- Oliver Gierke
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddProjection
(Class<?> projectionType) Adds the given projection type to the configuration.addProjection
(Class<?> projectionType, Class<?>... sourceTypes) Adds a projection type for the given source types.addProjection
(Class<?> projectionType, String name, Class<?>... sourceTypes) Adds the given projection type for the given source types under the given name.Returns the request parameter to be used to expose the projection to the web.getProjectionsFor
(Class<?> sourceType) Returns all projections registered for the given source type.Class<?>
getProjectionType
(Class<?> sourceType, String name) Returns the projection type for the given source type and name.boolean
hasProjectionFor
(Class<?> sourceType) Returns whether we have a projection registered for the given source type.void
setParameterName
(String parameterName) Configures the request parameter name to be used to accept the projection name to be returned.
-
Constructor Details
-
ProjectionDefinitionConfiguration
public ProjectionDefinitionConfiguration()Creates a newProjectionDefinitionConfiguration
.
-
-
Method Details
-
getParameterName
Description copied from interface:ProjectionDefinitions
Returns the request parameter to be used to expose the projection to the web.- Specified by:
getParameterName
in interfaceProjectionDefinitions
- Returns:
- the parameterName will never be null or empty.
-
setParameterName
Configures the request parameter name to be used to accept the projection name to be returned.- Parameters:
parameterName
- defaults to "projection", will be set back to this default if null or an empty value is configured.
-
addProjection
Adds the given projection type to the configuration. The type has to be annotated withProjection
for additional metadata.- Parameters:
projectionType
- must not be null.- Returns:
- See Also:
-
addProjection
public ProjectionDefinitionConfiguration addProjection(Class<?> projectionType, Class<?>... sourceTypes) Adds a projection type for the given source types. The name of the projection will be defaulted to the uncapitalized simply class name.- Parameters:
projectionType
- must not be null.sourceTypes
- must not be null or empty.- Returns:
-
addProjection
public ProjectionDefinitionConfiguration addProjection(Class<?> projectionType, String name, Class<?>... sourceTypes) Adds the given projection type for the given source types under the given name.- Parameters:
projectionType
- must not be null.name
- must not be null or empty.sourceTypes
- must not be null or empty.- Returns:
-
getProjectionType
Description copied from interface:ProjectionDefinitions
Returns the projection type for the given source type and name.- Specified by:
getProjectionType
in interfaceProjectionDefinitions
- Parameters:
sourceType
- must not be null.name
- must not be null or empty.- Returns:
-
hasProjectionFor
Description copied from interface:ProjectionDefinitions
Returns whether we have a projection registered for the given source type.- Specified by:
hasProjectionFor
in interfaceProjectionDefinitions
- Parameters:
sourceType
- must not be null.- Returns:
-
getProjectionsFor
Returns all projections registered for the given source type.- Parameters:
sourceType
- must not be null.- Returns:
-