DATAREST-1523 - Delombok production sources.
Hacking.
This commit is contained in:
@@ -15,13 +15,9 @@
|
||||
*/
|
||||
package org.springframework.data.rest.core.config;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Value;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
@@ -56,6 +52,7 @@ class EntityLookupConfiguration implements EntityLookupRegistrar {
|
||||
Converter<T, ID> converter, Lookup<R, ID> lookup) {
|
||||
|
||||
new MappingBuilder<T, ID, R>(repositoryType).withIdMapping(converter).withLookup(lookup);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -65,7 +62,9 @@ class EntityLookupConfiguration implements EntityLookupRegistrar {
|
||||
*/
|
||||
@Override
|
||||
public <T, ID, R extends Repository<T, ?>> IdMappingRegistrar<T, R> forLookupRepository(Class<R> type) {
|
||||
|
||||
this.lookupTypes.add(AbstractRepositoryMetadata.getMetadata(type).getDomainType());
|
||||
|
||||
return forRepository(type);
|
||||
}
|
||||
|
||||
@@ -87,6 +86,7 @@ class EntityLookupConfiguration implements EntityLookupRegistrar {
|
||||
Converter<T, ID> identifierMapping, Lookup<R, ID> lookup) {
|
||||
|
||||
this.lookupTypes.add(AbstractRepositoryMetadata.getMetadata(type).getDomainType());
|
||||
|
||||
return forRepository(type, identifierMapping, lookup);
|
||||
}
|
||||
|
||||
@@ -95,13 +95,24 @@ class EntityLookupConfiguration implements EntityLookupRegistrar {
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
private class MappingBuilder<T, ID, R extends Repository<T, ?>>
|
||||
implements LookupRegistrar<T, ID, R>, IdMappingRegistrar<T, R> {
|
||||
|
||||
private @NonNull final Class<R> repositoryType;
|
||||
private final Class<R> repositoryType;
|
||||
private Converter<T, ID> idMapping;
|
||||
|
||||
/**
|
||||
* Creates a new {@link MappingBuilder} for the given repository type.
|
||||
*
|
||||
* @param type must not be {@literal null}.
|
||||
*/
|
||||
public MappingBuilder(Class<R> type) {
|
||||
|
||||
Assert.notNull(type, "Repository type must not be null!");
|
||||
|
||||
this.repositoryType = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link MappingBuilder} using the given repository type and identifier mapping.
|
||||
*
|
||||
@@ -109,11 +120,8 @@ class EntityLookupConfiguration implements EntityLookupRegistrar {
|
||||
* @param mapping must not be {@literal null}.
|
||||
*/
|
||||
private MappingBuilder(Class<R> repositoryType, Converter<T, ID> mapping) {
|
||||
|
||||
this(repositoryType);
|
||||
|
||||
Assert.notNull(mapping, "Converter must not be null!");
|
||||
|
||||
this.idMapping = mapping;
|
||||
}
|
||||
|
||||
@@ -152,8 +160,8 @@ class EntityLookupConfiguration implements EntityLookupRegistrar {
|
||||
|
||||
Assert.notNull(repositories, "Repositories must not be null!");
|
||||
|
||||
return lookupInformation.stream()//
|
||||
.map(it -> new RepositoriesEntityLookup<>(repositories, it))//
|
||||
return lookupInformation.stream() //
|
||||
.map(it -> new RepositoriesEntityLookup<>(repositories, it)) //
|
||||
.collect(StreamUtils.toUnmodifiableList());
|
||||
}
|
||||
|
||||
@@ -171,7 +179,7 @@ class EntityLookupConfiguration implements EntityLookupRegistrar {
|
||||
private final LookupInformation<Object, Object, Repository<? extends T, ?>> lookupInfo;
|
||||
private final Repository<? extends T, ?> repository;
|
||||
private final Class<?> domainType;
|
||||
private final @Getter Optional<String> lookupProperty;
|
||||
private final Optional<String> lookupProperty;
|
||||
|
||||
/**
|
||||
* Creates a new {@link RepositoriesEntityLookup} for the given {@link Repositories} and {@link LookupInformation}.
|
||||
@@ -182,24 +190,21 @@ class EntityLookupConfiguration implements EntityLookupRegistrar {
|
||||
@SuppressWarnings("unchecked")
|
||||
public RepositoriesEntityLookup(Repositories repositories,
|
||||
LookupInformation<Object, Object, Repository<? extends T, ?>> lookupInformation) {
|
||||
|
||||
Assert.notNull(repositories, "Repositories must not be null!");
|
||||
Assert.notNull(lookupInformation, "LookupInformation must not be null!");
|
||||
|
||||
RepositoryInformation information = repositories.getRepositoryInformation(lookupInformation.repositoryType)//
|
||||
.orElseThrow(() -> new IllegalStateException(
|
||||
"No repository found for type " + lookupInformation.repositoryType.getName() + "!"));
|
||||
|
||||
RepositoryInformation information = //
|
||||
repositories.getRepositoryInformation(lookupInformation.repositoryType)
|
||||
.orElseThrow(() -> new IllegalStateException(
|
||||
"No repository found for type " + lookupInformation.repositoryType.getName() + "!"));
|
||||
this.domainType = information.getDomainType();
|
||||
this.lookupInfo = lookupInformation;
|
||||
this.repository = (Repository<? extends T, ?>) repositories.getRepositoryFor(information.getDomainType())//
|
||||
.orElseThrow(() -> new IllegalStateException(
|
||||
"No repository found for type " + information.getDomainType().getName() + "!"));
|
||||
|
||||
this.lookupProperty = Optional.of(domainType) //
|
||||
.flatMap(it -> MethodInvocationRecorder.forProxyOf(it) //
|
||||
.record(lookupInfo.identifierMapping::convert) //
|
||||
.getPropertyPath());
|
||||
this.repository = (Repository<? extends T, ?>) //
|
||||
repositories.getRepositoryFor(information.getDomainType()).orElseThrow(() -> new IllegalStateException(
|
||||
"No repository found for type " + information.getDomainType().getName() + "!"));
|
||||
this.lookupProperty = //
|
||||
Optional.of(domainType).flatMap(it -> //
|
||||
//
|
||||
MethodInvocationRecorder.forProxyOf(it).record(lookupInfo.identifierMapping::convert).getPropertyPath());
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -232,13 +237,86 @@ class EntityLookupConfiguration implements EntityLookupRegistrar {
|
||||
public boolean supports(Class<?> delimiter) {
|
||||
return domainType.isAssignableFrom(delimiter);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.rest.core.support.EntityLookup#getLookupProperty()
|
||||
*/
|
||||
public Optional<String> getLookupProperty() {
|
||||
return this.lookupProperty;
|
||||
}
|
||||
}
|
||||
|
||||
@Value
|
||||
private static class LookupInformation<T, ID, R extends Repository<? extends T, ?>> {
|
||||
private static final class LookupInformation<T, ID, R extends Repository<? extends T, ?>> {
|
||||
|
||||
private final Class<R> repositoryType;
|
||||
private final Converter<T, ID> identifierMapping;
|
||||
private final Lookup<R, ID> lookup;
|
||||
|
||||
public LookupInformation(Class<R> repositoryType, Converter<T, ID> identifierMapping,
|
||||
Lookup<R, ID> lookup) {
|
||||
|
||||
Assert.notNull(repositoryType, "Repository type must not be null!");
|
||||
Assert.notNull(identifierMapping, "Identifier mapping must not be null!");
|
||||
Assert.notNull(lookup, "Lookup must not be null!");
|
||||
|
||||
this.repositoryType = repositoryType;
|
||||
this.identifierMapping = identifierMapping;
|
||||
this.lookup = lookup;
|
||||
}
|
||||
|
||||
public Class<R> getRepositoryType() {
|
||||
return this.repositoryType;
|
||||
}
|
||||
|
||||
public Converter<T, ID> getIdentifierMapping() {
|
||||
return this.identifierMapping;
|
||||
}
|
||||
|
||||
public Lookup<R, ID> getLookup() {
|
||||
return this.lookup;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(final java.lang.Object o) {
|
||||
|
||||
if (o == this) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(o instanceof EntityLookupConfiguration.LookupInformation)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
LookupInformation<?, ?, ?> that = (LookupInformation<?, ?, ?>) o;
|
||||
|
||||
return Objects.equals(getRepositoryType(), that.getRepositoryType()) //
|
||||
&& Objects.equals(getIdentifierMapping(), that.getIdentifierMapping()) //
|
||||
&& Objects.equals(getLookup(), that.getLookup());
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* (non-Javadoc)
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(getRepositoryType(), getIdentifierMapping(), getLookup());
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public java.lang.String toString() {
|
||||
return "EntityLookupConfiguration.LookupInformation(repositoryType=" + this.getRepositoryType()
|
||||
+ ", identifierMapping=" + this.getIdentifierMapping() + ", lookup=" + this.getLookup() + ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,14 +15,10 @@
|
||||
*/
|
||||
package org.springframework.data.rest.core.config;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Value;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.core.annotation.AnnotationUtils;
|
||||
@@ -80,6 +76,7 @@ public class ProjectionDefinitionConfiguration implements ProjectionDefinitions
|
||||
public ProjectionDefinitionConfiguration addProjection(Class<?> projectionType) {
|
||||
|
||||
Assert.notNull(projectionType, "Projection type must not be null!");
|
||||
|
||||
Projection annotation = AnnotationUtils.findAnnotation(projectionType, Projection.class);
|
||||
|
||||
if (annotation == null) {
|
||||
@@ -89,7 +86,8 @@ public class ProjectionDefinitionConfiguration implements ProjectionDefinitions
|
||||
String name = annotation.name();
|
||||
Class<?>[] sourceTypes = annotation.types();
|
||||
|
||||
return StringUtils.hasText(name) ? addProjection(projectionType, name, sourceTypes)
|
||||
return StringUtils.hasText(name) //
|
||||
? addProjection(projectionType, name, sourceTypes) //
|
||||
: addProjection(projectionType, sourceTypes);
|
||||
}
|
||||
|
||||
@@ -104,6 +102,7 @@ public class ProjectionDefinitionConfiguration implements ProjectionDefinitions
|
||||
public ProjectionDefinitionConfiguration addProjection(Class<?> projectionType, Class<?>... sourceTypes) {
|
||||
|
||||
Assert.notNull(projectionType, "Projection type must not be null!");
|
||||
|
||||
return addProjection(projectionType, StringUtils.uncapitalize(projectionType.getSimpleName()), sourceTypes);
|
||||
}
|
||||
|
||||
@@ -146,6 +145,7 @@ public class ProjectionDefinitionConfiguration implements ProjectionDefinitions
|
||||
public boolean hasProjectionFor(Class<?> sourceType) {
|
||||
|
||||
for (ProjectionDefinition definition : projectionDefinitions) {
|
||||
|
||||
if (definition.sourceType.isAssignableFrom(sourceType)) {
|
||||
return true;
|
||||
}
|
||||
@@ -194,12 +194,21 @@ public class ProjectionDefinitionConfiguration implements ProjectionDefinitions
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@Value
|
||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
static final class ProjectionDefinition {
|
||||
|
||||
private final @NonNull Class<?> sourceType, targetType;
|
||||
private final @NonNull String name;
|
||||
private final Class<?> sourceType, targetType;
|
||||
private final String name;
|
||||
|
||||
private ProjectionDefinition(Class<?> sourceType, Class<?> targetType, String name) {
|
||||
|
||||
Assert.notNull(sourceType, "Source type must not be null!");
|
||||
Assert.notNull(targetType, "Target type must not be null!");
|
||||
Assert.notNull(name, "Name must not be null!");
|
||||
|
||||
this.sourceType = sourceType;
|
||||
this.targetType = targetType;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link ProjectionDefinitionKey} for the given source type and name;
|
||||
@@ -214,5 +223,58 @@ public class ProjectionDefinitionConfiguration implements ProjectionDefinitions
|
||||
|
||||
return new ProjectionDefinition(sourceType, targetType, name);
|
||||
}
|
||||
|
||||
public Class<?> getSourceType() {
|
||||
return this.sourceType;
|
||||
}
|
||||
|
||||
public Class<?> getTargetType() {
|
||||
return this.targetType;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
|
||||
if (o == this) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(o instanceof ProjectionDefinitionConfiguration.ProjectionDefinition)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ProjectionDefinition that = (ProjectionDefinitionConfiguration.ProjectionDefinition) o;
|
||||
|
||||
return Objects.equals(getSourceType(), that.getSourceType()) //
|
||||
&& Objects.equals(getTargetType(), that.getTargetType()) //
|
||||
&& Objects.equals(getName(), that.getName());
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(getSourceType(), getTargetType(), getName());
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public java.lang.String toString() {
|
||||
return "ProjectionDefinitionConfiguration.ProjectionDefinition(sourceType=" + this.getSourceType()
|
||||
+ ", targetType=" + this.getTargetType() + ", name=" + this.getName() + ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,10 +15,6 @@
|
||||
*/
|
||||
package org.springframework.data.rest.core.config;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -74,13 +70,12 @@ public class RepositoryRestConfiguration {
|
||||
/**
|
||||
* The {@link RelProvider} to be used to calculate the link relation defaults for repositories.
|
||||
*/
|
||||
private @Getter @Setter @NonNull LinkRelationProvider relProvider = new EvoInflectorLinkRelationProvider();
|
||||
|
||||
private LinkRelationProvider relProvider = new EvoInflectorLinkRelationProvider();
|
||||
private final ProjectionDefinitionConfiguration projectionConfiguration;
|
||||
private final MetadataConfiguration metadataConfiguration;
|
||||
private final EntityLookupConfiguration entityLookupConfiguration;
|
||||
private final @Getter ExposureConfiguration exposureConfiguration;
|
||||
|
||||
private final ExposureConfiguration exposureConfiguration;
|
||||
private final EnumTranslationConfiguration enumTranslationConfiguration;
|
||||
private boolean enableEnumTranslation = false;
|
||||
|
||||
@@ -667,4 +662,25 @@ public class RepositoryRestConfiguration {
|
||||
public boolean isLookupType(Class<?> type) {
|
||||
return this.entityLookupConfiguration.isLookupType(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* The {@link RelProvider} to be used to calculate the link relation defaults for repositories.
|
||||
*/
|
||||
public LinkRelationProvider getRelProvider() {
|
||||
return this.relProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* The {@link RelProvider} to be used to calculate the link relation defaults for repositories.
|
||||
*/
|
||||
public void setRelProvider(LinkRelationProvider relProvider) {
|
||||
|
||||
Assert.notNull(relProvider, "LinkRelationProvider must not be null!");
|
||||
|
||||
this.relProvider = relProvider;
|
||||
}
|
||||
|
||||
public ExposureConfiguration getExposureConfiguration() {
|
||||
return this.exposureConfiguration;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,15 +15,12 @@
|
||||
*/
|
||||
package org.springframework.data.rest.core.event;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -36,6 +33,7 @@ import org.springframework.core.annotation.AnnotationAwareOrderComparator;
|
||||
import org.springframework.core.annotation.AnnotationUtils;
|
||||
import org.springframework.data.rest.core.annotation.*;
|
||||
import org.springframework.data.util.ProxyUtils;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
@@ -175,18 +173,27 @@ public class AnnotatedEventHandlerInvoker implements ApplicationListener<Reposit
|
||||
handlerMethods.put(eventType, events);
|
||||
}
|
||||
|
||||
@ToString
|
||||
@EqualsAndHashCode
|
||||
@RequiredArgsConstructor
|
||||
static class EventHandlerMethod implements Comparable<EventHandlerMethod> {
|
||||
|
||||
final Class<?> targetType;
|
||||
final Method method;
|
||||
final Object handler;
|
||||
|
||||
public EventHandlerMethod(Class<?> targetType, Method method, Object handler) {
|
||||
|
||||
Assert.notNull(targetType, "Target type must not be null!");
|
||||
Assert.notNull(method, "Method must not be null!");
|
||||
Assert.notNull(handler, "Handler must not be null!");
|
||||
|
||||
this.targetType = targetType;
|
||||
this.method = method;
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
public static EventHandlerMethod of(Class<?> targetType, Object handler, Method method) {
|
||||
|
||||
ReflectionUtils.makeAccessible(method);
|
||||
|
||||
return new EventHandlerMethod(targetType, method, handler);
|
||||
}
|
||||
|
||||
@@ -198,5 +205,46 @@ public class AnnotatedEventHandlerInvoker implements ApplicationListener<Reposit
|
||||
public int compareTo(EventHandlerMethod o) {
|
||||
return AnnotationAwareOrderComparator.INSTANCE.compare(this.method, o.method);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(final java.lang.Object o) {
|
||||
|
||||
if (o == this) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(o instanceof EventHandlerMethod)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
EventHandlerMethod other = (AnnotatedEventHandlerInvoker.EventHandlerMethod) o;
|
||||
|
||||
return Objects.equals(targetType, other.targetType) //
|
||||
&& Objects.equals(method, other.method) //
|
||||
&& Objects.equals(handler, other.handler);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(targetType, method, handler);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public java.lang.String toString() {
|
||||
return "AnnotatedEventHandlerInvoker.EventHandlerMethod(targetType=" + this.targetType + ", method=" + this.method
|
||||
+ ", handler=" + this.handler + ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,9 +15,6 @@
|
||||
*/
|
||||
package org.springframework.data.rest.core.mapping;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
@@ -34,7 +31,6 @@ import org.springframework.util.Assert;
|
||||
* @author Oliver Gierke
|
||||
* @since 3.1
|
||||
*/
|
||||
@RequiredArgsConstructor(staticName = "of", access = AccessLevel.PACKAGE)
|
||||
public class ConfigurableHttpMethods implements HttpMethods {
|
||||
|
||||
public static final ConfigurableHttpMethods NONE = ConfigurableHttpMethods.of();
|
||||
@@ -42,6 +38,17 @@ public class ConfigurableHttpMethods implements HttpMethods {
|
||||
|
||||
private final Collection<HttpMethod> methods;
|
||||
|
||||
private ConfigurableHttpMethods(Collection<HttpMethod> methods) {
|
||||
|
||||
Assert.notNull(methods, "HttpMethods must not be null!");
|
||||
|
||||
this.methods = methods;
|
||||
}
|
||||
|
||||
static ConfigurableHttpMethods of(Collection<HttpMethod> methods) {
|
||||
return new ConfigurableHttpMethods(methods);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link ConfigurableHttpMethods} of the given {@link HttpMethod}s.
|
||||
*
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Generated by delombok at Tue Aug 11 12:16:38 CEST 2020
|
||||
/*
|
||||
* Copyright 2018-2020 the original author or authors.
|
||||
*
|
||||
@@ -15,27 +16,36 @@
|
||||
*/
|
||||
package org.springframework.data.rest.core.mapping;
|
||||
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import org.springframework.data.mapping.PersistentProperty;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Adapter for a {@link SupportedHttpMethods} instance that applies settings made through {@link ExposureConfiguration}
|
||||
* to the calculated {@link ConfigurableHttpMethods}
|
||||
*
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
* @see ExposureConfiguration
|
||||
* @since 3.1
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
public class ConfigurationApplyingSupportedHttpMethodsAdapter implements SupportedHttpMethods {
|
||||
class ConfigurationApplyingSupportedHttpMethodsAdapter implements SupportedHttpMethods {
|
||||
|
||||
private final @NonNull ExposureConfiguration configuration;
|
||||
private final @NonNull ResourceMetadata resourceMetadata;
|
||||
private final @NonNull SupportedHttpMethods delegate;
|
||||
private final ExposureConfiguration configuration;
|
||||
private final ResourceMetadata resourceMetadata;
|
||||
private final SupportedHttpMethods delegate;
|
||||
|
||||
/*
|
||||
ConfigurationApplyingSupportedHttpMethodsAdapter(ExposureConfiguration configuration,
|
||||
ResourceMetadata resourceMetadata, SupportedHttpMethods delegate) {
|
||||
|
||||
Assert.notNull(configuration, "Configuration must not be null!");
|
||||
Assert.notNull(resourceMetadata, "ResourceMetadata must not be null!");
|
||||
Assert.notNull(delegate, "SupportedHttpMethods must not be null!");
|
||||
|
||||
this.configuration = configuration;
|
||||
this.resourceMetadata = resourceMetadata;
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.rest.core.mapping.SupportedHttpMethods#getMethodsFor(org.springframework.data.rest.core.mapping.ResourceType)
|
||||
*/
|
||||
@@ -47,7 +57,7 @@ public class ConfigurationApplyingSupportedHttpMethodsAdapter implements Support
|
||||
return configuration.filter(ConfigurableHttpMethods.of(methods), type, resourceMetadata);
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.rest.core.mapping.SupportedHttpMethods#getMethodsFor(org.springframework.data.mapping.PersistentProperty)
|
||||
*/
|
||||
@@ -66,7 +76,7 @@ public class ConfigurationApplyingSupportedHttpMethodsAdapter implements Support
|
||||
return configuration.filter(methods, PropertyAwareResourceMapping.class.cast(mapping));
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.rest.core.mapping.SupportedHttpMethods#allowsPutForCreation()
|
||||
*/
|
||||
|
||||
@@ -17,8 +17,6 @@ package org.springframework.data.rest.core.mapping;
|
||||
|
||||
import static org.springframework.http.HttpMethod.*;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.springframework.http.HttpMethod;
|
||||
@@ -28,7 +26,7 @@ import org.springframework.util.Assert;
|
||||
* Configuration type to register filters customizing the HTTP methods supported. By default, filters registered are
|
||||
* applied globally. Domain type specific filters can be registered via {@link #forDomainType(Class)}. Useful global
|
||||
* shortcuts like {@link #disablePutOnItemResources()} do exist as well.
|
||||
*
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
* @see #forDomainType(Class)
|
||||
* @since 3.1
|
||||
@@ -92,7 +90,7 @@ public class ExposureConfiguration implements ExposureConfigurer {
|
||||
* {@link AggregateResourceHttpMethodsFilter} and {@link AssociationResourceHttpMethodsFilter}s which means the
|
||||
* configured filters will only be invoked for aggregates of the given type and properties owned by that type
|
||||
* respectively.
|
||||
*
|
||||
*
|
||||
* @param type must not be {@literal null}.
|
||||
* @return
|
||||
*/
|
||||
@@ -104,7 +102,7 @@ public class ExposureConfiguration implements ExposureConfigurer {
|
||||
|
||||
/**
|
||||
* Disables the support for {@link HttpMethod#PUT} for item resources.
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public ExposureConfiguration disablePutOnItemResources() {
|
||||
@@ -115,7 +113,7 @@ public class ExposureConfiguration implements ExposureConfigurer {
|
||||
|
||||
/**
|
||||
* Disables the support for {@link HttpMethod#PATCH} for item resources.
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public ExposureConfiguration disablePatchOnItemResources() {
|
||||
@@ -127,7 +125,7 @@ public class ExposureConfiguration implements ExposureConfigurer {
|
||||
/**
|
||||
* Returns whether PUT requests can be used to create new instances for the type backing the given
|
||||
* {@link ResourceMetadata}.
|
||||
*
|
||||
*
|
||||
* @param metadata must not be {@literal null}.
|
||||
* @return
|
||||
*/
|
||||
@@ -140,7 +138,7 @@ public class ExposureConfiguration implements ExposureConfigurer {
|
||||
|
||||
/**
|
||||
* Returns whether PUT requests can be used to create new instances of the given domain type.
|
||||
*
|
||||
*
|
||||
* @param metadata must not be {@literal null}.
|
||||
* @return
|
||||
*/
|
||||
@@ -182,11 +180,17 @@ public class ExposureConfiguration implements ExposureConfigurer {
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
private class TypeBasedExposureConfigurer implements ExposureConfigurer {
|
||||
|
||||
private final Class<?> type;
|
||||
|
||||
public TypeBasedExposureConfigurer(Class<?> type) {
|
||||
|
||||
Assert.notNull(type, " must not be null!");
|
||||
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.rest.core.mapping.ExposureConfigurer#withCollectionExposure(org.springframework.data.rest.core.mapping.ExposureConfigurer.AggregateResourceHttpMethodsFilter)
|
||||
@@ -211,7 +215,7 @@ public class ExposureConfiguration implements ExposureConfigurer {
|
||||
return this;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.rest.core.mapping.ExposureConfiguration.ExposureConfigurer#withAssociationExposure(java.util.function.BiFunction)
|
||||
*/
|
||||
@@ -229,7 +233,7 @@ public class ExposureConfiguration implements ExposureConfigurer {
|
||||
return this;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.rest.core.mapping.ExposureConfigurer#disableCreationViaPut()
|
||||
*/
|
||||
|
||||
@@ -15,9 +15,6 @@
|
||||
*/
|
||||
package org.springframework.data.rest.core.support;
|
||||
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
@@ -75,11 +72,19 @@ public class UnwrappingRepositoryInvokerFactory implements RepositoryInvokerFact
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
private static class UnwrappingRepositoryInvoker implements RepositoryInvoker {
|
||||
|
||||
private final @NonNull RepositoryInvoker delegate;
|
||||
private final @NonNull Optional<EntityLookup<?>> lookup;
|
||||
private final RepositoryInvoker delegate;
|
||||
private final Optional<EntityLookup<?>> lookup;
|
||||
|
||||
public UnwrappingRepositoryInvoker(RepositoryInvoker delegate, Optional<EntityLookup<?>> lookup) {
|
||||
|
||||
Assert.notNull(delegate, "Delegate RepositoryInvoker must not be null!");
|
||||
Assert.notNull(lookup, "EntityLookup must not be null!");
|
||||
|
||||
this.delegate = delegate;
|
||||
this.lookup = lookup;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
*/
|
||||
package org.springframework.data.rest.core.util;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
@@ -29,11 +27,14 @@ import org.springframework.plugin.core.PluginRegistry;
|
||||
* @deprecated since 3.2, for removal 3.3.
|
||||
*/
|
||||
@Deprecated
|
||||
@RequiredArgsConstructor
|
||||
public class Java8PluginRegistry<T extends Plugin<S>, S> {
|
||||
|
||||
private final PluginRegistry<T, S> registry;
|
||||
|
||||
public Java8PluginRegistry(PluginRegistry<T, S> registry) {
|
||||
this.registry = registry;
|
||||
}
|
||||
|
||||
public static <T extends Plugin<S>, S> Java8PluginRegistry<T, S> of(List<? extends T> plugins) {
|
||||
return Java8PluginRegistry.of(PluginRegistry.of(plugins));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user