DATAREST-1213 - Polishing.

Simplified tests and domain code. Reinstantiated accidentally removed method in PersistentEntityResource.

Original pull request: #355.
This commit is contained in:
Oliver Drotbohm
2020-10-26 22:17:23 +01:00
parent e3a88ff9ca
commit 2b0095d89b
7 changed files with 65 additions and 84 deletions

View File

@@ -60,7 +60,7 @@ public class HttpHeadersPreparer {
public HttpHeaders prepareHeaders(Optional<PersistentEntityResource> resource) {
return resource//
.map(it -> prepareHeaders(it.getPersistentEntity(), it.getTargetEntity()))//
.map(it -> prepareHeaders(it.getPersistentEntity(), it.getTarget()))//
.orElseGet(() -> new HttpHeaders());
}

View File

@@ -91,17 +91,19 @@ public class PersistentEntityResource extends EntityModel<Object> {
}
/**
* Returns the underlying instance. If the instance is a dynamic JDK proxy, the proxy target is returned.
* Returns the underlying instance. If the instance is a {@link TargetAware}, the {@link TargetAware}'s target is
* returned.
*
* @return
* @see #getContent()
*/
public Object getTargetEntity() {
public Object getTarget() {
Object content = getContent();
if (content instanceof TargetAware) {
return ((TargetAware) content).getTarget();
} else {
return content;
}
return content instanceof TargetAware
? ((TargetAware) content).getTarget()
: content;
}
/**
@@ -110,7 +112,7 @@ public class PersistentEntityResource extends EntityModel<Object> {
* @return
*/
public PersistentPropertyAccessor<?> getPropertyAccessor() {
return entity.getPropertyAccessor(getTargetEntity());
return entity.getPropertyAccessor(getTarget());
}
/**

View File

@@ -75,7 +75,7 @@ public final class ETag {
Assert.notNull(resource, "PersistentEntityResource must not be null!");
return from(resource.getPersistentEntity(), resource.getTargetEntity());
return from(resource.getPersistentEntity(), resource.getTarget());
}
/**