-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from SchwarzIT/feature/query
New Query Feature and Accessor to static methods from parent
- Loading branch information
Showing
24 changed files
with
354 additions
and
55 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
couchbase-entity-api/src/main/java/kaufland/com/coachbasebinderapi/GenerateAccessor.java
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,14 @@ | ||
package kaufland.com.coachbasebinderapi; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
|
||
@Retention(RetentionPolicy.CLASS) | ||
@Target({ElementType.FIELD, ElementType.METHOD}) | ||
public @interface GenerateAccessor { | ||
|
||
Class<?> value() default Void.class; | ||
} |
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
15 changes: 15 additions & 0 deletions
15
couchbase-entity-api/src/main/java/kaufland/com/coachbasebinderapi/query/Queries.java
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,15 @@ | ||
package kaufland.com.coachbasebinderapi.query; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
import kaufland.com.coachbasebinderapi.Field; | ||
|
||
@Retention(RetentionPolicy.CLASS) | ||
@Target({ElementType.TYPE}) | ||
public @interface Queries { | ||
|
||
Query[] value() default {}; | ||
} |
4 changes: 4 additions & 0 deletions
4
couchbase-entity-api/src/main/java/kaufland/com/coachbasebinderapi/query/Query.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,4 @@ | ||
package kaufland.com.coachbasebinderapi.query | ||
|
||
@Retention(AnnotationRetention.BINARY) | ||
annotation class Query(val fields: Array<String>) |
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
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
40 changes: 40 additions & 0 deletions
40
couchbase-entity/src/main/java/com/kaufland/model/accessor/CblGenerateAccessorHolder.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,40 @@ | ||
package com.kaufland.model.accessor | ||
|
||
import com.kaufland.javaToKotlinType | ||
import com.kaufland.util.ConversionUtil | ||
import com.kaufland.util.FieldExtractionUtil | ||
import com.kaufland.util.TypeUtil | ||
import com.squareup.kotlinpoet.* | ||
import kaufland.com.coachbasebinderapi.Field | ||
import org.apache.commons.lang3.text.WordUtils | ||
import javax.lang.model.element.Element | ||
import javax.lang.model.element.ElementKind | ||
import javax.lang.model.element.ExecutableElement | ||
import javax.lang.model.type.TypeMirror | ||
|
||
class CblGenerateAccessorHolder(private val className: String, val element: Element) { | ||
|
||
fun accessorFunSpec(): FunSpec? { | ||
|
||
if(element.kind == ElementKind.METHOD){ | ||
var methodBuilder = FunSpec.builder(element.simpleName.toString()).addAnnotation(JvmStatic::class) | ||
|
||
(element as ExecutableElement)?.apply { | ||
parameters.forEach { | ||
methodBuilder.addParameter(it.simpleName.toString(), it.asType().asTypeName().javaToKotlinType()) | ||
} | ||
methodBuilder.addStatement("%N.%N(${parameters.joinToString { it.simpleName.toString() }})", className, element.simpleName.toString()) | ||
} | ||
return methodBuilder.build() | ||
} | ||
return null | ||
} | ||
|
||
|
||
fun accessorPropertySpec(): PropertySpec? { | ||
if(element.kind == ElementKind.FIELD){ | ||
return PropertySpec.builder(element.simpleName.toString(), element.asType().asTypeName().javaToKotlinType()).addAnnotation(JvmField::class).initializer("%N.%N", className, element.simpleName.toString()).build() | ||
} | ||
return null | ||
} | ||
} |
15 changes: 11 additions & 4 deletions
15
couchbase-entity/src/main/java/com/kaufland/model/entity/BaseEntityHolder.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
Oops, something went wrong.