-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the ability to specify default values for non-nullable properties
- Loading branch information
Showing
24 changed files
with
409 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
...m/src/main/kotlin/org/apache/tinkerpop/gremlin/ogm/annotations/defaults/DefaultBoolean.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.apache.tinkerpop.gremlin.ogm.annotations.defaults | ||
|
||
import java.lang.annotation.Inherited | ||
|
||
/** | ||
* Annotation that, when used with the @Property annotation, specifies a value to use when | ||
* the graph does not have a value for the given parameter. This can be useful as an alternative to a migration | ||
* when adding a non-nullable property to an Element. | ||
*/ | ||
@Retention(value = AnnotationRetention.RUNTIME) | ||
@Target(AnnotationTarget.VALUE_PARAMETER) | ||
@Inherited | ||
annotation class DefaultBoolean( | ||
|
||
/** | ||
* The value to use when deserializing this property from the graph, but the graph has no value for this | ||
* property. | ||
*/ | ||
val value: Boolean) |
19 changes: 19 additions & 0 deletions
19
...-ogm/src/main/kotlin/org/apache/tinkerpop/gremlin/ogm/annotations/defaults/DefaultByte.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.apache.tinkerpop.gremlin.ogm.annotations.defaults | ||
|
||
import java.lang.annotation.Inherited | ||
|
||
/** | ||
* Annotation that, when used with the @Property annotation, specifies a value to use when | ||
* the graph does not have a value for the given parameter. This can be useful as an alternative to a migration | ||
* when adding a non-nullable property to an Element. | ||
*/ | ||
@Retention(value = AnnotationRetention.RUNTIME) | ||
@Target(AnnotationTarget.VALUE_PARAMETER) | ||
@Inherited | ||
annotation class DefaultByte( | ||
|
||
/** | ||
* The value to use when deserializing this property from the graph, but the graph has no value for this | ||
* property. | ||
*/ | ||
val value: Byte) |
19 changes: 19 additions & 0 deletions
19
...-ogm/src/main/kotlin/org/apache/tinkerpop/gremlin/ogm/annotations/defaults/DefaultChar.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.apache.tinkerpop.gremlin.ogm.annotations.defaults | ||
|
||
import java.lang.annotation.Inherited | ||
|
||
/** | ||
* Annotation that, when used with the @Property annotation, specifies a value to use when | ||
* the graph does not have a value for the given parameter. This can be useful as an alternative to a migration | ||
* when adding a non-nullable property to an Element. | ||
*/ | ||
@Retention(value = AnnotationRetention.RUNTIME) | ||
@Target(AnnotationTarget.VALUE_PARAMETER) | ||
@Inherited | ||
annotation class DefaultChar( | ||
|
||
/** | ||
* The value to use when deserializing this property from the graph, but the graph has no value for this | ||
* property. | ||
*/ | ||
val value: Char) |
19 changes: 19 additions & 0 deletions
19
...gm/src/main/kotlin/org/apache/tinkerpop/gremlin/ogm/annotations/defaults/DefaultDouble.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.apache.tinkerpop.gremlin.ogm.annotations.defaults | ||
|
||
import java.lang.annotation.Inherited | ||
|
||
/** | ||
* Annotation that, when used with the @Property annotation, specifies a value to use when | ||
* the graph does not have a value for the given parameter. This can be useful as an alternative to a migration | ||
* when adding a non-nullable property to an Element. | ||
*/ | ||
@Retention(value = AnnotationRetention.RUNTIME) | ||
@Target(AnnotationTarget.VALUE_PARAMETER) | ||
@Inherited | ||
annotation class DefaultDouble( | ||
|
||
/** | ||
* The value to use when deserializing this property from the graph, but the graph has no value for this | ||
* property. | ||
*/ | ||
val value: Double) |
19 changes: 19 additions & 0 deletions
19
...ogm/src/main/kotlin/org/apache/tinkerpop/gremlin/ogm/annotations/defaults/DefaultFloat.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.apache.tinkerpop.gremlin.ogm.annotations.defaults | ||
|
||
import java.lang.annotation.Inherited | ||
|
||
/** | ||
* Annotation that, when used with the @Property annotation, specifies a value to use when | ||
* the graph does not have a value for the given parameter. This can be useful as an alternative to a migration | ||
* when adding a non-nullable property to an Element. | ||
*/ | ||
@Retention(value = AnnotationRetention.RUNTIME) | ||
@Target(AnnotationTarget.VALUE_PARAMETER) | ||
@Inherited | ||
annotation class DefaultFloat( | ||
|
||
/** | ||
* The value to use when deserializing this property from the graph, but the graph has no value for this | ||
* property. | ||
*/ | ||
val value: Float) |
19 changes: 19 additions & 0 deletions
19
...n-ogm/src/main/kotlin/org/apache/tinkerpop/gremlin/ogm/annotations/defaults/DefaultInt.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.apache.tinkerpop.gremlin.ogm.annotations.defaults | ||
|
||
import java.lang.annotation.Inherited | ||
|
||
/** | ||
* Annotation that, when used with the @Property annotation, specifies a value to use when | ||
* the graph does not have a value for the given parameter. This can be useful as an alternative to a migration | ||
* when adding a non-nullable property to an Element. | ||
*/ | ||
@Retention(value = AnnotationRetention.RUNTIME) | ||
@Target(AnnotationTarget.VALUE_PARAMETER) | ||
@Inherited | ||
annotation class DefaultInt( | ||
|
||
/** | ||
* The value to use when deserializing this property from the graph, but the graph has no value for this | ||
* property. | ||
*/ | ||
val value: Int) |
19 changes: 19 additions & 0 deletions
19
...-ogm/src/main/kotlin/org/apache/tinkerpop/gremlin/ogm/annotations/defaults/DefaultLong.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.apache.tinkerpop.gremlin.ogm.annotations.defaults | ||
|
||
import java.lang.annotation.Inherited | ||
|
||
/** | ||
* Annotation that, when used with the @Property annotation, specifies a value to use when | ||
* the graph does not have a value for the given parameter. This can be useful as an alternative to a migration | ||
* when adding a non-nullable property to an Element. | ||
*/ | ||
@Retention(value = AnnotationRetention.RUNTIME) | ||
@Target(AnnotationTarget.VALUE_PARAMETER) | ||
@Inherited | ||
annotation class DefaultLong( | ||
|
||
/** | ||
* The value to use when deserializing this property from the graph, but the graph has no value for this | ||
* property. | ||
*/ | ||
val value: Long) |
19 changes: 19 additions & 0 deletions
19
...ogm/src/main/kotlin/org/apache/tinkerpop/gremlin/ogm/annotations/defaults/DefaultShort.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.apache.tinkerpop.gremlin.ogm.annotations.defaults | ||
|
||
import java.lang.annotation.Inherited | ||
|
||
/** | ||
* Annotation that, when used with the @Property annotation, specifies a value to use when | ||
* the graph does not have a value for the given parameter. This can be useful as an alternative to a migration | ||
* when adding a non-nullable property to an Element. | ||
*/ | ||
@Retention(value = AnnotationRetention.RUNTIME) | ||
@Target(AnnotationTarget.VALUE_PARAMETER) | ||
@Inherited | ||
annotation class DefaultShort( | ||
|
||
/** | ||
* The value to use when deserializing this property from the graph, but the graph has no value for this | ||
* property. | ||
*/ | ||
val value: Short) |
19 changes: 19 additions & 0 deletions
19
...gm/src/main/kotlin/org/apache/tinkerpop/gremlin/ogm/annotations/defaults/DefaultString.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.apache.tinkerpop.gremlin.ogm.annotations.defaults | ||
|
||
import java.lang.annotation.Inherited | ||
|
||
/** | ||
* Annotation that, when used with the @Property annotation, specifies a value to use when | ||
* the graph does not have a value for the given parameter. This can be useful as an alternative to a migration | ||
* when adding a non-nullable property to an Element. | ||
*/ | ||
@Retention(value = AnnotationRetention.RUNTIME) | ||
@Target(AnnotationTarget.VALUE_PARAMETER) | ||
@Inherited | ||
annotation class DefaultString( | ||
|
||
/** | ||
* The value to use when deserializing this property from the graph, but the graph has no value for this | ||
* property. | ||
*/ | ||
val value: String) |
21 changes: 21 additions & 0 deletions
21
...ogm/src/main/kotlin/org/apache/tinkerpop/gremlin/ogm/annotations/defaults/DefaultValue.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package org.apache.tinkerpop.gremlin.ogm.annotations.defaults | ||
|
||
import java.lang.annotation.Inherited | ||
import java.util.function.Supplier | ||
import kotlin.reflect.KClass | ||
|
||
/** | ||
* Annotation that, when used with the @Property annotation, specifies a value to use when | ||
* the graph does not have a value for the given parameter. This can be useful as an alternative to a migration | ||
* when adding a non-nullable property to an Element. | ||
*/ | ||
@Retention(value = AnnotationRetention.RUNTIME) | ||
@Target(AnnotationTarget.VALUE_PARAMETER) | ||
@Inherited | ||
annotation class DefaultValue( | ||
|
||
/** | ||
* A class that can supply the default value for the parameter this annotation is placed on. | ||
* The supplied value must never be null. | ||
*/ | ||
val supplier: KClass<out Supplier<out Any>>) |
13 changes: 13 additions & 0 deletions
13
...rc/main/kotlin/org/apache/tinkerpop/gremlin/ogm/exceptions/NullablePropertyWithDefault.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.apache.tinkerpop.gremlin.ogm.exceptions | ||
|
||
import kotlin.reflect.KParameter | ||
|
||
internal class NullablePropertyWithDefault( | ||
parameter: KParameter | ||
) : AnnotationException( | ||
"Parameter with @DefaultVaule annotation marked nullable. It's pretty odd to have an @Property that allows null " + | ||
"when the Element is created and serialized to the graph, but is given a default value when there's " + | ||
"no value for the @Property when deserializing from the graph. Most likely this parameter should be " + | ||
"non-nullable." + | ||
"Parameter: ${parameter.name}." | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.