-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DATAMONGO-1689 Add Kotlin extensions for [Reactive]MongoOperations. #463
Changes from all commits
e15dc3d
bbd2da8
a19287c
4c59d84
969b53c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,13 +11,14 @@ | |
<parent> | ||
<groupId>org.springframework.data</groupId> | ||
<artifactId>spring-data-mongodb-parent</artifactId> | ||
<version>2.0.0.BUILD-SNAPSHOT</version> | ||
<version>2.0.0.DATAMONGO-1689-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
<properties> | ||
<objenesis>1.3</objenesis> | ||
<equalsverifier>1.5</equalsverifier> | ||
<kotlin>1.1.2-5</kotlin> | ||
</properties> | ||
|
||
<dependencies> | ||
|
@@ -230,12 +231,108 @@ | |
<artifactId>spring-webmvc</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jetbrains.kotlin</groupId> | ||
<artifactId>kotlin-stdlib</artifactId> | ||
<version>${kotlin}</version> | ||
<optional>true</optional> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jetbrains.kotlin</groupId> | ||
<artifactId>kotlin-reflect</artifactId> | ||
<version>${kotlin}</version> | ||
<optional>true</optional> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jetbrains.kotlin</groupId> | ||
<artifactId>kotlin-test</artifactId> | ||
<version>${kotlin}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.nhaarman</groupId> | ||
<artifactId>mockito-kotlin</artifactId> | ||
<version>1.5.0</version> | ||
<scope>test</scope> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>org.jetbrains.kotlin</groupId> | ||
<artifactId>kotlin-stdlib</artifactId> | ||
</exclusion> | ||
<exclusion> | ||
<groupId>org.jetbrains.kotlin</groupId> | ||
<artifactId>kotlin-reflect</artifactId> | ||
</exclusion> | ||
<exclusion> | ||
<groupId>org.mockito</groupId> | ||
<artifactId>mockito-core</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
|
||
<plugin> | ||
<artifactId>kotlin-maven-plugin</artifactId> | ||
<groupId>org.jetbrains.kotlin</groupId> | ||
<version>${kotlin}</version> | ||
<configuration> | ||
<jvmTarget>1.8</jvmTarget> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<id>compile</id> | ||
<phase>compile</phase> | ||
<goals> <goal>compile</goal> </goals> | ||
<configuration> | ||
<sourceDirs> | ||
<sourceDir>${project.basedir}/src/main/kotlin</sourceDir> | ||
<sourceDir>${project.basedir}/src/main/java</sourceDir> | ||
</sourceDirs> | ||
</configuration> | ||
</execution> | ||
<execution> | ||
<id>test-compile</id> | ||
<phase>test-compile</phase> | ||
<goals> <goal>test-compile</goal> </goals> | ||
<configuration> | ||
<sourceDirs> | ||
<sourceDir>${project.basedir}/src/test/kotlin</sourceDir> | ||
<sourceDir>${project.basedir}/src/test/java</sourceDir> | ||
</sourceDirs> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
|
||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<executions> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you elaborate on the need for this quite significant change in the compile settings? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems to be the recommanded way to handle Kotlin + Java Maven builds. JetBrains explantation is the following:
|
||
<execution> | ||
<id>default-compile</id> | ||
<phase>none</phase> | ||
</execution> | ||
<execution> | ||
<id>default-testCompile</id> | ||
<phase>none</phase> | ||
</execution> | ||
<execution> | ||
<id>java-compile</id> | ||
<phase>compile</phase> | ||
<goals> <goal>compile</goal> </goals> | ||
</execution> | ||
<execution> | ||
<id>java-test-compile</id> | ||
<phase>test-compile</phase> | ||
<goals> <goal>testCompile</goal> </goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
|
||
<plugin> | ||
<groupId>com.mysema.maven</groupId> | ||
<artifactId>apt-maven-plugin</artifactId> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright 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. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.springframework.data.mongodb.core | ||
|
||
import kotlin.reflect.KClass | ||
|
||
/** | ||
* Extension for [ExecutableAggregationOperation.aggregateAndReturn] providing a [KClass] based variant. | ||
* | ||
* @author Sebastien Deleuze | ||
* @since 2.0 | ||
*/ | ||
fun <T : Any> ExecutableAggregationOperation.aggregateAndReturn(entityClass: KClass<T>): ExecutableAggregationOperation.AggregationOperation<T> = | ||
aggregateAndReturn(entityClass.java) | ||
|
||
/** | ||
* Extension for [ExecutableAggregationOperation.aggregateAndReturn] leveraging reified type parameters. | ||
* | ||
* @author Sebastien Deleuze | ||
* @since 2.0 | ||
*/ | ||
inline fun <reified T : Any> ExecutableAggregationOperation.aggregateAndReturn(): ExecutableAggregationOperation.AggregationOperation<T> = | ||
aggregateAndReturn(T::class.java) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Copyright 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. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.springframework.data.mongodb.core | ||
|
||
import kotlin.reflect.KClass | ||
|
||
/** | ||
* Extension for [ExecutableFindOperation.query] providing a [KClass] based variant. | ||
* | ||
* @author Sebastien Deleuze | ||
* @since 2.0 | ||
*/ | ||
fun <T : Any> ExecutableFindOperation.query(entityClass: KClass<T>): ExecutableFindOperation.FindOperation<T> = | ||
query(entityClass.java) | ||
|
||
/** | ||
* Extension for [ExecutableFindOperation.query] leveraging reified type parameters. | ||
* | ||
* @author Sebastien Deleuze | ||
* @since 2.0 | ||
*/ | ||
inline fun <reified T : Any> ExecutableFindOperation.query(): ExecutableFindOperation.FindOperation<T> = | ||
query(T::class.java) | ||
|
||
|
||
/** | ||
* Extension for [ExecutableFindOperation.FindOperationWithProjection.as] providing a [KClass] based variant. | ||
* | ||
* @author Sebastien Deleuze | ||
* @since 2.0 | ||
*/ | ||
fun <T : Any> ExecutableFindOperation.FindOperationWithProjection<T>.asType(resultType: KClass<T>): ExecutableFindOperation.FindOperationWithQuery<T> = | ||
`as`(resultType.java) | ||
|
||
/** | ||
* Extension for [ExecutableFindOperation.FindOperationWithProjection.as] leveraging reified type parameters. | ||
* | ||
* @author Sebastien Deleuze | ||
* @since 2.0 | ||
*/ | ||
inline fun <reified T : Any> ExecutableFindOperation.FindOperationWithProjection<T>.asType(): ExecutableFindOperation.FindOperationWithQuery<T> = | ||
`as`(T::class.java) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright 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. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.springframework.data.mongodb.core | ||
|
||
import kotlin.reflect.KClass | ||
|
||
/** | ||
* Extension for [ExecutableInsertOperation.insert] providing a [KClass] based variant. | ||
* | ||
* @author Sebastien Deleuze | ||
* @since 2.0 | ||
*/ | ||
fun <T : Any> ExecutableInsertOperation.insert(entityClass: KClass<T>): ExecutableInsertOperation.InsertOperation<T> = | ||
insert(entityClass.java) | ||
|
||
/** | ||
* Extension for [ExecutableInsertOperation.insert] leveraging reified type parameters. | ||
* | ||
* @author Sebastien Deleuze | ||
* @since 2.0 | ||
*/ | ||
inline fun <reified T : Any> ExecutableInsertOperation.insert(): ExecutableInsertOperation.InsertOperation<T> = | ||
insert(T::class.java) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright 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. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.springframework.data.mongodb.core | ||
|
||
import kotlin.reflect.KClass | ||
|
||
/** | ||
* Extension for [ExecutableRemoveOperation.remove] providing a [KClass] based variant. | ||
* | ||
* @author Sebastien Deleuze | ||
* @since 2.0 | ||
*/ | ||
fun <T : Any> ExecutableRemoveOperation.remove(entityClass: KClass<T>): ExecutableRemoveOperation.RemoveOperation<T> = | ||
remove(entityClass.java) | ||
|
||
/** | ||
* Extension for [ExecutableRemoveOperation.remove] leveraging reified type parameters. | ||
* | ||
* @author Sebastien Deleuze | ||
* @since 2.0 | ||
*/ | ||
inline fun <reified T : Any> ExecutableRemoveOperation.remove(): ExecutableRemoveOperation.RemoveOperation<T> = | ||
remove(T::class.java) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these be optional dependencies?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, I will change that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated