-
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.
# fixed issue with Default, Changes, Constants
- Loading branch information
Showing
6 changed files
with
68 additions
and
23 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
couchbase-entity/src/main/java/com/kaufland/generation/CblConstantGeneration.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,41 @@ | ||
package com.kaufland.generation; | ||
|
||
import com.kaufland.model.entity.BaseEntityHolder; | ||
import com.kaufland.model.field.CblBaseFieldHolder; | ||
import com.kaufland.model.field.CblFieldHolder; | ||
import com.kaufland.util.TypeUtil; | ||
import com.squareup.javapoet.CodeBlock; | ||
import com.squareup.javapoet.MethodSpec; | ||
|
||
import javax.lang.model.element.Modifier; | ||
import javax.lang.model.type.TypeMirror; | ||
|
||
public class CblConstantGeneration { | ||
|
||
public static MethodSpec addConstants(BaseEntityHolder holder){ | ||
MethodSpec.Builder builder = MethodSpec.methodBuilder("addConstants"). | ||
addModifiers(Modifier.PRIVATE). | ||
addParameter(TypeUtil.createMapStringObject(), "map"); | ||
|
||
for (CblBaseFieldHolder fieldHolder : holder.getFieldConstants()) { | ||
|
||
if (fieldHolder.isConstant()) { | ||
builder.addStatement("map.put($N, " + getConvertedValue(fieldHolder.getTypeMirror(), fieldHolder.getDefaultValue())+")", fieldHolder.getConstantName()); | ||
} | ||
} | ||
return builder.build(); | ||
} | ||
|
||
public static CodeBlock addAddCall(String nameOfMap){ | ||
return CodeBlock.builder().addStatement("addConstants($N)", nameOfMap).build(); | ||
} | ||
|
||
private static String getConvertedValue(TypeMirror clazz, String value) { | ||
|
||
if (clazz.toString().equals(String.class.getCanonicalName())) { | ||
return "\"" + value + "\""; | ||
} | ||
return value; | ||
} | ||
|
||
} |
21 changes: 12 additions & 9 deletions
21
couchbase-entity/src/main/java/com/kaufland/generation/CblDefaultGeneration.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
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