Skip to content

Commit

Permalink
Code style update
Browse files Browse the repository at this point in the history
  • Loading branch information
robohorse committed Sep 4, 2024
1 parent 3122607 commit a695669
Show file tree
Hide file tree
Showing 11 changed files with 409 additions and 409 deletions.
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
package com.robohorse.robopojogenerator.models

data class ControlsModel(
val sources: List<SourceVM>,
var selectedSource: SourceVM? = null
val sources: List<SourceVM>,
var selectedSource: SourceVM? = null
)

sealed class SourceVM(
val languages: List<LanguageVM>,
var selectedLanguage: LanguageVM? = null,
val propertyName: String
val languages: List<LanguageVM>,
var selectedLanguage: LanguageVM? = null,
val propertyName: String
) {
class Json(
languages: List<LanguageVM>,
selected: LanguageVM? = null
languages: List<LanguageVM>,
selected: LanguageVM? = null
) : SourceVM(languages, selected, JSON)

class JsonSchema(
languages: List<LanguageVM>,
selected: LanguageVM? = null
languages: List<LanguageVM>,
selected: LanguageVM? = null
) : SourceVM(languages, selected, JSON_SCHEMA)

companion object {
Expand All @@ -27,18 +27,18 @@ sealed class SourceVM(
}

sealed class LanguageVM(
val frameworks: List<FrameworkVW>,
var selectedFramework: FrameworkVW? = null,
val propertyName: String
val frameworks: List<FrameworkVW>,
var selectedFramework: FrameworkVW? = null,
val propertyName: String
) {
class Java(
frameworks: List<FrameworkVW>,
selected: FrameworkVW? = null
frameworks: List<FrameworkVW>,
selected: FrameworkVW? = null
) : LanguageVM(frameworks, selected, JAVA)

class Kotlin(
frameworks: List<FrameworkVW>,
selected: FrameworkVW? = null
frameworks: List<FrameworkVW>,
selected: FrameworkVW? = null
) : LanguageVM(frameworks, selected, KOTLIN)

companion object {
Expand All @@ -48,71 +48,71 @@ sealed class LanguageVM(
}

sealed class FrameworkVW(
val propertyName: String,
val properties: List<AdditionalPropertiesVM>
val propertyName: String,
val properties: List<AdditionalPropertiesVM>
) {
class None(
properties: List<AdditionalPropertiesVM> = emptyList()
properties: List<AdditionalPropertiesVM> = emptyList()
) : FrameworkVW(NONE, properties)

class NoneJavaRecords(
properties: List<AdditionalPropertiesVM> = emptyList()
properties: List<AdditionalPropertiesVM> = emptyList()
) : FrameworkVW(NONE_JAVA_RECORDS, properties), JavaRecords

class NoneLombok(
properties: List<AdditionalPropertiesVM> = emptyList()
properties: List<AdditionalPropertiesVM> = emptyList()
) : FrameworkVW(NONE_LOMBOK, properties)

class Gson(
properties: List<AdditionalPropertiesVM> = emptyList()
properties: List<AdditionalPropertiesVM> = emptyList()
) : FrameworkVW(GSON, properties)

class GsonJavaRecords(
properties: List<AdditionalPropertiesVM> = emptyList()
properties: List<AdditionalPropertiesVM> = emptyList()
) : FrameworkVW(GSON_JAVA_RECORDS, properties), JavaRecords

class Jackson(
properties: List<AdditionalPropertiesVM> = emptyList()
properties: List<AdditionalPropertiesVM> = emptyList()
) : FrameworkVW(JACKSON, properties)

class JacksonJavaRecords(
properties: List<AdditionalPropertiesVM> = emptyList()
properties: List<AdditionalPropertiesVM> = emptyList()
) : FrameworkVW(JACKSON_JAVA_RECORDS, properties), JavaRecords

class LoganSquare(
properties: List<AdditionalPropertiesVM> = emptyList()
properties: List<AdditionalPropertiesVM> = emptyList()
) : FrameworkVW(LOGAN_SQUARE, properties)

class LoganSquareJavaRecords(
properties: List<AdditionalPropertiesVM> = emptyList()
properties: List<AdditionalPropertiesVM> = emptyList()
) : FrameworkVW(LOGAN_SQUARE_JAVA_RECORDS, properties), JavaRecords

class Moshi(
properties: List<AdditionalPropertiesVM> = emptyList()
properties: List<AdditionalPropertiesVM> = emptyList()
) : FrameworkVW(MOSHI, properties)

class MoshiJavaRecords(
properties: List<AdditionalPropertiesVM> = emptyList()
properties: List<AdditionalPropertiesVM> = emptyList()
) : FrameworkVW(MOSHI_JAVA_RECORDS, properties), JavaRecords

class AutoValue(
properties: List<AdditionalPropertiesVM> = emptyList()
properties: List<AdditionalPropertiesVM> = emptyList()
) : FrameworkVW(AUTO_VALUE, properties)

class FastJson(
properties: List<AdditionalPropertiesVM> = emptyList()
properties: List<AdditionalPropertiesVM> = emptyList()
) : FrameworkVW(FAST_JSON, properties)

class FastJsonJavaRecords(
properties: List<AdditionalPropertiesVM> = emptyList()
properties: List<AdditionalPropertiesVM> = emptyList()
) : FrameworkVW(FAST_JSON_JAVA_RECORDS, properties), JavaRecords

class Jakatra(
properties: List<AdditionalPropertiesVM> = emptyList()
properties: List<AdditionalPropertiesVM> = emptyList()
) : FrameworkVW(JAKATRA, properties)

class JakatraJavaRecords(
properties: List<AdditionalPropertiesVM> = emptyList()
properties: List<AdditionalPropertiesVM> = emptyList()
) : FrameworkVW(JAKATRA_JAVA_RECORDS, properties), JavaRecords

companion object {
Expand All @@ -138,47 +138,47 @@ sealed class FrameworkVW(
}

sealed class AdditionalPropertiesVM(
var selected: Boolean,
val propertyName: String
var selected: Boolean,
val propertyName: String
) {
class UseSetters(
selected: Boolean = false
selected: Boolean = false
) : AdditionalPropertiesVM(selected, SETTERS)

class UseGetters(
selected: Boolean = false
selected: Boolean = false
) : AdditionalPropertiesVM(selected, GETTERS)

class UseToString(
selected: Boolean = false
selected: Boolean = false
) : AdditionalPropertiesVM(selected, TO_STRING)

class UseJavaPrimitives(
selected: Boolean = false
selected: Boolean = false
) : AdditionalPropertiesVM(selected, JAVA_PRIMITIVE_TYPES)

class UseKotlinParcelable(
selected: Boolean = false
selected: Boolean = false
) : AdditionalPropertiesVM(selected, KOTLIN_PARCELABLE)

class UseKotlinSingleDataClass(
selected: Boolean = false
selected: Boolean = false
) : AdditionalPropertiesVM(selected, KOTLIN_SINGLE_DATA_CLASS)

class UseMoshiAdapterAnnotation(
selected: Boolean = false
selected: Boolean = false
) : AdditionalPropertiesVM(selected, MOSHI_ADAPTER)

class UseKotlinDataClasses(
selected: Boolean = false
selected: Boolean = false
) : AdditionalPropertiesVM(selected, KOTLIN_DATA_CLASSES)

class UseKotlinNullableFields(
selected: Boolean = false
selected: Boolean = false
) : AdditionalPropertiesVM(selected, KOTLIN_NULLABLE_FIELDS)

class UseLombokValue(
selected: Boolean = false
selected: Boolean = false
) : AdditionalPropertiesVM(selected, LOMBOK_VALUE)

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ internal class JsonArrayParser(
val existing = classesMap[key]
if (existing != null) {
value.classFields.forEach { (classKey: String, classValue: ClassField) ->
existing.classFields.putIfAbsent(classKey, classValue)
}
existing.classFields.putIfAbsent(classKey, classValue)
}
existing.classImports.addAll(value.classImports)
} else {
classesMap[key] = value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,91 +25,91 @@ import com.robohorse.robopojogenerator.utils.ClassGenerateHelper
import com.robohorse.robopojogenerator.utils.ClassTemplateHelper

internal abstract class JavaPostProcessor(
generateHelper: ClassGenerateHelper,
classTemplateHelper: ClassTemplateHelper
generateHelper: ClassGenerateHelper,
classTemplateHelper: ClassTemplateHelper
) : BasePostProcessor(generateHelper, classTemplateHelper) {

override fun applyAnnotations(
generationModel: GenerationModel,
classItem: ClassItem
generationModel: GenerationModel,
classItem: ClassItem
) = when (generationModel.annotationEnum) {
is GsonJavaRecords,
is Gson -> {
generateHelper.setAnnotations(
classItem,
PojoAnnotations.GSON.classAnnotation,
PojoAnnotations.GSON.annotation,
ImportsTemplate.GSON.imports
classItem,
PojoAnnotations.GSON.classAnnotation,
PojoAnnotations.GSON.annotation,
ImportsTemplate.GSON.imports
)
}

is LoganSquareJavaRecords,
is LoganSquare -> {
generateHelper.setAnnotations(
classItem,
PojoAnnotations.LOGAN_SQUARE.classAnnotation,
PojoAnnotations.LOGAN_SQUARE.annotation,
ImportsTemplate.LOGAN_SQUARE.imports
classItem,
PojoAnnotations.LOGAN_SQUARE.classAnnotation,
PojoAnnotations.LOGAN_SQUARE.annotation,
ImportsTemplate.LOGAN_SQUARE.imports
)
}

is JacksonJavaRecords,
is Jackson -> {
generateHelper.setAnnotations(
classItem,
PojoAnnotations.JACKSON.classAnnotation,
PojoAnnotations.JACKSON.annotation,
ImportsTemplate.JACKSON.imports
classItem,
PojoAnnotations.JACKSON.classAnnotation,
PojoAnnotations.JACKSON.annotation,
ImportsTemplate.JACKSON.imports
)
}

is Jakatra,
is JakatraJavaRecords -> {
generateHelper.setAnnotations(
classItem,
PojoAnnotations.JAKATRA.classAnnotation,
PojoAnnotations.JAKATRA.annotation,
ImportsTemplate.JAKATRA.imports
classItem,
PojoAnnotations.JAKATRA.classAnnotation,
PojoAnnotations.JAKATRA.annotation,
ImportsTemplate.JAKATRA.imports
)
}

is FastJsonJavaRecords,
is FastJson -> {
generateHelper.setAnnotations(
classItem,
PojoAnnotations.FAST_JSON.classAnnotation,
PojoAnnotations.FAST_JSON.annotation,
ImportsTemplate.FAST_JSON.imports
classItem,
PojoAnnotations.FAST_JSON.classAnnotation,
PojoAnnotations.FAST_JSON.annotation,
ImportsTemplate.FAST_JSON.imports
)
}

is AutoValue -> {
generateHelper.setAnnotations(
classItem,
PojoAnnotations.AUTO_VALUE_GSON.classAnnotation,
PojoAnnotations.AUTO_VALUE_GSON.annotation,
ImportsTemplate.AUTO_VALUE_GSON.imports
classItem,
PojoAnnotations.AUTO_VALUE_GSON.classAnnotation,
PojoAnnotations.AUTO_VALUE_GSON.annotation,
ImportsTemplate.AUTO_VALUE_GSON.imports
)
}

is MoshiJavaRecords,
is Moshi -> {
generateHelper.setAnnotations(
classItem,
PojoAnnotations.MOSHI.classAnnotation,
PojoAnnotations.MOSHI.annotation,
ImportsTemplate.MOSHI().imports
classItem,
PojoAnnotations.MOSHI.classAnnotation,
PojoAnnotations.MOSHI.annotation,
ImportsTemplate.MOSHI().imports
)
}

is NoneLombok -> {
val annotations = PojoAnnotations.Lombok(generationModel.useLombokValue)
val importsTemplate = ImportsTemplate.Lombok(generationModel.useLombokValue)
generateHelper.setAnnotations(
classItem,
annotations.classAnnotation,
annotations.annotation,
importsTemplate.imports
classItem,
annotations.classAnnotation,
annotations.annotation,
importsTemplate.imports
)
}

Expand Down
Loading

0 comments on commit a695669

Please sign in to comment.