Skip to content

Commit

Permalink
refactor to use IppAttribute instead of IppAttributeBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
gmuth committed Feb 19, 2024
1 parent 6efa292 commit 63c483d
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 17 deletions.
11 changes: 3 additions & 8 deletions src/main/kotlin/de/gmuth/ipp/attributes/DocumentFormat.kt
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package de.gmuth.ipp.attributes

/**
* Copyright (c) 2020-2023 Gerhard Muth
* Copyright (c) 2020-2024 Gerhard Muth
*/

import de.gmuth.ipp.core.IppAttribute
import de.gmuth.ipp.core.IppAttributeBuilder
import de.gmuth.ipp.core.IppAttributesGroup
import de.gmuth.ipp.core.IppTag.MimeMediaType

class DocumentFormat(val mediaMimeType: String) : IppAttributeBuilder {
class DocumentFormat(mediaMimeType: String) :
IppAttribute<String>("document-format", MimeMediaType, mediaMimeType) {

companion object {
// application
Expand Down Expand Up @@ -39,8 +38,4 @@ class DocumentFormat(val mediaMimeType: String) : IppAttributeBuilder {
@JvmField
val HP_PCL = DocumentFormat("vnd.hp-PCL")
}

override fun buildIppAttribute(printerAttributes: IppAttributesGroup) =
IppAttribute("document-format", MimeMediaType, mediaMimeType)

}
7 changes: 1 addition & 6 deletions src/main/kotlin/de/gmuth/ipp/attributes/MediaSource.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ package de.gmuth.ipp.attributes
*/

import de.gmuth.ipp.core.IppAttribute
import de.gmuth.ipp.core.IppAttributeBuilder
import de.gmuth.ipp.core.IppAttributesGroup
import de.gmuth.ipp.core.IppTag.Keyword

data class MediaSource(val keyword: String) : IppAttributeBuilder {
data class MediaSource(val keyword: String) : IppAttribute<String>("media-source", Keyword, keyword) {

companion object {
@JvmField
Expand All @@ -34,9 +32,6 @@ data class MediaSource(val keyword: String) : IppAttributeBuilder {
val LargeCapacity = MediaSource("large-capacity")
}

override fun buildIppAttribute(printerAttributes: IppAttributesGroup) =
IppAttribute("media-source", Keyword, keyword)

override fun toString() = keyword

}
2 changes: 1 addition & 1 deletion src/main/kotlin/de/gmuth/ipp/attributes/Sides.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ enum class Sides(private val keyword: String) : IppAttributeBuilder {
TwoSidedShortEdge("two-sided-short-edge");

override fun buildIppAttribute(printerAttributes: IppAttributesGroup) =
IppAttribute("sides", Keyword, keyword)
IppAttribute("sides", Keyword, keyword)

}
2 changes: 1 addition & 1 deletion src/main/kotlin/de/gmuth/ipp/core/IppAttribute.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import java.util.logging.Level.INFO
import java.util.logging.Logger
import java.util.logging.Logger.getLogger

data class IppAttribute<T>(val name: String, val tag: IppTag) : IppAttributeBuilder {
open class IppAttribute<T>(val name: String, val tag: IppTag) : IppAttributeBuilder {

private val logger = getLogger(javaClass.name)

Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/de/gmuth/ipp/core/IppCollection.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import java.util.logging.Level.INFO
import java.util.logging.Logger

// RFC8010 3.1.6.
data class IppCollection(val members: MutableCollection<IppAttribute<*>> = mutableListOf()) {
class IppCollection(val members: MutableCollection<IppAttribute<*>> = mutableListOf()) {

constructor(vararg attributes: IppAttribute<*>) : this(attributes.toMutableList())

Expand Down

0 comments on commit 63c483d

Please sign in to comment.