Skip to content

Commit

Permalink
refactored ColorMode from enum to class to support optional values as…
Browse files Browse the repository at this point in the history
… well, e.g. ColorMode("highlight")
  • Loading branch information
gmuth committed Oct 10, 2023
1 parent 07e2d3e commit 547d44e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
16 changes: 12 additions & 4 deletions src/main/kotlin/de/gmuth/ipp/attributes/ColorMode.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,19 @@ import de.gmuth.ipp.core.IppAttributesGroup
import de.gmuth.ipp.core.IppException
import de.gmuth.ipp.core.IppTag.Keyword

enum class ColorMode(private val keyword: String) : IppAttributeBuilder {
// https://ftp.pwg.org/pub/pwg/candidates/cs-ippjobprinterext3v10-20120727-5100.13.pdf - 5.2.3
class ColorMode(private val keyword: String) : IppAttributeBuilder {

Auto("auto"),
Color("color"),
Monochrome("monochrome");
companion object {
@JvmField
val Auto = ColorMode("auto")

@JvmField
val Color = ColorMode("color")

@JvmField
val Monochrome = ColorMode("monochrome")
}

override fun buildIppAttribute(printerAttributes: IppAttributesGroup) = IppAttribute(
when { // use job-creation-attributes-supported? // 5100.11
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/de/gmuth/ipp/iana/IppRegistrationsSection2.kt
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ object IppRegistrationsSection2 {

}

private val attributesMap: Map<String, Attribute>
private val aliasMap: Map<String, String>
internal val attributesMap: Map<String, Attribute>
internal val aliasMap: Map<String, String>

init {
// source: https://www.iana.org/assignments/ipp-registrations/ipp-registrations-2.csv
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/de/gmuth/ipp/iana/IppRegistrationsSection6.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ object IppRegistrationsSection6 {
override fun toString() = "$attribute/$value ($syntax) = $name $reference "
}

private val enumAttributeValuesMap: Map<String, EnumAttributeValue>
private val aliasMap: Map<String, String>
internal val enumAttributeValuesMap: Map<String, EnumAttributeValue>
internal val aliasMap: Map<String, String>

init {
// source: https://www.iana.org/assignments/ipp-registrations/ipp-registrations-6.csv
Expand Down

0 comments on commit 547d44e

Please sign in to comment.