DATAJPA-1728 - Delombok source files.

This commit is contained in:
Mark Paluch
2020-05-18 11:02:39 +02:00
parent 7b9f6f903f
commit 6cb79be68a
5 changed files with 106 additions and 21 deletions

View File

@@ -15,10 +15,6 @@
*/
package org.springframework.data.jpa.repository.config;
import static org.springframework.data.jpa.repository.config.BeanDefinitionNames.*;
import lombok.experimental.UtilityClass;
import java.lang.annotation.Annotation;
import java.util.Arrays;
import java.util.Collection;
@@ -56,6 +52,8 @@ import org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcesso
import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;
import static org.springframework.data.jpa.repository.config.BeanDefinitionNames.*;
/**
* JPA specific configuration extension parsing custom attributes from the XML namespace and
* {@link EnableJpaRepositories} annotation. Also, it registers bean definitions for a
@@ -277,7 +275,6 @@ public class JpaRepositoryConfigExtension extends RepositoryConfigurationExtensi
* @author Mark Paluch
* @since 2.1
*/
@UtilityClass
static class LazyJvmAgent {
private static final Set<String> AGENT_CLASSES;
@@ -292,6 +289,8 @@ public class JpaRepositoryConfigExtension extends RepositoryConfigurationExtensi
AGENT_CLASSES = Collections.unmodifiableSet(agentClasses);
}
private LazyJvmAgent() {}
/**
* Determine if any agent is active.
*

View File

@@ -15,8 +15,6 @@
*/
package org.springframework.data.jpa.repository.query;
import lombok.Value;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Stream;
@@ -30,13 +28,20 @@ import org.springframework.lang.Nullable;
* @author Jens Schauder
* @author Oliver Drotbohm
*/
@Value(staticConstructor = "of")
public class EscapeCharacter {
public final class EscapeCharacter {
public static final EscapeCharacter DEFAULT = EscapeCharacter.of('\\');
private static final List<String> TO_REPLACE = Arrays.asList("_", "%");
char escapeCharacter;
private final char escapeCharacter;
private EscapeCharacter(char escapeCharacter) {
this.escapeCharacter = escapeCharacter;
}
public static EscapeCharacter of(char escapeCharacter) {
return new EscapeCharacter(escapeCharacter);
}
/**
* Escapes all special like characters ({@code _}, {@code %}) using the configured escape character.
@@ -52,4 +57,45 @@ public class EscapeCharacter {
: Stream.concat(Stream.of(String.valueOf(escapeCharacter)), TO_REPLACE.stream()) //
.reduce(value, (it, character) -> it.replace(character, this.escapeCharacter + character));
}
public char getEscapeCharacter() {
return this.escapeCharacter;
}
/*
* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof EscapeCharacter)) {
return false;
}
EscapeCharacter that = (EscapeCharacter) o;
return escapeCharacter == that.escapeCharacter;
}
/*
* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
return escapeCharacter;
}
/*
* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return "EscapeCharacter(escapeCharacter=" + this.getEscapeCharacter() + ")";
}
}

View File

@@ -15,8 +15,6 @@
*/
package org.springframework.data.jpa.repository.support;
import lombok.RequiredArgsConstructor;
import org.springframework.data.jpa.repository.query.EscapeCharacter;
import org.springframework.data.spel.spi.EvaluationContextExtension;
@@ -57,11 +55,18 @@ public class JpaEvaluationContextExtension implements EvaluationContextExtension
return root;
}
@RequiredArgsConstructor(staticName = "of")
public static class JpaRootObject {
private final EscapeCharacter character;
private JpaRootObject(EscapeCharacter character) {
this.character = character;
}
public static JpaRootObject of(EscapeCharacter character) {
return new JpaRootObject(character);
}
/**
* Escapes the given source {@link String} for LIKE expressions.
*

View File

@@ -15,10 +15,6 @@
*/
package org.springframework.data.jpa.repository.support;
import static org.springframework.data.querydsl.QuerydslUtils.*;
import lombok.extern.slf4j.Slf4j;
import java.io.Serializable;
import java.lang.reflect.Method;
import java.util.Optional;
@@ -27,6 +23,8 @@ import java.util.stream.Stream;
import javax.persistence.EntityManager;
import javax.persistence.Tuple;
import org.slf4j.Logger;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.dao.InvalidDataAccessApiUsageException;
import org.springframework.data.jpa.projection.CollectionAwareProjectionFactory;
@@ -59,6 +57,8 @@ import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.ReflectionUtils;
import static org.springframework.data.querydsl.QuerydslUtils.*;
/**
* JPA specific generic repository factory.
*
@@ -282,11 +282,13 @@ public class JpaRepositoryFactory extends RepositoryFactorySupport {
* @since 2.0.5
* @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=289141
*/
@Slf4j
private static class EclipseLinkProjectionQueryCreationListener implements QueryCreationListener<AbstractJpaQuery> {
private static final String ECLIPSELINK_PROJECTIONS = "Usage of Spring Data projections detected on persistence provider EclipseLink. Make sure the following query methods declare result columns in exactly the order the accessors are declared in the projecting interface or the order of parameters for DTOs:";
private static final Logger log = org.slf4j.LoggerFactory
.getLogger(EclipseLinkProjectionQueryCreationListener.class);
private final JpaMetamodel metamodel;
private boolean warningLogged = false;

View File

@@ -18,8 +18,6 @@ package org.springframework.data.jpa.util;
import static java.util.Arrays.*;
import static org.springframework.beans.factory.BeanFactoryUtils.*;
import lombok.EqualsAndHashCode;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -38,6 +36,7 @@ import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.jndi.JndiObjectFactoryBean;
import org.springframework.orm.jpa.AbstractEntityManagerFactoryBean;
import org.springframework.util.ClassUtils;
import org.springframework.util.ObjectUtils;
/**
* Utility methods to work with {@link BeanDefinition} instances from {@link BeanFactoryPostProcessor}s.
@@ -170,7 +169,6 @@ public class BeanDefinitionUtils {
* @author Oliver Gierke
* @author Thomas Darimont
*/
@EqualsAndHashCode
public static class EntityManagerFactoryBeanDefinition {
private final String beanName;
@@ -214,5 +212,40 @@ public class BeanDefinitionUtils {
public BeanDefinition getBeanDefinition() {
return beanFactory.getBeanDefinition(beanName);
}
/*
* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof EntityManagerFactoryBeanDefinition)) {
return false;
}
EntityManagerFactoryBeanDefinition that = (EntityManagerFactoryBeanDefinition) o;
if (!ObjectUtils.nullSafeEquals(beanName, that.beanName)) {
return false;
}
return ObjectUtils.nullSafeEquals(beanFactory, that.beanFactory);
}
/*
* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
int result = ObjectUtils.nullSafeHashCode(beanName);
result = 31 * result + ObjectUtils.nullSafeHashCode(beanFactory);
return result;
}
}
}