DATACMNS-1726 - Delombok source files.

This commit is contained in:
Mark Paluch
2020-05-14 15:46:03 +02:00
parent 302fa6335f
commit 4be5aae181
99 changed files with 3052 additions and 715 deletions

View File

@@ -17,8 +17,6 @@ package org.springframework.data.domain;
import java.io.Serializable;
import org.springframework.lang.Nullable;
/**
* Abstract Java Bean implementation of {@code Pageable}.
*
@@ -134,7 +132,7 @@ public abstract class AbstractPageRequest implements Pageable, Serializable {
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(@Nullable Object obj) {
public boolean equals(Object obj) {
if (this == obj) {
return true;

View File

@@ -15,8 +15,6 @@
*/
package org.springframework.data.domain;
import lombok.Getter;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
@@ -25,7 +23,6 @@ import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
/**
@@ -40,7 +37,7 @@ abstract class Chunk<T> implements Slice<T>, Serializable {
private static final long serialVersionUID = 867755909294344406L;
private final List<T> content = new ArrayList<>();
private final @Getter Pageable pageable;
private final Pageable pageable;
/**
* Creates a new {@link Chunk} with the given content and the given governing {@link Pageable}.
@@ -137,6 +134,15 @@ abstract class Chunk<T> implements Slice<T>, Serializable {
return Collections.unmodifiableList(content);
}
/*
* (non-Javadoc)
* @see org.springframework.data.domain.Slice#getPageable()
*/
@Override
public Pageable getPageable() {
return pageable;
}
/*
* (non-Javadoc)
* @see org.springframework.data.domain.Slice#getSort()
@@ -172,7 +178,7 @@ abstract class Chunk<T> implements Slice<T>, Serializable {
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(@Nullable Object obj) {
public boolean equals(Object obj) {
if (this == obj) {
return true;

View File

@@ -15,11 +15,6 @@
*/
package org.springframework.data.domain;
import lombok.AccessLevel;
import lombok.EqualsAndHashCode;
import lombok.RequiredArgsConstructor;
import lombok.experimental.FieldDefaults;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.Map;
@@ -29,6 +24,7 @@ import java.util.function.Function;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
/**
* Specification for property path matching to use in query by example (QBE). An {@link ExampleMatcher} can be created
@@ -282,7 +278,6 @@ public interface ExampleMatcher {
*
* @author Mark Paluch
*/
@EqualsAndHashCode
class GenericPropertyMatcher {
@Nullable StringMatcher stringMatcher = null;
@@ -440,6 +435,49 @@ public interface ExampleMatcher {
this.valueTransformer = propertyValueTransformer;
return this;
}
protected boolean canEqual(final Object other) {
return other instanceof GenericPropertyMatcher;
}
/*
* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof GenericPropertyMatcher)) {
return false;
}
GenericPropertyMatcher that = (GenericPropertyMatcher) o;
if (stringMatcher != that.stringMatcher)
return false;
if (!ObjectUtils.nullSafeEquals(ignoreCase, that.ignoreCase)) {
return false;
}
return ObjectUtils.nullSafeEquals(valueTransformer, that.valueTransformer);
}
/*
* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
int result = ObjectUtils.nullSafeHashCode(stringMatcher);
result = 31 * result + ObjectUtils.nullSafeHashCode(ignoreCase);
result = 31 * result + ObjectUtils.nullSafeHashCode(valueTransformer);
return result;
}
}
/**
@@ -589,15 +627,12 @@ public interface ExampleMatcher {
* @author Mark Paluch
* @since 1.12
*/
@FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE)
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
@EqualsAndHashCode
class PropertySpecifier {
String path;
@Nullable StringMatcher stringMatcher;
@Nullable Boolean ignoreCase;
PropertyValueTransformer valueTransformer;
private final String path;
private final @Nullable StringMatcher stringMatcher;
private final @Nullable Boolean ignoreCase;
private final PropertyValueTransformer valueTransformer;
/**
* Creates new {@link PropertySpecifier} for given path.
@@ -614,6 +649,14 @@ public interface ExampleMatcher {
this.valueTransformer = NoOpPropertyValueTransformer.INSTANCE;
}
private PropertySpecifier(String path, @Nullable StringMatcher stringMatcher, @Nullable Boolean ignoreCase,
PropertyValueTransformer valueTransformer) {
this.path = path;
this.stringMatcher = stringMatcher;
this.ignoreCase = ignoreCase;
this.valueTransformer = valueTransformer;
}
/**
* Creates a new {@link PropertySpecifier} containing all values from the current instance and sets
* {@link StringMatcher} in the returned instance.
@@ -696,6 +739,55 @@ public interface ExampleMatcher {
public Optional<Object> transformValue(Optional<Object> source) {
return getPropertyValueTransformer().apply(source);
}
/*
* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof PropertySpecifier)) {
return false;
}
PropertySpecifier that = (PropertySpecifier) o;
if (!ObjectUtils.nullSafeEquals(path, that.path)) {
return false;
}
if (stringMatcher != that.stringMatcher)
return false;
if (!ObjectUtils.nullSafeEquals(ignoreCase, that.ignoreCase)) {
return false;
}
return ObjectUtils.nullSafeEquals(valueTransformer, that.valueTransformer);
}
/*
* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
int result = ObjectUtils.nullSafeHashCode(path);
result = 31 * result + ObjectUtils.nullSafeHashCode(stringMatcher);
result = 31 * result + ObjectUtils.nullSafeHashCode(ignoreCase);
result = 31 * result + ObjectUtils.nullSafeHashCode(valueTransformer);
return result;
}
protected boolean canEqual(final Object other) {
return other instanceof PropertySpecifier;
}
}
/**
@@ -705,7 +797,6 @@ public interface ExampleMatcher {
* @author Mark Paluch
* @since 1.12
*/
@EqualsAndHashCode
class PropertySpecifiers {
private final Map<String, PropertySpecifier> propertySpecifiers = new LinkedHashMap<>();
@@ -737,6 +828,34 @@ public interface ExampleMatcher {
public Collection<PropertySpecifier> getSpecifiers() {
return propertySpecifiers.values();
}
/*
* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof PropertySpecifiers)) {
return false;
}
PropertySpecifiers that = (PropertySpecifiers) o;
return ObjectUtils.nullSafeEquals(propertySpecifiers, that.propertySpecifiers);
}
/*
* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
return ObjectUtils.nullSafeHashCode(propertySpecifiers);
}
}
/**

View File

@@ -15,14 +15,10 @@
*/
package org.springframework.data.domain;
import lombok.AccessLevel;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.Value;
import java.util.Optional;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
/**
* Simple value object to work with ranges and boundaries.
@@ -31,21 +27,28 @@ import org.springframework.util.Assert;
* @author Mark Paluch
* @since 1.10
*/
@Value
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
public class Range<T extends Comparable<T>> {
public final class Range<T extends Comparable<T>> {
private final static Range<?> UNBOUNDED = Range.of(Bound.unbounded(), Bound.UNBOUNDED);
/**
* The lower bound of the range.
*/
private final @NonNull Bound<T> lowerBound;
private final Bound<T> lowerBound;
/**
* The upper bound of the range.
*/
private final @NonNull Bound<T> upperBound;
private final Bound<T> upperBound;
private Range(Bound<T> lowerBound, Bound<T> upperBound) {
Assert.notNull(lowerBound, "Lower bound must not be null!");
Assert.notNull(upperBound, "Upper bound must not be null!");
this.lowerBound = lowerBound;
this.upperBound = upperBound;
}
/**
* Returns an unbounded {@link Range}.
@@ -203,6 +206,49 @@ public class Range<T extends Comparable<T>> {
return String.format("%s-%s", lowerBound.toPrefixString(), upperBound.toSuffixString());
}
public Range.Bound<T> getLowerBound() {
return this.lowerBound;
}
public Range.Bound<T> getUpperBound() {
return this.upperBound;
}
/*
* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof Range)) {
return false;
}
Range<?> range = (Range<?>) o;
if (!ObjectUtils.nullSafeEquals(lowerBound, range.lowerBound)) {
return false;
}
return ObjectUtils.nullSafeEquals(upperBound, range.upperBound);
}
/*
* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
int result = ObjectUtils.nullSafeHashCode(lowerBound);
result = 31 * result + ObjectUtils.nullSafeHashCode(upperBound);
return result;
}
/**
* Value object representing a boundary. A boundary can either be {@link #unbounded() unbounded},
* {@link #inclusive(Comparable) including its value} or {@link #exclusive(Comparable) its value}.
@@ -211,9 +257,7 @@ public class Range<T extends Comparable<T>> {
* @since 2.0
* @soundtrack Mohamed Ragab - Excelsior Sessions (March 2017)
*/
@Value
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
public static class Bound<T extends Comparable<T>> {
public static final class Bound<T extends Comparable<T>> {
@SuppressWarnings({ "rawtypes", "unchecked" }) //
private static final Bound<?> UNBOUNDED = new Bound(Optional.empty(), true);
@@ -221,6 +265,11 @@ public class Range<T extends Comparable<T>> {
private final Optional<T> value;
private final boolean inclusive;
private Bound(Optional<T> value, boolean inclusive) {
this.value = value;
this.inclusive = inclusive;
}
/**
* Creates an unbounded {@link Bound}.
*/
@@ -367,6 +416,47 @@ public class Range<T extends Comparable<T>> {
return value.map(Object::toString).orElse("unbounded");
}
public Optional<T> getValue() {
return this.value;
}
public boolean isInclusive() {
return this.inclusive;
}
/*
* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof Bound)) {
return false;
}
Bound<?> bound = (Bound<?>) o;
if (inclusive != bound.inclusive)
return false;
return ObjectUtils.nullSafeEquals(value, bound.value);
}
/*
* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
int result = ObjectUtils.nullSafeHashCode(value);
result = 31 * result + (inclusive ? 1 : 0);
return result;
}
}
/**

View File

@@ -15,9 +15,6 @@
*/
package org.springframework.data.domain;
import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
@@ -44,7 +41,6 @@ import org.springframework.util.StringUtils;
* @author Thomas Darimont
* @author Mark Paluch
*/
@RequiredArgsConstructor(access = AccessLevel.PROTECTED)
public class Sort implements Streamable<org.springframework.data.domain.Sort.Order>, Serializable {
private static final long serialVersionUID = 5737186511678863905L;
@@ -55,6 +51,10 @@ public class Sort implements Streamable<org.springframework.data.domain.Sort.Ord
private final List<Order> orders;
protected Sort(List<Order> orders) {
this.orders = orders;
}
/**
* Creates a new {@link Sort} instance.
*

View File

@@ -15,12 +15,8 @@
*/
package org.springframework.data.domain;
import lombok.AccessLevel;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.ToString;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
/**
* Default implementation of {@link Example} holing instances of {@literal probe} and {@link ExampleMatcher}.
@@ -28,12 +24,68 @@ import lombok.ToString;
* @author Christoph Strobl
* @since 2.0
*/
@ToString
@EqualsAndHashCode
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
@Getter
class TypedExample<T> implements Example<T> {
private final @NonNull T probe;
private final @NonNull ExampleMatcher matcher;
private final T probe;
private final ExampleMatcher matcher;
TypedExample(T probe, ExampleMatcher matcher) {
Assert.notNull(probe, "Probe must not be null");
Assert.notNull(matcher, "ExampleMatcher must not be null");
this.probe = probe;
this.matcher = matcher;
}
public T getProbe() {
return this.probe;
}
public ExampleMatcher getMatcher() {
return this.matcher;
}
/*
* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof TypedExample)) {
return false;
}
TypedExample<?> that = (TypedExample<?>) o;
if (!ObjectUtils.nullSafeEquals(probe, that.probe)) {
return false;
}
return ObjectUtils.nullSafeEquals(matcher, that.matcher);
}
/*
* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
int result = ObjectUtils.nullSafeHashCode(probe);
result = 31 * result + ObjectUtils.nullSafeHashCode(matcher);
return result;
}
/*
* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return "TypedExample{" + "probe=" + probe + ", matcher=" + matcher + '}';
}
}

View File

@@ -15,18 +15,13 @@
*/
package org.springframework.data.domain;
import lombok.AccessLevel;
import lombok.EqualsAndHashCode;
import lombok.RequiredArgsConstructor;
import lombok.ToString;
import lombok.With;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.Set;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
/**
* Default implementation of {@link ExampleMatcher}.
@@ -35,9 +30,6 @@ import org.springframework.util.Assert;
* @author Mark Paluch
* @since 2.0
*/
@ToString
@EqualsAndHashCode
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
class TypedExampleMatcher implements ExampleMatcher {
private final NullHandler nullHandler;
@@ -45,7 +37,7 @@ class TypedExampleMatcher implements ExampleMatcher {
private final PropertySpecifiers propertySpecifiers;
private final Set<String> ignoredPaths;
private final boolean defaultIgnoreCase;
private final @With(AccessLevel.PACKAGE) MatchMode mode;
private final MatchMode mode;
TypedExampleMatcher() {
@@ -53,6 +45,16 @@ class TypedExampleMatcher implements ExampleMatcher {
MatchMode.ALL);
}
private TypedExampleMatcher(NullHandler nullHandler, StringMatcher defaultStringMatcher,
PropertySpecifiers propertySpecifiers, Set<String> ignoredPaths, boolean defaultIgnoreCase, MatchMode mode) {
this.nullHandler = nullHandler;
this.defaultStringMatcher = defaultStringMatcher;
this.propertySpecifiers = propertySpecifiers;
this.ignoredPaths = ignoredPaths;
this.defaultIgnoreCase = defaultIgnoreCase;
this.mode = mode;
}
/*
* (non-Javadoc)
* @see org.springframework.data.domain.ExampleMatcher#withIgnorePaths(java.lang.String...)
@@ -228,6 +230,12 @@ class TypedExampleMatcher implements ExampleMatcher {
return mode;
}
TypedExampleMatcher withMode(MatchMode mode) {
return this.mode == mode ? this
: new TypedExampleMatcher(this.nullHandler, this.defaultStringMatcher, this.propertySpecifiers,
this.ignoredPaths, this.defaultIgnoreCase, mode);
}
private PropertySpecifier getOrCreatePropertySpecifier(String propertyPath, PropertySpecifiers propertySpecifiers) {
if (propertySpecifiers.hasSpecifierForPath(propertyPath)) {
@@ -236,4 +244,71 @@ class TypedExampleMatcher implements ExampleMatcher {
return new PropertySpecifier(propertyPath);
}
/*
* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof TypedExampleMatcher)) {
return false;
}
TypedExampleMatcher that = (TypedExampleMatcher) o;
if (defaultIgnoreCase != that.defaultIgnoreCase) {
return false;
}
if (nullHandler != that.nullHandler) {
return false;
}
if (defaultStringMatcher != that.defaultStringMatcher) {
return false;
}
if (!ObjectUtils.nullSafeEquals(propertySpecifiers, that.propertySpecifiers)) {
return false;
}
if (!ObjectUtils.nullSafeEquals(ignoredPaths, that.ignoredPaths)) {
return false;
}
return mode == that.mode;
}
/*
* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
int result = ObjectUtils.nullSafeHashCode(nullHandler);
result = 31 * result + ObjectUtils.nullSafeHashCode(defaultStringMatcher);
result = 31 * result + ObjectUtils.nullSafeHashCode(propertySpecifiers);
result = 31 * result + ObjectUtils.nullSafeHashCode(ignoredPaths);
result = 31 * result + (defaultIgnoreCase ? 1 : 0);
result = 31 * result + ObjectUtils.nullSafeHashCode(mode);
return result;
}
/*
* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return "TypedExampleMatcher{" + "nullHandler=" + nullHandler + ", defaultStringMatcher=" + defaultStringMatcher
+ ", propertySpecifiers=" + propertySpecifiers + ", ignoredPaths=" + ignoredPaths + ", defaultIgnoreCase="
+ defaultIgnoreCase + ", mode=" + mode + '}';
}
}