Skip to content

Commit

Permalink
revert to IppAttributeBuilder and 'data' to fix failing equals-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gmuth committed Feb 19, 2024
1 parent b1e4823 commit bb1e982
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 7 deletions.
11 changes: 8 additions & 3 deletions src/main/kotlin/de/gmuth/ipp/attributes/DocumentFormat.kt
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package de.gmuth.ipp.attributes

/**
* Copyright (c) 2020-2024 Gerhard Muth
* Copyright (c) 2020-2023 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(mediaMimeType: String) :
IppAttribute<String>("document-format", MimeMediaType, mediaMimeType) {
class DocumentFormat(val mediaMimeType: String) : IppAttributeBuilder {

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

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

}
9 changes: 8 additions & 1 deletion src/main/kotlin/de/gmuth/ipp/attributes/Media.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ 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

class Media(val keyword: String) : IppAttribute<String>("media", Keyword, keyword) {
class Media(val keyword: String) : IppAttributeBuilder {

companion object {
@JvmField
val ISO_A3 = Media("iso_a3_297x420mm")
Expand All @@ -30,4 +33,8 @@ class Media(val keyword: String) : IppAttribute<String>("media", Keyword, keywor
@JvmField
val NA_LEDGER = Media("na_ledger_11x17in")
}

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

}
7 changes: 6 additions & 1 deletion src/main/kotlin/de/gmuth/ipp/attributes/MediaSource.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ 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) : IppAttribute<String>("media-source", Keyword, keyword) {
data class MediaSource(val keyword: String) : IppAttributeBuilder {

companion object {
@JvmField
Expand All @@ -32,6 +34,9 @@ data class MediaSource(val keyword: String) : IppAttribute<String>("media-source
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/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

open class IppAttribute<T>(val name: String, val tag: IppTag) : IppAttributeBuilder {
data 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.
class IppCollection(val members: MutableCollection<IppAttribute<*>> = mutableListOf()) {
data class IppCollection(val members: MutableCollection<IppAttribute<*>> = mutableListOf()) {

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

Expand Down

0 comments on commit bb1e982

Please sign in to comment.