1515 */
1616package org .springframework .data .rest .webmvc .support ;
1717
18- import org .springframework .core .convert .converter .Converter ;
18+ import java .util .function .Function ;
19+
1920import org .springframework .data .projection .ProjectionFactory ;
2021import org .springframework .data .rest .core .mapping .ResourceMappings ;
2122import org .springframework .data .rest .core .projection .ProjectionDefinitions ;
@@ -59,14 +60,7 @@ public PersistentEntityProjector(ProjectionDefinitions projectionDefinitions, Pr
5960 * @see org.springframework.data.rest.webmvc.support.Projector#project(java.lang.Object)
6061 */
6162 public Object project (Object source ) {
62-
63- return projectWithDefault (source , new Converter <Object , Object >() {
64-
65- @ Override
66- public Object convert (Object source ) {
67- return source ;
68- }
69- });
63+ return projectWithDefault (source , Function .identity ());
7064 }
7165
7266 /*
@@ -75,34 +69,27 @@ public Object convert(Object source) {
7569 */
7670 @ Override
7771 public Object projectExcerpt (Object source ) {
78-
79- return projectWithDefault (source , new Converter <Object , Object >() {
80-
81- @ Override
82- public Object convert (Object source ) {
83- return PersistentEntityProjector .super .projectExcerpt (source );
84- }
85- });
72+ return projectWithDefault (source , PersistentEntityProjector .super ::projectExcerpt );
8673 }
8774
8875 /**
89- * Creates the projection for the given source instance falling back to the given {@link Converter } if no explicit
76+ * Creates the projection for the given source instance falling back to the given {@link Function } if no explicit
9077 * projection is selected.
9178 *
9279 * @param source must not be {@literal null}.
9380 * @param converter must not be {@literal null}.
9481 * @return
9582 */
96- private Object projectWithDefault (Object source , Converter <Object , Object > converter ) {
83+ private Object projectWithDefault (Object source , Function <Object , Object > converter ) {
9784
9885 Assert .notNull (source , "Projection source must not be null!" );
9986 Assert .notNull (converter , "Converter must not be null!" );
10087
10188 if (!StringUtils .hasText (projection )) {
102- return converter .convert (source );
89+ return converter .apply (source );
10390 }
10491
10592 Class <?> projectionType = definitions .getProjectionType (source .getClass (), projection );
106- return projectionType == null ? converter .convert (source ) : factory .createProjection (projectionType , source );
93+ return projectionType == null ? converter .apply (source ) : factory .createProjection (projectionType , source );
10794 }
10895}
0 commit comments