Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -120,18 +120,15 @@ trait EnumValue extends EnumValueBase {
override lazy val toString = {
val theVal = this
val cn = getNameFromClass(this)
val en = cn match {
//
// Special case for CalendarFirstDayOfWeek
//
case "Sunday" | "Monday" | "Tuesday" | "Wednesday" | "Thursday" | "Friday" | "Saturday" =>
cn
case _ => Misc.toInitialLowerCaseUnlessAllUpperCase(cn)
}
val en = Misc.toInitialLowerCaseUnlessAllUpperCase(cn)
en
}
}

trait EnumValueSimple extends EnumValueBase {
override def toString = getNameFromClass(this)
}

/**
* base mixin for traits representing collections of DFDL properties
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ class PropertyGenerator(arg: Node) {

val dfdlSchema = arg

val enumSimpleTypes = List(
"CalendarFirstDayOfWeek"
)

val excludedTypes = List(
"AlignmentType",
"BinaryBooleanFalseRepType",
Expand Down Expand Up @@ -72,6 +76,10 @@ class PropertyGenerator(arg: Node) {
excludedAttributes.exists { _.toUpperCase == name.toUpperCase() }
}

def replaceEnumClass(name: String) = {
enumSimpleTypes.exists { _.toUpperCase == name.toUpperCase() }
}

def generate() = {
val res = genAll()
res
Expand Down Expand Up @@ -380,7 +388,6 @@ class PropertyGenerator(arg: Node) {
* }
* </pre>
*/

val templateStart =
"""sealed trait Currency extends EnumValue
object Currency extends Enum[Currency] {
Expand Down Expand Up @@ -479,7 +486,12 @@ trait CurrencyMixin extends PropertyMixin {
val pvalueIDs = pvalues.map(pvalue => initialUpperCase(pvalue))
val mids = pvalueIDs.map(id => middle.replace("EUR", id))
val values = pvalueIDs.mkString(" override lazy val values = Array(", ", ", ")\n")
val start = templateStart.replaceAll("Currency", traitName)
val start0 = templateStart.replaceAll("Currency", traitName)
val start = if (replaceEnumClass(traitName)) {
start0.replace("EnumValue", "EnumValueSimple")
} else {
start0
}
val end = templateEnd.replaceAll("Currency", traitName).replaceAll("currency", propName)
val mixin =
if (excludeRuntimeProperties(propName)) "\n"
Expand Down
Loading