DATAKV-169 - Polishing.
Fix typo in test method names. Some minor language level cleanups and removal of deprecated API usage. Original pull request: #23.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2016 the original author or authors.
|
||||
* Copyright 2014-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -23,7 +23,7 @@ import org.springframework.data.keyvalue.core.query.KeyValueQuery;
|
||||
/**
|
||||
* Base implementation of {@link KeyValueAdapter} holds {@link QueryEngine} to delegate {@literal find} and
|
||||
* {@literal count} execution to.
|
||||
*
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
*/
|
||||
public abstract class AbstractKeyValueAdapter implements KeyValueAdapter {
|
||||
@@ -39,18 +39,18 @@ public abstract class AbstractKeyValueAdapter implements KeyValueAdapter {
|
||||
|
||||
/**
|
||||
* Creates new {@link AbstractKeyValueAdapter} with using the default query engine.
|
||||
*
|
||||
*
|
||||
* @param engine will be defaulted to {@link SpelQueryEngine} if {@literal null}.
|
||||
*/
|
||||
protected AbstractKeyValueAdapter(QueryEngine<? extends KeyValueAdapter, ?, ?> engine) {
|
||||
|
||||
this.engine = engine != null ? engine : new SpelQueryEngine<KeyValueAdapter>();
|
||||
this.engine = engine != null ? engine : new SpelQueryEngine<>();
|
||||
this.engine.registerAdapter(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the {@link QueryEngine} used.
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected QueryEngine<? extends KeyValueAdapter, ?, ?> getQueryEngine() {
|
||||
@@ -81,7 +81,7 @@ public abstract class AbstractKeyValueAdapter implements KeyValueAdapter {
|
||||
*/
|
||||
@Override
|
||||
public <T> Iterable<T> find(KeyValueQuery<?> query, Serializable keyspace, Class<T> type) {
|
||||
return (Iterable<T>) engine.execute(query, keyspace, type);
|
||||
return engine.execute(query, keyspace, type);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2016 the original author or authors.
|
||||
* Copyright 2014-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -29,7 +29,7 @@ import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Default implementation of {@link IdentifierGenerator} to generate identifiers of types {@link UUID}, String,
|
||||
*
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@@ -37,7 +37,7 @@ enum DefaultIdentifierGenerator implements IdentifierGenerator {
|
||||
|
||||
INSTANCE;
|
||||
|
||||
private final AtomicReference<SecureRandom> secureRandom = new AtomicReference<SecureRandom>(null);
|
||||
private final AtomicReference<SecureRandom> secureRandom = new AtomicReference<>(null);
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 the original author or authors.
|
||||
* Copyright 2015-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -22,9 +22,8 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* Converter capable of transforming a given {@link Iterable} into a collection type.
|
||||
*
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
* @param <T>
|
||||
*/
|
||||
public final class IterableConverter {
|
||||
|
||||
@@ -32,7 +31,7 @@ public final class IterableConverter {
|
||||
|
||||
/**
|
||||
* Converts a given {@link Iterable} into a {@link List}
|
||||
*
|
||||
*
|
||||
* @param source
|
||||
* @return {@link Collections#emptyList()} when source is {@literal null}.
|
||||
*/
|
||||
@@ -47,10 +46,10 @@ public final class IterableConverter {
|
||||
}
|
||||
|
||||
if (source instanceof Collection) {
|
||||
return new ArrayList<T>((Collection<T>) source);
|
||||
return new ArrayList<>((Collection<T>) source);
|
||||
}
|
||||
|
||||
List<T> result = new ArrayList<T>();
|
||||
List<T> result = new ArrayList<>();
|
||||
for (T value : source) {
|
||||
result.add(value);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2015 the original author or authors.
|
||||
* Copyright 2014-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -42,7 +42,7 @@ import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
* Basic implementation of {@link KeyValueOperations}.
|
||||
*
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
* @author Oliver Gierke
|
||||
* @author Thomas Darimont
|
||||
@@ -64,7 +64,7 @@ public class KeyValueTemplate implements KeyValueOperations, ApplicationEventPub
|
||||
/**
|
||||
* Create new {@link KeyValueTemplate} using the given {@link KeyValueAdapter} with a default
|
||||
* {@link KeyValueMappingContext}.
|
||||
*
|
||||
*
|
||||
* @param adapter must not be {@literal null}.
|
||||
*/
|
||||
public KeyValueTemplate(KeyValueAdapter adapter) {
|
||||
@@ -73,7 +73,7 @@ public class KeyValueTemplate implements KeyValueOperations, ApplicationEventPub
|
||||
|
||||
/**
|
||||
* Create new {@link KeyValueTemplate} using the given {@link KeyValueAdapter} and {@link MappingContext}.
|
||||
*
|
||||
*
|
||||
* @param adapter must not be {@literal null}.
|
||||
* @param mappingContext must not be {@literal null}.
|
||||
*/
|
||||
@@ -90,7 +90,7 @@ public class KeyValueTemplate implements KeyValueOperations, ApplicationEventPub
|
||||
|
||||
/**
|
||||
* Set the {@link PersistenceExceptionTranslator} used for converting {@link RuntimeException}.
|
||||
*
|
||||
*
|
||||
* @param exceptionTranslator must not be {@literal null}.
|
||||
*/
|
||||
public void setExceptionTranslator(PersistenceExceptionTranslator exceptionTranslator) {
|
||||
@@ -101,7 +101,7 @@ public class KeyValueTemplate implements KeyValueOperations, ApplicationEventPub
|
||||
|
||||
/**
|
||||
* Define the event types to publish via {@link ApplicationEventPublisher}.
|
||||
*
|
||||
*
|
||||
* @param eventTypesToPublish use {@literal null} or {@link Collections#emptySet()} to stop publishing.
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
@@ -247,7 +247,7 @@ public class KeyValueTemplate implements KeyValueOperations, ApplicationEventPub
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
ArrayList<T> filtered = new ArrayList<T>();
|
||||
ArrayList<T> filtered = new ArrayList<>();
|
||||
for (Object candidate : values) {
|
||||
if (typeCheck(type, candidate)) {
|
||||
filtered.add((T) candidate);
|
||||
@@ -407,7 +407,7 @@ public class KeyValueTemplate implements KeyValueOperations, ApplicationEventPub
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
List<T> filtered = new ArrayList<T>();
|
||||
List<T> filtered = new ArrayList<>();
|
||||
|
||||
for (Object candidate : result) {
|
||||
if (typeCheck(type, candidate)) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2016 the original author or authors.
|
||||
* Copyright 2014-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -30,7 +30,7 @@ import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||
/**
|
||||
* {@link QueryEngine} implementation specific for executing {@link SpelExpression} based {@link KeyValueQuery} against
|
||||
* {@link KeyValueAdapter}.
|
||||
*
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
* @author Oliver Gierke
|
||||
* @param <T>
|
||||
@@ -78,7 +78,7 @@ class SpelQueryEngine<T extends KeyValueAdapter> extends QueryEngine<KeyValueAda
|
||||
|
||||
private static <S> List<S> filterMatchingRange(Iterable<S> source, SpelCriteria criteria, long offset, int rows) {
|
||||
|
||||
List<S> result = new ArrayList<S>();
|
||||
List<S> result = new ArrayList<>();
|
||||
|
||||
boolean compareOffsetAndRows = 0 < offset || 0 <= rows;
|
||||
int remainingRows = rows;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
* Copyright 2014-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,21 +16,21 @@
|
||||
package org.springframework.data.keyvalue.core;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.domain.Sort.Direction;
|
||||
import org.springframework.data.domain.Sort.NullHandling;
|
||||
import org.springframework.data.domain.Sort.Order;
|
||||
import org.springframework.data.keyvalue.core.query.KeyValueQuery;
|
||||
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.comparator.CompoundComparator;
|
||||
|
||||
/**
|
||||
* {@link SortAccessor} implementation capable of creating {@link SpelPropertyComparator}.
|
||||
*
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
* @author Oliver Gierke
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
class SpelSortAccessor implements SortAccessor<Comparator<?>> {
|
||||
|
||||
@@ -53,27 +53,35 @@ class SpelSortAccessor implements SortAccessor<Comparator<?>> {
|
||||
@Override
|
||||
public Comparator<?> resolve(KeyValueQuery<?> query) {
|
||||
|
||||
if (query == null || query.getSort() == null || Sort.unsorted().equals(query.getSort())) {
|
||||
if (query == null || query.getSort() == null || query.getSort().isUnsorted()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
CompoundComparator compoundComperator = new CompoundComparator();
|
||||
Optional<Comparator<?>> comparator = Optional.empty();
|
||||
for (Order order : query.getSort()) {
|
||||
|
||||
SpelPropertyComparator<?> spelSort = new SpelPropertyComparator(order.getProperty(), parser);
|
||||
SpelPropertyComparator<Object> spelSort = new SpelPropertyComparator<>(order.getProperty(), parser);
|
||||
|
||||
if (Direction.DESC.equals(order.getDirection())) {
|
||||
|
||||
spelSort.desc();
|
||||
|
||||
if (order.getNullHandling() != null && !NullHandling.NATIVE.equals(order.getNullHandling())) {
|
||||
spelSort = NullHandling.NULLS_FIRST.equals(order.getNullHandling()) ? spelSort.nullsFirst() : spelSort
|
||||
.nullsLast();
|
||||
spelSort = NullHandling.NULLS_FIRST.equals(order.getNullHandling()) ? spelSort.nullsFirst()
|
||||
: spelSort.nullsLast();
|
||||
}
|
||||
}
|
||||
compoundComperator.addComparator(spelSort);
|
||||
|
||||
if (!comparator.isPresent()) {
|
||||
comparator = Optional.of(spelSort);
|
||||
} else {
|
||||
|
||||
SpelPropertyComparator<Object> spelSortToUse = spelSort;
|
||||
comparator = comparator.map(it -> it.thenComparing(spelSortToUse));
|
||||
}
|
||||
}
|
||||
|
||||
return compoundComperator;
|
||||
return comparator.orElseThrow(
|
||||
() -> new IllegalStateException("No sort definitions have been added to this CompoundComparator to compare"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 the original author or authors.
|
||||
* Copyright 2015-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -23,7 +23,7 @@ import org.springframework.context.ApplicationEvent;
|
||||
* {@link KeyValueEvent} gets published for operations executed by eg.
|
||||
* {@link org.springframework.data.keyvalue.core.KeyValueTemplate}. Use the {@link #getType()} to determine which event
|
||||
* has been emitted.
|
||||
*
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
* @author Thomas Darimont
|
||||
* @param <T>
|
||||
@@ -54,19 +54,19 @@ public class KeyValueEvent<T> extends ApplicationEvent {
|
||||
|
||||
/**
|
||||
* Create new {@link BeforeGetEvent}.
|
||||
*
|
||||
*
|
||||
* @param id
|
||||
* @param keySpace
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
public static <T> BeforeGetEvent<T> beforeGet(Serializable id, String keySpace, Class<T> type) {
|
||||
return new BeforeGetEvent<T>(id, keySpace, type);
|
||||
return new BeforeGetEvent<>(id, keySpace, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create new {@link AfterGetEvent}.
|
||||
*
|
||||
*
|
||||
* @param id
|
||||
* @param keySpace
|
||||
* @param type
|
||||
@@ -74,12 +74,12 @@ public class KeyValueEvent<T> extends ApplicationEvent {
|
||||
* @return
|
||||
*/
|
||||
public static <T> AfterGetEvent<T> afterGet(Serializable id, String keySpace, Class<T> type, T value) {
|
||||
return new AfterGetEvent<T>(id, keySpace, type, value);
|
||||
return new AfterGetEvent<>(id, keySpace, type, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create new {@link BeforeInsertEvent}.
|
||||
*
|
||||
*
|
||||
* @param id
|
||||
* @param keySpace
|
||||
* @param type
|
||||
@@ -87,12 +87,12 @@ public class KeyValueEvent<T> extends ApplicationEvent {
|
||||
* @return
|
||||
*/
|
||||
public static <T> BeforeInsertEvent<T> beforeInsert(Serializable id, String keySpace, Class<? extends T> type, T value) {
|
||||
return new BeforeInsertEvent<T>(id, keySpace, type, value);
|
||||
return new BeforeInsertEvent<>(id, keySpace, type, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create new {@link AfterInsertEvent}.
|
||||
*
|
||||
*
|
||||
* @param id
|
||||
* @param keySpace
|
||||
* @param type
|
||||
@@ -100,12 +100,12 @@ public class KeyValueEvent<T> extends ApplicationEvent {
|
||||
* @return
|
||||
*/
|
||||
public static <T> AfterInsertEvent<T> afterInsert(Serializable id, String keySpace, Class<? extends T> type, T value) {
|
||||
return new AfterInsertEvent<T>(id, keySpace, type, value);
|
||||
return new AfterInsertEvent<>(id, keySpace, type, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create new {@link BeforeUpdateEvent}.
|
||||
*
|
||||
*
|
||||
* @param id
|
||||
* @param keySpace
|
||||
* @param type
|
||||
@@ -113,12 +113,12 @@ public class KeyValueEvent<T> extends ApplicationEvent {
|
||||
* @return
|
||||
*/
|
||||
public static <T> BeforeUpdateEvent<T> beforeUpdate(Serializable id, String keySpace, Class<? extends T> type, T value) {
|
||||
return new BeforeUpdateEvent<T>(id, keySpace, type, value);
|
||||
return new BeforeUpdateEvent<>(id, keySpace, type, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create new {@link AfterUpdateEvent}.
|
||||
*
|
||||
*
|
||||
* @param id
|
||||
* @param keySpace
|
||||
* @param type
|
||||
@@ -128,46 +128,46 @@ public class KeyValueEvent<T> extends ApplicationEvent {
|
||||
*/
|
||||
public static <T> AfterUpdateEvent<T> afterUpdate(Serializable id, String keySpace, Class<? extends T> type,
|
||||
T actualValue, Object previousValue) {
|
||||
return new AfterUpdateEvent<T>(id, keySpace, type, actualValue, previousValue);
|
||||
return new AfterUpdateEvent<>(id, keySpace, type, actualValue, previousValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create new {@link BeforeDropKeySpaceEvent}.
|
||||
*
|
||||
*
|
||||
* @param keySpace
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
public static <T> BeforeDropKeySpaceEvent<T> beforeDropKeySpace(String keySpace, Class<? extends T> type) {
|
||||
return new BeforeDropKeySpaceEvent<T>(keySpace, type);
|
||||
return new BeforeDropKeySpaceEvent<>(keySpace, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create new {@link AfterDropKeySpaceEvent}.
|
||||
*
|
||||
*
|
||||
* @param keySpace
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
public static <T> AfterDropKeySpaceEvent<T> afterDropKeySpace(String keySpace, Class<? extends T> type) {
|
||||
return new AfterDropKeySpaceEvent<T>(keySpace, type);
|
||||
return new AfterDropKeySpaceEvent<>(keySpace, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create new {@link BeforeDeleteEvent}.
|
||||
*
|
||||
*
|
||||
* @param id
|
||||
* @param keySpace
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
public static <T> BeforeDeleteEvent<T> beforeDelete(Serializable id, String keySpace, Class<? extends T> type) {
|
||||
return new BeforeDeleteEvent<T>(id, keySpace, type);
|
||||
return new BeforeDeleteEvent<>(id, keySpace, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create new {@link AfterDeleteEvent}.
|
||||
*
|
||||
*
|
||||
* @param id
|
||||
* @param keySpace
|
||||
* @param type
|
||||
@@ -175,7 +175,7 @@ public class KeyValueEvent<T> extends ApplicationEvent {
|
||||
* @return
|
||||
*/
|
||||
public static <T> AfterDeleteEvent<T> afterDelete(Serializable id, String keySpace, Class<? extends T> type, T value) {
|
||||
return new AfterDeleteEvent<T>(id, keySpace, type, value);
|
||||
return new AfterDeleteEvent<>(id, keySpace, type, value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -209,7 +209,7 @@ public class KeyValueEvent<T> extends ApplicationEvent {
|
||||
|
||||
/**
|
||||
* Get the type of the element the {@link KeyValueEvent} refers to.
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Class<? extends T> getType() {
|
||||
@@ -233,7 +233,7 @@ public class KeyValueEvent<T> extends ApplicationEvent {
|
||||
|
||||
/**
|
||||
* Get the value of the element the {@link KeyValueEvent} refers to. Can be {@literal null}.
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public T getPayload() {
|
||||
@@ -243,7 +243,7 @@ public class KeyValueEvent<T> extends ApplicationEvent {
|
||||
|
||||
/**
|
||||
* {@link KeyValueEvent} raised before loading an object by its {@literal key}.
|
||||
*
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
* @param <T>
|
||||
*/
|
||||
@@ -258,7 +258,7 @@ public class KeyValueEvent<T> extends ApplicationEvent {
|
||||
|
||||
/**
|
||||
* {@link KeyValueEvent} after loading an object by its {@literal key}.
|
||||
*
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
* @param <T>
|
||||
*/
|
||||
@@ -273,7 +273,7 @@ public class KeyValueEvent<T> extends ApplicationEvent {
|
||||
|
||||
/**
|
||||
* {@link KeyValueEvent} before inserting an object by with a given {@literal key}.
|
||||
*
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
* @param <T>
|
||||
*/
|
||||
@@ -288,7 +288,7 @@ public class KeyValueEvent<T> extends ApplicationEvent {
|
||||
|
||||
/**
|
||||
* {@link KeyValueEvent} after inserting an object by with a given {@literal key}.
|
||||
*
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
* @param <T>
|
||||
*/
|
||||
@@ -302,7 +302,7 @@ public class KeyValueEvent<T> extends ApplicationEvent {
|
||||
|
||||
/**
|
||||
* {@link KeyValueEvent} before updating an object by with a given {@literal key}.
|
||||
*
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
* @param <T>
|
||||
*/
|
||||
@@ -316,7 +316,7 @@ public class KeyValueEvent<T> extends ApplicationEvent {
|
||||
|
||||
/**
|
||||
* {@link KeyValueEvent} after updating an object by with a given {@literal key}.
|
||||
*
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
* @param <T>
|
||||
*/
|
||||
@@ -332,7 +332,7 @@ public class KeyValueEvent<T> extends ApplicationEvent {
|
||||
|
||||
/**
|
||||
* Get the value before update. Can be {@literal null}.
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Object before() {
|
||||
@@ -341,7 +341,7 @@ public class KeyValueEvent<T> extends ApplicationEvent {
|
||||
|
||||
/**
|
||||
* Get the current value.
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public T after() {
|
||||
@@ -351,7 +351,7 @@ public class KeyValueEvent<T> extends ApplicationEvent {
|
||||
|
||||
/**
|
||||
* {@link KeyValueEvent} before removing an object by with a given {@literal key}.
|
||||
*
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
* @param <T>
|
||||
*/
|
||||
@@ -365,7 +365,7 @@ public class KeyValueEvent<T> extends ApplicationEvent {
|
||||
|
||||
/**
|
||||
* {@link KeyValueEvent} after removing an object by with a given {@literal key}.
|
||||
*
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
* @param <T>
|
||||
*/
|
||||
@@ -379,7 +379,7 @@ public class KeyValueEvent<T> extends ApplicationEvent {
|
||||
|
||||
/**
|
||||
* {@link KeyValueEvent} before removing all elements in a given {@literal keySpace}.
|
||||
*
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
* @param <T>
|
||||
*/
|
||||
@@ -400,7 +400,7 @@ public class KeyValueEvent<T> extends ApplicationEvent {
|
||||
|
||||
/**
|
||||
* {@link KeyValueEvent} after removing all elements in a given {@literal keySpace}.
|
||||
*
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
* @param <T>
|
||||
*/
|
||||
|
||||
@@ -34,7 +34,7 @@ import org.springframework.util.ObjectUtils;
|
||||
/**
|
||||
* {@link AnnotationBasedKeySpaceResolver} looks up {@link Persistent} and checks for presence of either meta or direct
|
||||
* usage of {@link KeySpace}. If non found it will default the keyspace to {@link Class#getName()}.
|
||||
*
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@@ -142,7 +142,7 @@ enum AnnotationBasedKeySpaceResolver implements KeySpaceResolver {
|
||||
*/
|
||||
public static <T extends Annotation> AnnotationDescriptor<T> findAnnotationDescriptor(Class<?> clazz,
|
||||
Class<T> annotationType) {
|
||||
return findAnnotationDescriptor(clazz, new HashSet<Annotation>(), annotationType);
|
||||
return findAnnotationDescriptor(clazz, new HashSet<>(), annotationType);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -165,7 +165,7 @@ enum AnnotationBasedKeySpaceResolver implements KeySpaceResolver {
|
||||
|
||||
// Declared locally?
|
||||
if (AnnotationUtils.isAnnotationDeclaredLocally(annotationType, clazz)) {
|
||||
return new AnnotationDescriptor<T>(clazz, clazz.getAnnotation(annotationType));
|
||||
return new AnnotationDescriptor<>(clazz, clazz.getAnnotation(annotationType));
|
||||
}
|
||||
|
||||
// Declared on a composed annotation (i.e., as a meta-annotation)?
|
||||
@@ -174,7 +174,7 @@ enum AnnotationBasedKeySpaceResolver implements KeySpaceResolver {
|
||||
AnnotationDescriptor<T> descriptor = findAnnotationDescriptor(composedAnnotation.annotationType(), visited,
|
||||
annotationType);
|
||||
if (descriptor != null) {
|
||||
return new AnnotationDescriptor<T>(clazz, descriptor.getDeclaringClass(), composedAnnotation,
|
||||
return new AnnotationDescriptor<>(clazz, descriptor.getDeclaringClass(), composedAnnotation,
|
||||
descriptor.getAnnotation());
|
||||
}
|
||||
}
|
||||
@@ -218,7 +218,7 @@ enum AnnotationBasedKeySpaceResolver implements KeySpaceResolver {
|
||||
*/
|
||||
public static UntypedAnnotationDescriptor findAnnotationDescriptorForTypes(Class<?> clazz,
|
||||
Class<? extends Annotation>... annotationTypes) {
|
||||
return findAnnotationDescriptorForTypes(clazz, new HashSet<Annotation>(), annotationTypes);
|
||||
return findAnnotationDescriptorForTypes(clazz, new HashSet<>(), annotationTypes);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -301,7 +301,7 @@ enum AnnotationBasedKeySpaceResolver implements KeySpaceResolver {
|
||||
* @Retention(RetentionPolicy.RUNTIME)
|
||||
* public @interface RepositoryTests {
|
||||
* }
|
||||
*
|
||||
*
|
||||
* @RepositoryTests
|
||||
* public class UserRepositoryTests {}
|
||||
* </pre>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
* Copyright 2014-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -24,7 +24,7 @@ import org.springframework.data.mapping.model.SimpleTypeHolder;
|
||||
|
||||
/**
|
||||
* Most trivial implementation of {@link PersistentProperty}.
|
||||
*
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
*/
|
||||
public class KeyValuePersistentProperty<P extends KeyValuePersistentProperty<P>>
|
||||
@@ -41,6 +41,6 @@ public class KeyValuePersistentProperty<P extends KeyValuePersistentProperty<P>>
|
||||
*/
|
||||
@Override
|
||||
protected Association<P> createAssociation() {
|
||||
return new Association<P>((P) this, null);
|
||||
return new Association<>((P) this, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
* Copyright 2014-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -19,11 +19,12 @@ import org.springframework.data.domain.Sort;
|
||||
|
||||
/**
|
||||
* @author Christoph Strobl
|
||||
* @author Mark Paluch
|
||||
* @param <T> Criteria type
|
||||
*/
|
||||
public class KeyValueQuery<T> {
|
||||
|
||||
private Sort sort;
|
||||
private Sort sort = Sort.unsorted();
|
||||
private long offset = -1;
|
||||
private int rows = -1;
|
||||
private T criteria;
|
||||
@@ -35,7 +36,7 @@ public class KeyValueQuery<T> {
|
||||
|
||||
/**
|
||||
* Creates new instance of {@link KeyValueQuery} with given criteria.
|
||||
*
|
||||
*
|
||||
* @param criteria can be {@literal null}.
|
||||
*/
|
||||
public KeyValueQuery(T criteria) {
|
||||
@@ -44,7 +45,7 @@ public class KeyValueQuery<T> {
|
||||
|
||||
/**
|
||||
* Creates new instance of {@link KeyValueQuery} with given {@link Sort}.
|
||||
*
|
||||
*
|
||||
* @param sort can be {@literal null}.
|
||||
*/
|
||||
public KeyValueQuery(Sort sort) {
|
||||
@@ -53,7 +54,7 @@ public class KeyValueQuery<T> {
|
||||
|
||||
/**
|
||||
* Get the criteria object.
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public T getCritieria() {
|
||||
@@ -62,7 +63,7 @@ public class KeyValueQuery<T> {
|
||||
|
||||
/**
|
||||
* Get {@link Sort}.
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Sort getSort() {
|
||||
@@ -71,7 +72,7 @@ public class KeyValueQuery<T> {
|
||||
|
||||
/**
|
||||
* Number of elements to skip.
|
||||
*
|
||||
*
|
||||
* @return negative value if not set.
|
||||
*/
|
||||
public long getOffset() {
|
||||
@@ -80,7 +81,7 @@ public class KeyValueQuery<T> {
|
||||
|
||||
/**
|
||||
* Number of elements to read.
|
||||
*
|
||||
*
|
||||
* @return negative value if not set.
|
||||
*/
|
||||
public int getRows() {
|
||||
@@ -89,7 +90,7 @@ public class KeyValueQuery<T> {
|
||||
|
||||
/**
|
||||
* Set the number of elements to skip.
|
||||
*
|
||||
*
|
||||
* @param offset use negative value for none.
|
||||
*/
|
||||
public void setOffset(long offset) {
|
||||
@@ -98,8 +99,8 @@ public class KeyValueQuery<T> {
|
||||
|
||||
/**
|
||||
* Set the number of elements to read.
|
||||
*
|
||||
* @param offset use negative value for all.
|
||||
*
|
||||
* @param rows use negative value for all.
|
||||
*/
|
||||
public void setRows(int rows) {
|
||||
this.rows = rows;
|
||||
@@ -107,7 +108,7 @@ public class KeyValueQuery<T> {
|
||||
|
||||
/**
|
||||
* Set {@link Sort} to be applied.
|
||||
*
|
||||
*
|
||||
* @param sort
|
||||
*/
|
||||
public void setSort(Sort sort) {
|
||||
@@ -116,7 +117,7 @@ public class KeyValueQuery<T> {
|
||||
|
||||
/**
|
||||
* Add given {@link Sort}.
|
||||
*
|
||||
*
|
||||
* @param sort {@literal null} {@link Sort} will be ignored.
|
||||
* @return
|
||||
*/
|
||||
@@ -127,7 +128,7 @@ public class KeyValueQuery<T> {
|
||||
}
|
||||
|
||||
if (this.sort != null) {
|
||||
this.sort.and(sort);
|
||||
this.sort = this.sort.and(sort);
|
||||
} else {
|
||||
this.sort = sort;
|
||||
}
|
||||
@@ -135,7 +136,7 @@ public class KeyValueQuery<T> {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see KeyValueQuery#setOffset(int)
|
||||
* @see KeyValueQuery#setOffset(long)
|
||||
* @param offset
|
||||
* @return
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2016 the original author or authors.
|
||||
* Copyright 2014-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -41,7 +41,7 @@ import org.springframework.util.ClassUtils;
|
||||
/**
|
||||
* {@link RepositoryQuery} implementation deriving queries from {@link PartTree} using a predefined
|
||||
* {@link AbstractQueryCreator}.
|
||||
*
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
* @author Oliver Gierke
|
||||
* @author Mark Paluch
|
||||
@@ -56,7 +56,7 @@ public class KeyValuePartTreeQuery implements RepositoryQuery {
|
||||
/**
|
||||
* Creates a new {@link KeyValuePartTreeQuery} for the given {@link QueryMethod}, {@link EvaluationContextProvider},
|
||||
* {@link KeyValueOperations} and query creator type.
|
||||
*
|
||||
*
|
||||
* @param queryMethod must not be {@literal null}.
|
||||
* @param evaluationContextProvider must not be {@literal null}.
|
||||
* @param keyValueOperations must not be {@literal null}.
|
||||
@@ -157,7 +157,7 @@ public class KeyValuePartTreeQuery implements RepositoryQuery {
|
||||
query.setRows(instance.getRows());
|
||||
}
|
||||
|
||||
query.setSort(sort == null || Sort.unsorted().equals(sort) ? instance.getSort() : sort);
|
||||
query.setSort(sort == null || sort.isUnsorted() ? instance.getSort() : sort);
|
||||
|
||||
return query;
|
||||
}
|
||||
@@ -179,7 +179,7 @@ public class KeyValuePartTreeQuery implements RepositoryQuery {
|
||||
|
||||
PartTree tree = new PartTree(getQueryMethod().getName(), getQueryMethod().getEntityInformation().getJavaType());
|
||||
|
||||
Constructor<? extends AbstractQueryCreator<?, ?>> constructor = (Constructor<? extends AbstractQueryCreator<?, ?>>) ClassUtils
|
||||
Constructor<? extends AbstractQueryCreator<?, ?>> constructor = ClassUtils
|
||||
.getConstructorIfAvailable(queryCreator, PartTree.class, ParameterAccessor.class);
|
||||
KeyValueQuery<?> query = (KeyValueQuery<?>) BeanUtils.instantiateClass(constructor, tree, accessor).createQuery();
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||
|
||||
/**
|
||||
* {@link AbstractQueryCreator} to create {@link SpelExpression} based {@link KeyValueQuery}s.
|
||||
*
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@@ -44,7 +44,7 @@ public class SpelQueryCreator extends AbstractQueryCreator<KeyValueQuery<SpelExp
|
||||
|
||||
/**
|
||||
* Creates a new {@link SpelQueryCreator} for the given {@link PartTree} and {@link ParameterAccessor}.
|
||||
*
|
||||
*
|
||||
* @param tree must not be {@literal null}.
|
||||
* @param parameters must not be {@literal null}.
|
||||
*/
|
||||
@@ -85,7 +85,7 @@ public class SpelQueryCreator extends AbstractQueryCreator<KeyValueQuery<SpelExp
|
||||
@Override
|
||||
protected KeyValueQuery<SpelExpression> complete(String criteria, Sort sort) {
|
||||
|
||||
KeyValueQuery<SpelExpression> query = new KeyValueQuery<SpelExpression>(this.expression);
|
||||
KeyValueQuery<SpelExpression> query = new KeyValueQuery<>(this.expression);
|
||||
|
||||
if (sort != null) {
|
||||
query.orderBy(sort);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2015 the original author or authors.
|
||||
* Copyright 2014-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -33,7 +33,7 @@ import com.querydsl.core.types.dsl.PathBuilder;
|
||||
|
||||
/**
|
||||
* Utilities for Querydsl usage.
|
||||
*
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
* @author Thomas Darimont
|
||||
* @author Oliver Gierke
|
||||
@@ -46,7 +46,7 @@ abstract class KeyValueQuerydslUtils {
|
||||
|
||||
/**
|
||||
* Transforms a plain {@link Order} into a QueryDsl specific {@link OrderSpecifier}.
|
||||
*
|
||||
*
|
||||
* @param sort
|
||||
* @param builder must not be {@literal null}.
|
||||
* @return empty {@code OrderSpecifier<?>[]} when sort is {@literal null}.
|
||||
@@ -65,7 +65,7 @@ abstract class KeyValueQuerydslUtils {
|
||||
specifiers = ((QSort) sort).getOrderSpecifiers();
|
||||
} else {
|
||||
|
||||
specifiers = new ArrayList<OrderSpecifier<?>>();
|
||||
specifiers = new ArrayList<>();
|
||||
for (Order order : sort) {
|
||||
specifiers.add(toOrderSpecifier(order, builder));
|
||||
}
|
||||
@@ -83,7 +83,7 @@ abstract class KeyValueQuerydslUtils {
|
||||
|
||||
/**
|
||||
* Creates an {@link Expression} for the given {@link Order} property.
|
||||
*
|
||||
*
|
||||
* @param order must not be {@literal null}.
|
||||
* @param builder must not be {@literal null}.
|
||||
* @return
|
||||
@@ -114,7 +114,7 @@ abstract class KeyValueQuerydslUtils {
|
||||
/**
|
||||
* Converts the given {@link org.springframework.data.domain.Sort.NullHandling} to the appropriate Querydsl
|
||||
* {@link NullHandling}.
|
||||
*
|
||||
*
|
||||
* @param nullHandling must not be {@literal null}.
|
||||
* @return
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2016 the original author or authors.
|
||||
* Copyright 2014-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.keyvalue.repository.support;
|
||||
|
||||
import static org.springframework.data.querydsl.QuerydslUtils.*;
|
||||
import static org.springframework.data.querydsl.QuerydslUtils.QUERY_DSL_PRESENT;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Constructor;
|
||||
@@ -48,7 +48,7 @@ import org.springframework.util.ClassUtils;
|
||||
/**
|
||||
* {@link RepositoryFactorySupport} specific of handing
|
||||
* {@link org.springframework.data.keyvalue.repository.KeyValueRepository}.
|
||||
*
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@@ -63,7 +63,7 @@ public class KeyValueRepositoryFactory extends RepositoryFactorySupport {
|
||||
|
||||
/**
|
||||
* Creates a new {@link KeyValueRepositoryFactory} for the given {@link KeyValueOperations}.
|
||||
*
|
||||
*
|
||||
* @param keyValueOperations must not be {@literal null}.
|
||||
*/
|
||||
public KeyValueRepositoryFactory(KeyValueOperations keyValueOperations) {
|
||||
@@ -73,7 +73,7 @@ public class KeyValueRepositoryFactory extends RepositoryFactorySupport {
|
||||
/**
|
||||
* Creates a new {@link KeyValueRepositoryFactory} for the given {@link KeyValueOperations} and
|
||||
* {@link AbstractQueryCreator}-type.
|
||||
*
|
||||
*
|
||||
* @param keyValueOperations must not be {@literal null}.
|
||||
* @param queryCreator defaulted to {@link #DEFAULT_QUERY_CREATOR} if {@literal null}.
|
||||
*/
|
||||
@@ -86,7 +86,7 @@ public class KeyValueRepositoryFactory extends RepositoryFactorySupport {
|
||||
/**
|
||||
* Creates a new {@link KeyValueRepositoryFactory} for the given {@link KeyValueOperations} and
|
||||
* {@link AbstractQueryCreator}-type.
|
||||
*
|
||||
*
|
||||
* @param keyValueOperations must not be {@literal null}.
|
||||
* @param queryCreator must not be {@literal null}.
|
||||
* @param repositoryQueryType must not be {@literal null}.
|
||||
@@ -114,7 +114,7 @@ public class KeyValueRepositoryFactory extends RepositoryFactorySupport {
|
||||
public <T, ID extends Serializable> EntityInformation<T, ID> getEntityInformation(Class<T> domainClass) {
|
||||
|
||||
PersistentEntity<T, ?> entity = (PersistentEntity<T, ?>) context.getPersistentEntity(domainClass).get();
|
||||
PersistentEntityInformation<T, ID> entityInformation = new PersistentEntityInformation<T, ID>(entity);
|
||||
PersistentEntityInformation<T, ID> entityInformation = new PersistentEntityInformation<>(entity);
|
||||
|
||||
return entityInformation;
|
||||
}
|
||||
@@ -142,7 +142,7 @@ public class KeyValueRepositoryFactory extends RepositoryFactorySupport {
|
||||
|
||||
/**
|
||||
* Returns whether the given repository interface requires a QueryDsl specific implementation to be chosen.
|
||||
*
|
||||
*
|
||||
* @param repositoryInterface must not be {@literal null}.
|
||||
* @return
|
||||
*/
|
||||
@@ -177,7 +177,7 @@ public class KeyValueRepositoryFactory extends RepositoryFactorySupport {
|
||||
* {@link KeyValueOperations} and query creator type.
|
||||
* <p>
|
||||
* TODO: Key is not considered. Should it?
|
||||
*
|
||||
*
|
||||
* @param key
|
||||
* @param evaluationContextProvider must not be {@literal null}.
|
||||
* @param keyValueOperations must not be {@literal null}.
|
||||
@@ -210,7 +210,7 @@ public class KeyValueRepositoryFactory extends RepositoryFactorySupport {
|
||||
this.repositoryQueryType = repositoryQueryType;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.repository.query.QueryLookupStrategy#resolveQuery(java.lang.reflect.Method, org.springframework.data.repository.core.RepositoryMetadata, org.springframework.data.projection.ProjectionFactory, org.springframework.data.repository.core.NamedQueries)
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2015 the original author or authors.
|
||||
* Copyright 2014-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.keyvalue.repository.support;
|
||||
|
||||
import static org.springframework.data.keyvalue.repository.support.KeyValueQuerydslUtils.*;
|
||||
import static org.springframework.data.keyvalue.repository.support.KeyValueQuerydslUtils.toOrderSpecifier;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@@ -41,7 +41,7 @@ import com.querydsl.core.types.dsl.PathBuilder;
|
||||
|
||||
/**
|
||||
* {@link KeyValueRepository} implementation capable of executing {@link Predicate}s using {@link CollQuery}.
|
||||
*
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
* @author Oliver Gierke
|
||||
* @author Thomas Darimont
|
||||
@@ -59,7 +59,7 @@ public class QuerydslKeyValueRepository<T, ID extends Serializable> extends Simp
|
||||
/**
|
||||
* Creates a new {@link QuerydslKeyValueRepository} for the given {@link EntityInformation} and
|
||||
* {@link KeyValueOperations}.
|
||||
*
|
||||
*
|
||||
* @param entityInformation must not be {@literal null}.
|
||||
* @param operations must not be {@literal null}.
|
||||
*/
|
||||
@@ -70,7 +70,7 @@ public class QuerydslKeyValueRepository<T, ID extends Serializable> extends Simp
|
||||
/**
|
||||
* Creates a new {@link QuerydslKeyValueRepository} for the given {@link EntityInformation},
|
||||
* {@link KeyValueOperations} and {@link EntityPathResolver}.
|
||||
*
|
||||
*
|
||||
* @param entityInformation must not be {@literal null}.
|
||||
* @param operations must not be {@literal null}.
|
||||
* @param resolver must not be {@literal null}.
|
||||
@@ -83,7 +83,7 @@ public class QuerydslKeyValueRepository<T, ID extends Serializable> extends Simp
|
||||
Assert.notNull(resolver, "EntityPathResolver must not be null!");
|
||||
|
||||
this.path = resolver.createPath(entityInformation.getJavaType());
|
||||
this.builder = new PathBuilder<T>(path.getType(), path.getMetadata());
|
||||
this.builder = new PathBuilder<>(path.getType(), path.getMetadata());
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -117,7 +117,7 @@ public class QuerydslKeyValueRepository<T, ID extends Serializable> extends Simp
|
||||
return query.fetchResults().getResults();
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.querydsl.QueryDslPredicateExecutor#findAll(com.mysema.query.types.Predicate, org.springframework.data.domain.Sort)
|
||||
*/
|
||||
@@ -145,7 +145,7 @@ public class QuerydslKeyValueRepository<T, ID extends Serializable> extends Simp
|
||||
}
|
||||
}
|
||||
|
||||
return new PageImpl<T>(query.fetchResults().getResults(), pageable, count(predicate));
|
||||
return new PageImpl<>(query.fetchResults().getResults(), pageable, count(predicate));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -174,7 +174,7 @@ public class QuerydslKeyValueRepository<T, ID extends Serializable> extends Simp
|
||||
return prepareQuery(predicate).fetchCount();
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.querydsl.QueryDslPredicateExecutor#exists(com.mysema.query.types.Predicate)
|
||||
*/
|
||||
@@ -185,13 +185,13 @@ public class QuerydslKeyValueRepository<T, ID extends Serializable> extends Simp
|
||||
|
||||
/**
|
||||
* Creates executable query for given {@link Predicate}.
|
||||
*
|
||||
*
|
||||
* @param predicate
|
||||
* @return
|
||||
*/
|
||||
protected AbstractCollQuery<T, ?> prepareQuery(Predicate predicate) {
|
||||
|
||||
CollQuery<T> query = new CollQuery<T>();
|
||||
CollQuery<T> query = new CollQuery<>();
|
||||
query.from(builder, findAll());
|
||||
|
||||
return predicate != null ? query.where(predicate) : query;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
* Copyright 2014-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -44,7 +44,7 @@ public class SimpleKeyValueRepository<T, ID extends Serializable> implements Key
|
||||
/**
|
||||
* Creates a new {@link SimpleKeyValueRepository} for the given {@link EntityInformation} and
|
||||
* {@link KeyValueOperations}.
|
||||
*
|
||||
*
|
||||
* @param metadata must not be {@literal null}.
|
||||
* @param operations must not be {@literal null}.
|
||||
*/
|
||||
@@ -75,13 +75,13 @@ public class SimpleKeyValueRepository<T, ID extends Serializable> implements Key
|
||||
|
||||
if (pageable == null) {
|
||||
List<T> result = findAll();
|
||||
return new PageImpl<T>(result, Pageable.unpaged(), result.size());
|
||||
return new PageImpl<>(result, Pageable.unpaged(), result.size());
|
||||
}
|
||||
|
||||
Iterable<T> content = operations.findInRange(pageable.getOffset(), pageable.getPageSize(), pageable.getSort(),
|
||||
entityInformation.getJavaType());
|
||||
|
||||
return new PageImpl<T>(IterableConverter.toList(content), pageable,
|
||||
return new PageImpl<>(IterableConverter.toList(content), pageable,
|
||||
this.operations.count(entityInformation.getJavaType()));
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ public class SimpleKeyValueRepository<T, ID extends Serializable> implements Key
|
||||
@Override
|
||||
public Iterable<T> findAll(Iterable<ID> ids) {
|
||||
|
||||
List<T> result = new ArrayList<T>();
|
||||
List<T> result = new ArrayList<>();
|
||||
|
||||
for (ID id : ids) {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2015 the original author or authors.
|
||||
* Copyright 2014-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -31,7 +31,7 @@ import org.springframework.util.ClassUtils;
|
||||
|
||||
/**
|
||||
* {@link KeyValueAdapter} implementation for {@link Map}.
|
||||
*
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
*/
|
||||
public class MapKeyValueAdapter extends AbstractKeyValueAdapter {
|
||||
@@ -49,7 +49,7 @@ public class MapKeyValueAdapter extends AbstractKeyValueAdapter {
|
||||
|
||||
/**
|
||||
* Creates a new {@link MapKeyValueAdapter} using the given {@link Map} as backing store.
|
||||
*
|
||||
*
|
||||
* @param mapType must not be {@literal null}.
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
@@ -59,7 +59,7 @@ public class MapKeyValueAdapter extends AbstractKeyValueAdapter {
|
||||
|
||||
/**
|
||||
* Create new instance of {@link MapKeyValueAdapter} using given dataStore for persistence.
|
||||
*
|
||||
*
|
||||
* @param store must not be {@literal null}.
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@@ -69,7 +69,7 @@ public class MapKeyValueAdapter extends AbstractKeyValueAdapter {
|
||||
|
||||
/**
|
||||
* Creates a new {@link MapKeyValueAdapter} with the given store and type to be used when creating key spaces.
|
||||
*
|
||||
*
|
||||
* @param store must not be {@literal null}.
|
||||
* @param keySpaceMapType must not be {@literal null}.
|
||||
*/
|
||||
@@ -150,7 +150,7 @@ public class MapKeyValueAdapter extends AbstractKeyValueAdapter {
|
||||
*/
|
||||
@Override
|
||||
public CloseableIterator<Entry<Serializable, Object>> entries(Serializable keyspace) {
|
||||
return new ForwardingCloseableIterator<Entry<Serializable, Object>>(getKeySpaceMap(keyspace).entrySet().iterator());
|
||||
return new ForwardingCloseableIterator<>(getKeySpaceMap(keyspace).entrySet().iterator());
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -182,7 +182,7 @@ public class MapKeyValueAdapter extends AbstractKeyValueAdapter {
|
||||
|
||||
/**
|
||||
* Get map associated with given key space.
|
||||
*
|
||||
*
|
||||
* @param keyspace must not be {@literal null}.
|
||||
* @return
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user