org.dbtools.codegen.kotlin.KotlinEnum.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dbtools-gen Show documentation
Show all versions of dbtools-gen Show documentation
DBTools ORM Class Generator.
/*
* KotlinEnum.kt
*
* Created on Nov 7, 2015
*
* Copyright 2007 Jeff Campbell. All rights reserved. Unauthorized reproduction
* is a violation of applicable law. This material contains certain
* confidential or proprietary information and trade secrets of Jeff Campbell.
*/
package org.dbtools.codegen.kotlin
import java.util.*
@SuppressWarnings("PMD.UseStringBufferForStringAppends")
class KotlinEnum : KotlinClass {
private val enums = ArrayList();
constructor(name: String, enums: List) : super(name, classType = KotlinClassType.ENUM) {
setEnums(enums)
}
constructor(name: String, packageName: String, enums: List) : super(name, packageName, KotlinClassType.ENUM) {
setEnums(enums)
}
fun getEnums(): List {
return Collections.unmodifiableList(enums)
}
fun setEnums(enums: List) {
if (enums.isEmpty()) {
throw IllegalArgumentException("enums cannot be null or empty")
}
this.enums.clear()
this.enums.addAll(enums)
}
override fun buildPostClassHeader(): String {
var enumStr = ""
var count = 0
for (enumItem in enums) {
if (count > 0) {
enumStr += ", "
}
enumStr += enumItem
count++
}
enumStr += ";\n"
return enumStr
}
}