Skip to content

Commit

Permalink
return optionally replaced attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
gmuth committed Dec 20, 2024
1 parent 4664497 commit edf8ea9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/kotlin/de/gmuth/ipp/core/IppAttributesGroup.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ class IppAttributesGroup(val tag: IppTag) : LinkedHashMap<String, IppAttribute<*
require(tag.isGroupTag(), { "'$tag' is not a group tag" })
}

fun put(attribute: IppAttribute<*>) {
fun put(attribute: IppAttribute<*>) =
if (containsKey(attribute.name)) {
if (replaceEnabled) { // some implementations do not follow the IPP specification
put(attribute.name, attribute).also {
logger.fine { "$name: '$it' replaced with '${attribute.values.joinToString(",")}'" }
}
} else {
logger.fine { "Ignored replacement attribute: $attribute" }
null
}
} else {
put(attribute.name, attribute)
}
}

fun attribute(name: String, tag: IppTag, vararg values: Any) =
IppAttribute(name, tag, values.toList()).also { put(it) }
Expand Down

0 comments on commit edf8ea9

Please sign in to comment.