Commit Graph

138 Commits

Author SHA1 Message Date
Christoph Strobl
1f77786d89 Don't create PersistentEntity for Nullable wrapper type.
Original pull request: #2394.
Closes #2390.
2021-07-08 11:49:25 +02:00
Mark Paluch
c24ba262ca Polishing.
Use Spring's nullability annotations where used as part of API nullability indicators.

See #2385
2021-06-17 09:03:00 +02:00
Mark Paluch
c94fe6d2e0 Limit BeanWrapper's KotlinCopyUtil to Kotlin Data classes.
Previously, we tried to invoke the copy(…) method on all Kotlin classes whereas the copy(…) method is only specific to Kotlin data classes.

Original pull request: #390.
Closes #2358.
2021-04-21 09:29:37 +02:00
Oliver Drotbohm
6b0292cc66 Support for jMolecules' Association type.
We no recognize properties of type org.jmolecules.ddd.types.Association as associations in our PersistentProperty model.

Also, we now register JMolecules Converter implementations for Association and Identifier in CustomConversions so that they can persisted like their embedded primitive value out of the box.

Fixes #2315.
Original pull request: #2316.
2021-03-01 15:20:26 +01:00
Mark Paluch
3f1609587e Polishing.
Reformat code.

Original pull request: #2314.
Closes: #2313
2021-03-01 10:33:33 +01:00
Christoph Strobl
8917115ba9 Collect constructor type information via Constructor.getParameters().
This commit fixes an issue where we fail to detect all type arguments from a given constructor. calling getGenericParameterTypes in some cases does not include all Types, we now explicitly iterate over the parameters and extract the parameterized type that is used for creating the TypeInformation.

Closes: #2313
Original pull request: #2314.
2021-03-01 10:33:22 +01:00
Mark Paluch
8bd2f9bf34 Update copyright year to 2021.
Closes #2268.
2021-01-07 13:42:27 +01:00
Mark Paluch
1d146da048 DATACMNS-1828 - Revert custom collection component type lookup.
We now report the first generic parameter for collection-like types to use the behavior that was previously in place. We will address the issues resulting of the intent to report the correct component type of Iterable in a later change.
2020-11-06 16:08:06 +01:00
Oliver Drotbohm
9fddd402f7 DATACMNS-1828 - Fix Map component type lookup for custom Map implementations.
Instead of using the first generic type parameter of a parameterized type as Map component type, we now explicitly lookup the super type's Map-specific generics configuration and use its first generic type parameter. The same for collection like types falling back to the parameter type bound to Iterable.
2020-11-05 15:21:55 +01:00
Oliver Drotbohm
e3e23828ef DATACMNS-1806 - Polishing.
Styilistic tweaks (we only qualify writing field access with this).

Original pull request: #468.
2020-09-25 16:42:41 +02:00
Henning Rohlfs
a442b90021 DATACMNS-1806 - Prevent returning null from Lazy due to concurrency problem.
When accessed concurrently from multiple threads, Lazy.getNullable() could return null unexpectedly.

Original pull request: #468.
2020-09-25 16:42:41 +02:00
Oliver Drotbohm
af9dd6110d DATACMNS-1726 - Polishing of nullability after Lombok removal.
Reviewed visibility modifiers manually introduced constructors previously provided by Lombok. Also some nullability constraints have been accidentally changed by that.
2020-09-25 15:29:08 +02:00
Christoph Strobl
f261220372 DATACMNS-1762 - Polishing.
Update JavaDoc, remove unused imports and reduce method visibility.

Original Pull Request: #459
2020-09-25 08:00:29 +02:00
Mark Paluch
04f59f1307 DATACMNS-1762 - Extract NullableWrapperConverters from QueryExecutionConverters.
Nullable wrappers such as Java 8 Optional, Guava Optional, Scala Option and Vavr Option are now handled in NullableWrapperConverters and are no longer coupled to QueryExecutionConverters so that this functionality can be reused.

Original Pull Request: #459
2020-09-25 07:58:52 +02:00
Mark Paluch
b3d0fea061 DATACMNS-1637 - Add default stream() method to CloseableIterator.
CloseableIterator now allows construction of a Stream that is associated with a close hook to release resources after its use.

CloseableIterator<Person> iterator = …;

try (Stream<Person> stream = iterator.stream()) {
	assertThat(stream.count()).isEqualTo(3);
}
2020-09-22 15:47:48 +02:00
Mark Paluch
a600d8160c DATACMNS-1781 - Move off deprecated Spring Framework API.
Use KotlinDetector instead of ReflectionUtils.isKotlinClass(…). Use replacement MethodParameter(…).withContainingClass(…) instead of GenericTypeResolver.resolveParameterType(…). Use MergedAnnotations.from(…).isPresent(…) instead of AnnotationUtils.isAnnotationMetaPresent(…).
2020-08-04 12:16:55 +02:00
Mark Paluch
bb4d621a32 DATACMNS-1779 - Consider kotlin.Unit a simple type.
kotlin.Unit is now considered a simple type to avoid PersistentEntity creation.

ReflectionUtils.isVoid(…) now encapsulates the check so that calling code doesn't need to check if Kotlin is on the class path.
2020-07-31 10:57:56 +02:00
Mark Paluch
edcf1a0562 DATACMNS-1108 - Prefer regular methods in ReflectionUtils.findRequiredMethod(…).
findRequiredMethod(…) now prefers regular methods over synthetic/bridge methods. This refinement is required for newer Java versions that create synthetic bridge methods using the interface's return type. For SpEL extension introspection we're looking for the most specific return type that may be declared in the extension.

Original Pull Request: #454
2020-07-22 13:44:19 +02:00
Phillip Webb
cb8443e299 DATACMNS-1755 - Rename uppercase 'CACHE' static finals.
Rename static final `CACHE` members to use the lowercase form. Although
the caches are static final, they are not constant values.

Original pull request: #448.
2020-06-25 11:19:44 +02:00
Mark Paluch
4be5aae181 DATACMNS-1726 - Delombok source files. 2020-05-15 08:46:58 +02:00
wonwoo
12b9850a85 DATACMNS-1672 - Fix typos in Javadoc.
Original pull request: #431.
2020-02-25 09:23:52 +01:00
Christoph Strobl
769b0f6af5 DATACMNS-1508 - Polishing.
Add findAllById, deleteAll to CoroutineCrudRepository.

Keep CoroutineCrudRepository somewhat in sync with ReactiveCrudRepository by adding based methods for those accecpting Publisher.
Also add some test.

Update License Headers of Kotlin files and fix some warnings. Switch to kotlin-test-junit5.

Original pull request: #415.
2020-01-16 11:28:39 +01:00
Mark Paluch
93c708379e DATACMNS-1508 - Address review comments.
Added ClassUtils.ifPresent(…) to conditionally call back a Consumer<Class> if a class is available from the given ClassLoader. Extract isSuspend(…) method into KotlinReflectionUtils. Deprecate Kotlin-related methods in our ReflectionUtils as parts are available from Spring Framework directly.

Rename CoCrudRepository to CoroutineCrudRepository and CoroutineSortingRepository. Add tests for KotlinReflectionUtils to test calls without Kotlin dependencies.

Original pull request: #415.
2020-01-16 11:28:39 +01:00
Mark Paluch
ce7683c672 DATACMNS-1508 - Support for Kotlin Coroutines repositories.
We now support Kotlin Coroutines repositories backed by reactive repositories. Coroutine repositories can either invoke reactive query methods or implemented methods that are backed either by methods returning a reactive wrapper or that are native suspended functions.

Exclude Coroutines Continuation from bindable parameters and name discovery and do not unwrap results for suspended functions returning a reactive type.

interface CoroutinesRepository : CoroutineCrudRepository<User, String> {

    suspend fun findOne(id: String): User

    fun findByFirstname(firstname: String): Flow<User>
}

Original pull request: #415.
2020-01-16 11:28:33 +01:00
Mark Paluch
eed7658ce5 DATACMNS-1643 - Update copyright years to 2020. 2020-01-07 08:32:25 +01:00
Oliver Drotbohm
3e41d932dd DATACMNS-1571 - Polishing. 2019-08-28 10:06:46 +02:00
Oliver Drotbohm
85e257fc82 DATACMNS-1571 - Fixed specialization in ParameterizedTypeInformation.
DATACMNS-783 introduced code to specialize a raw type containing generics with the type information from it's context so that it can be established if only the raw type has been e.g. stored as type hint in a store (SomeType<T> stored as SomeType and T needing to be reestablished from the context). That application of the context unfortunately did not consider that the raw type might carry generics information itself, like `SomeType extends Foo<String, Integer>`.

We've now changed the specialization algorithm so that the the target type is being looked at in the context of the type used for the assignment (e.g. `Foo<T, ID> foo`). If that assignment fully resolves the declared type, we just outright use the given type as it by definition carries all generics information plus better type information in the first place.

If the type to specialize on is only partially expanding the generics we now create a synthetic type to merge the generics information. I.e. a `SomeType<T> extends Foo<T, Integer>` stored as SomeType would still resolve ID to Integer but capture T from the context including all potentially declared bounds.

Related tickets: DATACMNS-783, DATACMNS-1138.
2019-08-28 10:06:46 +02:00
Mark Paluch
293bbd9a63 DATACMNS-1556 - General performance improvements in repository execution.
We now avoid the allocation of an Optional instance in the lookup of a dynamic projection in ParameterAccessor. Also, Lazy now exposes a ….getNullable() to be favored over ….getOptional() for hot code paths.

Replaced Stream and Optional usage with for-loops and nullable return values. Reuse parameter names to avoid repeated annotation lookups. Reuse result from Parameters.getBindable(). Introduce ParametersParameterAccessor.getValues() to consistently reuse a single accessor instance allowing access to the unwrapped values. Introduce type cache to QueryExecutionConverters to quickly reject types that do not require wrapping. Avoid recalculation of QueryMethod.isCollectionQuery().
2019-07-25 14:12:11 +02:00
Mark Paluch
83611de861 DATACMNS-1500 - URL Cleanup. 2019-06-05 11:16:03 +02:00
Oliver Drotbohm
a45a0ded9c DATACMNS-1518 - Fixed detection of varargs overloads for SpEL expressions.
Before this commit we haven't properly resolved methods on a root object provided by an EvaluationContextExtension that was using varargs. With a vararg method, the number of parameters handed into the method is not necessary equal to the number of parameters. We previously simply skipped methods with a different number of arguments. We now try direct matches first but calculate valid varargs alternatives in case that initial lookup fails and try to match those alternatives.

This lookup is implemented in ….util.ParameterTypes now and used by ….spel.spi.Function. The latter now also handles the actual invocation of those methods properly by collecting the trailing arguments into an array.
2019-05-09 13:05:11 +02:00
Spring Operator
48c9297118 DATACMNS-1500 - URL Cleanup.
This commit updates URLs to prefer the https protocol. Redirects are not followed to avoid accidentally expanding intentionally shortened URLs (i.e. if using a URL shortener).

# Fixed URLs

## Fixed Success
These URLs were switched to an https URL with a 2xx status. While the status was successful, your review is still recommended.

* [ ] http://www.apache.org/licenses/ with 1 occurrences migrated to:
  https://www.apache.org/licenses/ ([https](https://www.apache.org/licenses/) result 200).
* [ ] http://www.apache.org/licenses/LICENSE-2.0 with 701 occurrences migrated to:
  https://www.apache.org/licenses/LICENSE-2.0 ([https](https://www.apache.org/licenses/LICENSE-2.0) result 200).

Original Pull Request: #387
2019-03-22 11:00:44 +01:00
Oliver Drotbohm
ea3af3dbbb DATACMNS-1449 - MethodInvocationRecorder now rejects final types. 2019-03-05 14:37:59 +01:00
Oliver Gierke
34d95fb7e4 DAATCMNS-1449 - Added API to record method invocations.
Introduced MethodInvocationRecorder to record method invocations on types to obtain the property traversal those invocations represent.

Recorded<ZipCode> recorded = MethodInvocationRecorder.forProxyOf(Person.class)
  .record(Person::getAddress)
  .record(Address::getZipCode);

assertThat(recorded.getPropertyPath)).hasValue("address.zipCode");
2019-03-05 13:50:49 +01:00
Mark Paluch
1969f4bcdc DATACMNS-1459 - Update copyright years to 2019. 2019-01-02 12:12:19 +01:00
Oliver Drotbohm
97390a1eef DATACMNS-1447 - Streamable now exposes Collectors.
Added Streamable.toStreamable() and ….toStreamable(Collector) to allow the creation of a Streamable from streams wither using a default List-based intermediate collector (former) or providing an explicit one (latter).
2018-12-12 11:26:15 +01:00
Oliver Drotbohm
75c9ab0a63 DATACMNS-1430 - Tweaked TypeDiscoverer to consider subtypes of Streamable collection like. 2018-12-04 15:43:54 +01:00
Oliver Drotbohm
db6e4cc024 DATACMNS-1434 - Removed Javaslang support. 2018-12-04 14:05:24 +01:00
Oliver Drotbohm
a3a5c8e484 DATACMNS-1433 - Added additional Streamable.and(…) flavors for convenience.
Removed superfluous Streamable creation from DefaultImplementationlookupConfiguration.
2018-12-04 12:46:06 +01:00
Oliver Drotbohm
9b39f51635 DATACMNS-1432 - Added Streamable.toList() and ….toSet() for convenience. 2018-12-04 12:40:14 +01:00
Oliver Drotbohm
9d16739943 DATACMNS-1419 - Added TypeInformation.isSubtypeOf(…). 2018-11-19 19:21:33 +01:00
Oliver Gierke
f00d5b9ac6 DATACMNS-1376 - Polishing.
Moved JVM version lookup into Version.

Original pull request: #307.
2018-08-17 13:09:04 +02:00
Mark Paluch
4600190d01 DATACMNS-1366 - Performance improvements in mapping subsystem
We now use a presized HashMap and Weak references in BasicPersistentEntity to improve memory and CPU profile and and avoid unmodifiable collection creation in BasicPersistentEntity.iterator(). Refactored ClassTypeInformation.from(…) lambda to method reference and predefined collection size for the cache. Reduced object instantiations during TypeDiscoverer.equals(…) by checking for type variable map emptiness to avoid Map iterator creation in Map.equals(…).

Original pull request: #305.
2018-08-15 15:13:41 +02:00
Oliver Gierke
13b115068d DATACMNS-1371 - Improvements to custom implementation scanning.
CustomRepositoryImplementationDetector now works in two differend modes. If initialized with an ImplementationDetectionConfiguration, it will trigger a canonical, cached component scan for implementation types matching the configured name pattern. Individual custom implementation lookups will then select from this initially scanned set of bean definitions to pick the matching implementation class and potentially resolve ambiguities.
2018-08-14 15:25:30 +02:00
Mark Paluch
85b507ce10 DATACMNS-1322 - Cleanup refactorings.
Add missing since tags. Extract methods to maintain single abstraction level per method. Move visitDefaultValue from ClassGeneratingPropertyAccessorFactory to BytecodeUtil. Extend Javadoc.
2018-07-04 16:59:51 +02:00
Mark Paluch
79119000bb DATACMNS-1322 - Add support for Kotlin's copy(…) method.
We now support updating of immutable Kotlin data objects by creating new copies through Kotlin's copy method that is generated along with data classes and immutable properties.

data class DataClassKt(val id: String) {
}

data class ExtendedDataClassKt(val id: String, val name: String) {
}
2018-07-04 16:59:51 +02:00
Oliver Gierke
d570f4d79e DATACMNS-1342 - TypeInformation.isCollectionLike() considers Streamable now. 2018-06-14 12:18:41 +02:00
Oliver Gierke
37ab0a5d8f DATACMNS-1341 - ProxyUtils now detects JDK proxy target classes. 2018-06-14 11:51:15 +02:00
Oliver Gierke
d73e0a1f8f DATACMNS-1324 - Introduced extensible proxy detection infrastructure.
Introduced ProxyUtils.getUserClass(…) that by default is basically a facade for Spring's ClassUtils.getUserClass(…) but allows the registration of ProxyDetector implementations via Spring's SpringFactoriesLoader mechanism.

Moved all existing usages of ClassUtils.getUserClass(…) to ProxyUtils.
2018-05-17 16:20:11 +02:00
Oliver Gierke
ac324b22a5 DATACMNS-1275 - Introduced MappingContext.findPersistentPropertyPaths(Class<?>, Predicate<P>).
MappingContext now exposes a method to detect all property paths pointing to properties matching a given predicate.

Extracted PersistentPropertyPath creation into a dedicated factory class so that it can be tested individually. DefaultPersistentPropertyPath now exposes a ….containsPropertyOfType(…) to detect whether we've already processed a particular type in the path. Also applied a bit of Java 8 and Lombok polish.

InvalidPersistentPropertyPath now collects suggested alternatives to create a better exception message. PersistentEntities now allows to map over a MappingContext and PersistentEntity that a given type is corresponding to. Streamable now exposes an ….isEmpty(). Removed references to equivalent methods implemented in subtypes.
2018-04-09 14:31:20 +02:00
Oliver Gierke
32ea1f77c0 DATACMNS-1271 - Streamlined implementation of AnnotationBasedPersistentProperty to avoid NullPointerExceptions.
We now use the annotation cache's ….computeIfAbsent(…) to avoid inconsistencies between ….contains(…) and ….get(…) in multi-threaded scenarios.
2018-03-01 16:25:06 +01:00