Commit Graph

57 Commits

Author SHA1 Message Date
Jens Schauder
1fc25727cf DATACMNS-1097 - Move classes to better matching packages.
Introduced new ExampleMatcherAccessor in data.support in favor of the now deprecated one in data.repository.core to avoid a dependency into the repositories subsystem to work with examples in general.

Added Degraph based test in order to avoid future cyclic package dependency violations.

Original pull request: #230.
Related ticket: DATAMONGO-1721.
2017-07-06 11:38:12 +02:00
Oliver Gierke
6cd5f7c052 DATACMNS-1096 - Replaced references to Spring's Converter to JDK 8's Function in domain package.
Switched to use Optional<Object> to make nullability explicit. Keep the original ….convert(…) method around as deprecated default method so that clients can be migrated gradually.
2017-06-26 16:26:41 +02:00
Mark Paluch
7d496978f5 DATACMNS-1058 - Polishing.
Improve Javadoc. Extend year range in license header.

Original pull request: #214.
2017-05-11 09:56:21 +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
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
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
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
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
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
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
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
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
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
Oliver Gierke
d4811e29d9 DATACMNS-867 - Second draft. 2017-03-24 08:00:23 +01:00
Oliver Gierke
cc63e5b7a4 DATACMNS-867 - First draft. 2017-03-24 08:00:23 +01:00
Christoph Strobl
3e048a6dca DATACMNS-985 - Remove references to single-argument assertion methods. 2017-01-31 18:10:40 +01:00
Oliver Gierke
a696484f8d DATACMNS-953 - Fixed application of GenericPropertyMatchers.exact().
We now really use exact matching for a match setup requesting exact matching. Previously, we erroneously set up the matching with a startsWith().
2016-12-06 10:58:52 +01:00
Oliver Gierke
c52c45741a DATACMNS-928 - Polishing.
Additional JavaDoc and @since tags. Minor additions to AbstractAggregateRoot.
2016-11-30 18:30:51 +01:00
Oliver Gierke
802eb7deef DATACMNS-928 - Support for publishing events from aggregate roots.
Introduced @DomainEvents usable on a method of an aggregate root. The method will be invoked when the aggregate is passed to a repository to save and its returned value or values will be exposed via an ApplicationEventListener.

Also, the aggregate can expose a method annotated with @AfterDomainEventPublication which will be invoked once all events have been published.
2016-11-30 18:30:51 +01:00
Oliver Gierke
b4518f0583 DATACMNS-920 - Added accessors for Range.lowerInclusive / ….upperInclusive.
Generally improved Range to be a value type by using Lombok's @Value.
2016-11-04 18:37:22 +01:00
Oliver Gierke
e294fb5ef4 DATACMNS-908 - Introduced Order.withProperty(…).
The introduced method allows creating new Order instances for a different property ensuring all other aspects (ignore case, null handling) are retained.
2016-09-05 14:46:51 +02:00
Oliver Gierke
acf12423e0 DATACMNS-888 - Added dedicated Sort type to be able to express directions for revisions.
Introduced dedicated RevisionSort property that allows to define the sort order independent of the revision property to be used.

Introduced methods to find out whether a Sort is descending or ascending to avoid having to refer to the enum.
2016-09-01 19:48:23 +02:00
Mark Paluch
ac51b1671d DATACMNS-900 - Added equals(…) and hashCode() methods for ExampleMatcher utility classes.
We now provide equals(…) and hashCode() methods for GenericPropertyMatcher, PropertySpecifier and PropertySpecifiers so that they can be compared and used in sets.

Original pull request: #175.
2016-09-01 17:24:32 +02:00
Oliver Gierke
d41a9cb5c5 DATACMNS-879 - ExampleMatcher now allows to define whether all or any match should be used.
Introduced dedicated factory methods for ExampleMatcher so that it exposes whether the predicates built from Example instances have to be fulfilled all or if it's sufficient that any of them matches.
2016-07-14 08:54:56 +02:00
Oliver Gierke
26f725be0d DATACMNS-810 - Polishing.
Renamed ExampleSpecification to ExampleMatcher and introduced a matching() factory method, dropping the dedicated override mechanism for types for now. Updated documentation accordingly.

Used Lombok for constructor creation, field defaults, toString() as well as equals(…) and hashCode() implementations.

Tweaked imports in unit tests. Renamed methods to express expected behavior.

Original pull request: #153.
2016-03-17 16:22:55 +01:00
Mark Paluch
b0ce7009e8 DATACMNS-810 - Refactor Query by Example API.
Split Example and ExampleSpec to create reusable components. Refactor builder pattern to a fluent API that creates immutable instances. Split user and framework API, Example and ExampleSpec are user API, created ExampleSpecAccessor for modules to access example spec configuration. Create static methods in GenericPropertyMatchers to ease creation of matchers in a readable style. Convert PropertySpecifier to inner class  and move PropertySpecifiers to ExampleSpec.

Related tickets: DATAJPA-218, DATAMONGO-1245.
Original pull request: #153.
2016-03-17 16:17:39 +01:00
Christoph Strobl
4092f0716f DATACMNS-810 - Add core types for Query by Example support.
Added required types for Query by Example which should be used by the individual store implementations. 

Generally the Example type captures a sample object and allow various settings concerning the mapping into an actual query. So there’s configuration options for handling null values, string matching, property paths to ignore,

Related tickets: DATAJPA-218, DATAMONGO-1245.
Original pull request: #153.
2016-03-17 16:17:39 +01:00
Oliver Gierke
ae96301ab0 DATACMNS-812 - Polishing.
Formatting and extension of copyright years.

Original pull request: #154.
2016-03-07 11:33:57 +01:00
Timothy Cheng
bc421f53c0 DATACMNS-812 - Fixed PageImpl.toString() to improve readability.
Add one to the getNumber() in PageImpl.toString() since it uses 0-based index.

Original pull request: #154.
2016-03-07 11:31:42 +01:00
Pepe García
64eafa4341 DATACMNS-789 - Fixed typo in JavaDoc of Page.
Original pull request: #146.
2015-11-23 17:13:15 +01:00
Oliver Gierke
3a2dc3d1d4 DATACMNS-713 - Disabled total adaption in PageImpl for empty pages.
The newly introduced adaption of the total in PageImpl must only be applied if the page accessed is not empty.
2015-06-19 15:26:40 +02:00
Oliver Gierke
de4f1ffb7b DATACMNS-713 - PageImpl now adapts total if necessary.
On a last page the total handed into a PageImpl constructor might not necessarily fit the content as there's the change of an insertion or deletion between the calculated count and the retrieval of the content. We now leniently mitigate those differences if the page created is the last page of the result.

Related tickets: DATAJPA-728, DATACMNS-615.
2015-06-15 14:24:03 +02:00
Oliver Gierke
2d75cf2c43 DATACMNS-651 - Introduced a Range value type.
Primarily intended to be used with Distance instances, we introduce a Range value type. Distance now has factory methods to create Range instances between two distances. To support this, Distance now implements comparable based on the normalized value of it.

Tiny refactoring in TypeDiscoverer to avoid code duplication between the lookup of parameter type information for constructors and methods.
2015-03-04 17:34:32 +01:00
Oliver Gierke
5cc4811c52 DATACMNS-635 - Slice and Page can now be mapped using a Converter.
Introduced a map(Converter converter) method on Slice and Page to be able to easily transform the elements and create a new Slice or Page of the transformation result.

On Java 8 this allows code like this:

Page<String> strings = …;
Page<Integer> ints = strings.map(String::length);
2015-01-22 19:01:16 +01:00
Oliver Gierke
55d988e7b7 DATACMNS-615 - PageImpl now rejects a total less than the amount of items given.
PageImpl now makes sure that the total given to the constructor is never less than then number of items given to make sure we do not mask broken count calculation by creating an actually invalid instance.

Related ticket: DATAMONGO-1120.
2014-12-16 12:40:48 +01:00
Oliver Gierke
e1b38faee9 DATACMNS-601 - Fixes for most of the SonarQube warnings. 2014-11-26 09:25:14 +01:00
Oliver Gierke
3660676338 DATACMNS-558 - Some code cleanups according to the Sonar report. 2014-08-10 12:51:28 +02:00
Oliver Gierke
ed0f7c51f8 DATACMNS-469 - Removed deprecations. 2014-07-16 11:53:20 +02:00
Oliver Gierke
63e595b0af DATACMNS-491 - Polishing of null handling API in Sort.Order.
Fixed @since-tags, added author tags where appropriate, fixed copyright header in SortUnitTests. Removed unnecessary formatting line comments. Renamed nullHandlingHint to nullHandling inside Order. Changed builder method signatures to be consistent with with(…) methods defining the direction.

Fixed copy & paste test in SortUnitTests.

Original pull request: #79.
2014-04-28 11:34:34 +02:00
Thomas Darimont
f689b5d5f3 DATACMNS-491 - Add support for configuring null handling hints in Sort.Order.
Null handling hints can now be configured on Order as being either NATIVE (we let the data store decide how to order nulls), NULLS_FIRST or NULLS_LAST.

This is the foundation for custom null-handling in other data store support modules like SD JPA and SD MongoDB.

Original pull request: #79.
2014-04-28 11:34:26 +02:00
Oliver Gierke
1805aad718 DATACMNS-387 - Introduce Slice abstraction.
Introduced a Slice interface which is effectively a Page without the total page information. This will allow store modules to implement slice-by-slice access without having to calculate a total number of elements.

Extracted content and Pageable related functionality into a common Chunk class which serves as base class for the two concrete implementations SliceImpl and PageImpl. Deprecated hasNextPage() etc. on Page in favor of the generic hasNext() methods.

QueryMethod now exposes an isSliceQuery() to indicate a query method will need sliced execution.
2014-03-04 14:25:08 +01:00
Oliver Gierke
1e3640e0ee DATACMNS-436 - Order.equals(…) / hashCode() / toString() now consider ignore case flag.
Extended equals(…), hashCode() and toString() methods t consider the ignore case flag held in an Order instance.
2014-02-06 18:13:54 +01:00
Oliver Gierke
8f0979e963 DATACMNS-431 - Code cleanups. 2014-01-28 13:14:35 +01:00
Oliver Gierke
f1d49c6f37 DATACMNS-429 - Improved JavaDoc for PageRequest and Sort.
Added a few missing parameter documentations in terms of semantics and nullability.
2014-01-23 12:23:13 +01:00
Oliver Gierke
62e14d2b12 DATACMNS-402 - Slight refinements in QSort implementation.
Re-enable concatenation with plain Sort via ….and(…) method. Some general polishing and JavaDoc cleanups.

Original pull request: #59.
2013-12-04 13:30:19 +01:00