Commit Graph

1329 Commits

Author SHA1 Message Date
Oliver Gierke
6894fcb36a DATACMNS-1056 - Prevent QueryExecutionResultHander from rewrapping JDK 8 Optionals.
In case a repository method execution returns a JDK 8 Optional in the first place, the Optional instance had been wrapped into a third-party null-wrapper as is. We're now unwrapping the value held inside that optional and forward it to the value conversion.
2017-05-04 13:37:59 +02:00
Oliver Gierke
727ab8384c DATACMNS-944 - Moved to more consistent naming scheme for CrudRepository methods.
We now follow a more consistent naming scheme for the methods in repository that are driven by the following guidelines:

* Methods referring to an identifier now all end on …ById(…).
* Methods taking or returning a collection are named …All(…)

That results in the following renames:

* findOne(…) -> findById(…)
* save(Iterable) -> saveAll(Iterable)
* findAll(Iterable<ID>) -> findAllById(…)
* delete(ID) -> deleteById(ID)
* delete(Iterable<T>) -> deleteAll(Iterable<T>)
* exists() -> existsById(…)

As a side-effect of that, we can now drop the Serializable requirement for identifiers.

Updated CRUD method detection to use the new naming scheme and moved the code to Java 8 streams and Optional. Adapted RepositoryInvoker API to reflect method name changes as well.
2017-05-03 17:49:50 +02:00
Oliver Gierke
382c912111 DATACMNS-1052 - Sort is now Streamable. 2017-05-03 17:26:36 +02:00
Oliver Gierke
357efe4551 DATACMNS-1053 - EntityInformation now exposes getRequiredId(…).
Added EntityInformation.getRequiredId(…) that throws an exception if getId(…) returns an empty Optional.
2017-05-03 17:26:36 +02:00
Mark Paluch
b0177b2ab7 DATACMNS-1014 - Polishing.
Remove superfluous static modifier for inner enum types.

Original pull request: #213.
2017-05-03 08:26:00 +02:00
Jens Schauder
6be036af3a DATACMNS-1014 - Removed DateMidnight related converters.
org.joda.time.DateMidnight is deprecated, therefore we drop support for DateMidnight and remove all references to it.

Original pull request: #213.
2017-05-03 08:25:26 +02:00
Mark Paluch
14647f9192 DATACMNS-1021 - Add Order.asc(…) and Order.desc(…) factory methods.
We now support Order creation with Order.asc(String) and Order.desc(String) factory methods as shortcut to constructor creation via new Order(Direction, String).

Sort.by(Order.asc("age"), Order.desc("name"));

Deprecated Order(String) constructor in favor of the Order.by(String) factory method. Replace references to new Order(String) with Order.by(String).

Original pull request: #211.
2017-04-26 16:48:40 +02:00
Oliver Gierke
78374f3cb7 DATACMNS-1050 - Polishing.
Used @RequiredArgsConstructor in a couple of places in favour of manually declared constructors. Removed obsolete factory methods on Range. Adapted test cases accordingly.

Original pull request: #212.
2017-04-26 16:30:32 +02:00
Mark Paluch
22dc91b68f DATACMNS-1050 - Encapsulate boundaries in value objects for Range.
We now encapsulate a boundary in Range within a Bound value object. Bound consists of a value and whether the value is inclusive or exclusive. Boundaries without a value are unbounded. We introduced factory methods for Range and Boundary creation using primitives and a builder to build a Range.

Range<Long> range = Range.unbounded();
Range<Integer> range = Range.from(Bound.inclusive(10)).to(Bound.inclusive(20));
Range<Integer> range = Range.of(Bound.inclusive(10), Bound.inclusive(20));

Original pull request: #121.
2017-04-26 16:30:28 +02:00
Oliver Gierke
233fde36b5 DATACMNS-1035 - Moved CustomConversions to Spring Data Commons.
Extracted CustomConversions — whose code has largely been duplicated between the MongoDB, Couchbase and Cassandra modules — into Spring Data Commons. Store-specific extensions can now be contributed via a StoreConversions value type that carries both, store-specific default converters as well as a store-specific SimpleTypeHolder to augment the default list of simple types.

Removed SimpleTypeHolders public default constructor in favour of a protected one and a static DEFAULT instance for plain references.

Original pull request: #210.
2017-04-21 16:49:00 +02:00
Oliver Gierke
46d7e47239 DATACMNS-1042 - PagedResourceAssembler now keeps pagination information for self link.
We now hand the Pageable contained in the Page to the code that constructs the self link.

Added toEmptyResource(Page, Class) to force clients to resolve an optional base link before calling the method. Removed deprecated method to append pagination template parameters.
2017-04-21 16:48:59 +02:00
Oliver Gierke
4918eca7cf DATACMNS-1043 - Slice now exposes Pageable.
We now expose the Pageable that was used to create a Slice via its API. Slice itself constructs a default PageRequest so that current implementations of it still work as before.
2017-04-21 16:48:59 +02:00
Oliver Gierke
9d315af70a DATACMNS-993 - Polishing.
Removed custom JUnit integration as we can just create HidingClassLoader instances in the test and the integration actually causes more code being needed (additional JUnit rule, method level annotations etc.).

Tweaked ShadowingClassLoader to make obvious what has been changed over the Spring Framework variant. Created upstream ticket [0] to ask for the tweaks that would allow us to remove the class again.

Changed SpringDataWebConfigurationImportSelector to be lenient against the ResourceLoader not being available.

Original pull request: #202.
Related ticket: SPR-15439
[0] https://jira.spring.io/browse/SPR-15439
2017-04-12 08:03:38 +02:00
Jens Schauder
65734739bd DATACMNS-993 - Clean up class loader hacking in tests.
ClassLoaderRule with @ClassLoaderConfiguration allows easy creation FilteringClassLoader. Changed usage pattern of ClassUtils.isPresent(…) in order to ease testing. Copied the ShadowingClassloader from SpringFramework to get a constructor that doesn't shadow anything by default.

Original pull request: #202.
2017-04-12 08:03:32 +02:00
Oliver Gierke
37f78a3707 DATACMNS-1024 - Reinstated root object method lookup behavior in EvaluationContextExtensionInformation.
The switch to Java 8 and thus to Collectors.toMap(…) to assemble the root object's methods as functions broke due to the fact that overloaded methods have the same name which causes a collision in keys when preparing the map of functions.

We now use the same approach as before, of letting later methods trump earlier ones as this fixes the original bug. Filed DATACMNS-1026 to keep track of that problem.

Related tickets: DATACMNS-1026.
2017-04-04 07:07:42 +02:00
Mark Paluch
d72e9486be DATACMNS-988 - Fix Publisher to RxJava 2 conversion.
And fix some issues in JavaDoc.

Original Pull Request: #194
2017-04-03 10:47:53 +02:00
Mark Paluch
3099125aa3 DATACMNS-988 - Polishing.
Improve JavaDoc. Remove findAll declarations in reactive sorting repositories as they are inherited with the same signature.

Original Pull Request: #194
2017-04-03 10:47:02 +02:00
Mark Paluch
39ab1b3555 DATACMNS-988 - Provide RxJava 2 Repository interfaces.
Provide RxJava 2 Repository interfaces using back-pressure enabled Flowable as default return type for multi-element queries and Maybe for queries that can complete without emitting a value.

Original Pull Request: #194
2017-04-03 10:46:32 +02:00
Mark Paluch
e73710374d DATACMNS-1023 - We prefer direct matches on reactive repository query method overloads.
We now attempt to look up a target class method based on exact name and parameter types before falling back on the more expensive type matches. This also eliminates the possibility of invalid method matches as described in the ticket.

Related ticket: DATACMNS-943.
Original Pull Request: #194
2017-04-03 10:45:19 +02:00
Oliver Gierke
b5af2e9d96 DATACMNS-1020 - Improvements to revision API.
RevisionRepository now returns Optional for methods that could previously return null. Revision exposes additional methods to lookup required revision numbers and dates. Revisions now implements Streamable and exposes a ….none() factory method to create an empty instance.

AnnotationBasedRevisionMetadata now uses Lazy to lookup the fields with revision annotations. AnnotationDetectionFieldCallback now also uses Optional in places it previously returned null. StreamUtils now exposes factory methods for Collector instances producing unmodifiable List and Set instances.

Related ticket: DATACMNS-867.
2017-03-25 12:34:24 +01:00
Oliver Gierke
11dc67da2c DATACMNS-1018 - Reinstantiated ability to customize repository factory bean through annotation and XML namespace.
The refactoring for DATACMNS-867 has dropped support to customize the repository factory bean class on both the @Enable-annotations and the XML namespace. Reintroduced this feature, added a test case and moved the fallback into the value that's defined by the configuration extension inside DefaultRepositoryConfiguration.
2017-03-24 14:18:40 +01:00
Oliver Gierke
6b5b65804e DATACMNS-1015 - Introduced IdentifierAccessor.getRequiredIdentifier().
The new method allows to look up identifiers and immediately fail in the case of absence. Introduced the method as default method but also a new base type TargetAwareIdentifierAccessor to throw an exception with more context, i.e. the actual target bean we try to look up the identifier on.
2017-03-24 11:57:57 +01:00
Oliver Gierke
5f117a00a3 DATACMNS-867 - Polishing of Property value type in mapping package. 2017-03-24 08:00:48 +01:00
Oliver Gierke
baccb412f0 DATACMNS-867 - Cleanups.
SliceImpl now already checks Sort instance for not null. Removed unnecessary warnings supression.
2017-03-24 08:00:47 +01:00
Oliver Gierke
bc28a6b094 DATACMNS-867 - Improvements in Chunk and PageImpl.
Chunk now rejects null Pageables. Improved total calculation in PageImpl by using ….toOptional().
2017-03-24 08:00:47 +01:00
Oliver Gierke
93bb3d2e21 DATACMNS-867 - Additional assertions in AuditingHandler. 2017-03-24 08:00:47 +01:00
Oliver Gierke
7ac12c3c3d DATACMNS-867 - BasicPersistentEntity now rejects null Association.
Related ticket: DATACMNS-934.
2017-03-24 08:00:47 +01:00
Oliver Gierke
429dcbf659 DATACMNS-867 - ReflectionRepositoryInvoker now avoids ConversionService for Optional creation.
We now manually create Optional instances as the ConversionService converts single-argument collections into an optional with only that element.
2017-03-24 08:00:47 +01:00
Oliver Gierke
fe5d543ff2 DATACMNS-867 - Further refinements to Optionals.
Made ifAllPresent(…) void as the returned value is never used. Added ifPresentOrElse(…).
2017-03-24 08:00:47 +01:00
Oliver Gierke
d65d5a45e5 DATACMNS-867 - Fixed type on Sort.isUnsorted(). 2017-03-24 08:00:47 +01:00
Oliver Gierke
58b2bde303 DATACMNS-867 - Removed Optionals from Auditing methods signatures. 2017-03-24 08:00:46 +01:00
Oliver Gierke
ba875187cd DATACMNS-867 - RepositoryInvoker.invokeQueryMethod(…) now returns an Optional. 2017-03-24 08:00:46 +01:00
Oliver Gierke
7c33bcf98a DATACMNS-867 - Let lookups for a property's component and map value type use Optional. 2017-03-24 08:00:46 +01:00
Oliver Gierke
1c45fcfcdc DATACMNS-867 - Lazify lookups in AbstractPersistentProperty. 2017-03-24 08:00:46 +01:00
Oliver Gierke
417e728e77 DATACMNS-867 - Moved to new factory methods for Sort.
Codebase now uses Sort.by(…) where possible instead of the deprecated new Sort(…).
2017-03-24 08:00:46 +01:00
Oliver Gierke
fee153f724 DATACMNS-867 - RepositoryInvoker now returns an Optional for invokeFindOne(…).
Adapted ReflectionRepositoryInvoker to transparently unwrap other potentially used wrapper types to then convert the result into an Optional.
2017-03-24 08:00:46 +01:00
Oliver Gierke
dec820d6c2 DATACMNS-867 - Removed handling of null Pageables.
Pageable now exposes a dedicated null-object representing the absence of pagination so that all places that previously handled null values can now rather be more relaxed and assume that a non-null value is given.
2017-03-24 08:00:46 +01:00
Oliver Gierke
917c3e2889 DATACMNS-867 - Removed Optional from QuerydslBindingsFactory API. 2017-03-24 08:00:45 +01:00
Oliver Gierke
082c4157d1 DATACMNS-867 - Less Optional for auditing subsystem.
Removed Optional<Object> parameters in favor of plain Object and clients that avoid calling methods for absent values in the first place.
2017-03-24 08:00:45 +01:00
Oliver Gierke
5f7d1ae2f2 DATACMNS-867 - Overhaul of PersistentEntity API.
Moved getRequired…(…) methods from implementations into interfaces so that implementations inherit them by default.

Expanded generics declaration in PersistentEntities so that PerisistentProperty instances can be properly access from the PersistentEntity instances returned.
2017-03-24 08:00:45 +01:00
Oliver Gierke
1c60ea8d36 DATACMNS-867 - Rework utility classes.
Removed the additional methods that reflectively checked for the Stream type and whether a Method instance is a default method. Turned utility classes into interfaces where possible. Make use of Lombok's @UtilityClass where not.

Removed obsolete implementation class in StreamUtils in favor of a lambda.
2017-03-24 08:00:45 +01:00
Oliver Gierke
6e3114f3cb DATACMNS-867 - Updates to QueryExecutionConverters.
Introduced an overload in AbstractWrapperTypeConverter to simplify the constructors in implementations. Switched to Streamable.map(…) in getConvertibleTypes().
2017-03-24 08:00:45 +01:00
Oliver Gierke
628dc8b9c8 DATACMNS-867 - Introduced monadic methods on Streamable.
Streamable now exposes map(…), flatMap(…) and filter(…) to allow easy conversion into new Streamables. Introduced LazyStreamable to back those implementations. Simplified implementation of methods in PartTree to use those new methods.

Changed Page and Slice map(…) method to take a Function over a Converter so that act as specialization of the newly introduced map(…) method.
2017-03-24 08:00:45 +01:00
Oliver Gierke
bdbdb46adb DATACMNS-867 - API updates after rebase on latest changes. 2017-03-24 08:00:44 +01:00
Oliver Gierke
e861d0343b DATACMNS-867 - Additions to Lazy.
Added mapping functions to Lazy.
2017-03-24 08:00:44 +01:00
Oliver Gierke
8372e34adf DATACMNS-867 - Cleanups in Pageable API.
Dropped Pageable.NONE in favor of ….unpaged() for consistency with Sort.unsorted(). Extracted the implementation for the value backing it into an Unpaged enum instance. Introduced defaulted isPaged() / isUnpaged() to avoid having to compare instances.

JavaDoc in Sort and a couple of API polishes.
2017-03-24 08:00:44 +01:00
Oliver Gierke
a5c4be5f0a DATACMNS-867 - Removed Optional from ResultProcessor.withDynamicProjection(…).
We now expect the PropertyAccessor to either be non-null or the method not being called at all.
2017-03-24 08:00:44 +01:00
Oliver Gierke
c84e6c8427 DATACMNS-867 - More required metadata lookup.
Introduced overloads to lookup required RepositoryInformation and PersistentEntity instances to Repositories and PersistentEntities.
2017-03-24 08:00:44 +01:00
Christoph Strobl
be347eaaab DATACMNS-867 - Additional Java 8 language feature cleanup.
Make use of lambdas and method references though out the codebase. Remove no longer required generic type parameters.
Additionally remove unused imports and replace single element list initialization with dedicated singletonList.
Use Assertion overloads taking Supplier for dynamic assertion error messages.
2017-03-24 08:00:43 +01:00
Christoph Strobl
aa4c51e1ea DATACMNS-867 - Cache constructors in ClassGeneratingPropertyAccesssorFactory.
Fix hotspot in constructor lookup - in particular the propertyAccessorClass.getConstructors() call.
Additionally fix another minor issue in assertion message creation.
2017-03-24 08:00:43 +01:00