diff --git a/klanglicht-module-dmx/pom.xml b/klanglicht-module-dmx/pom.xml index dd4b244..4bae9c2 100644 --- a/klanglicht-module-dmx/pom.xml +++ b/klanglicht-module-dmx/pom.xml @@ -27,21 +27,11 @@ - - org.apache.commons - commons-lang3 - 3.12.0 - commons-codec commons-codec 1.15 - - com.google.guava - guava - 31.1-jre - diff --git a/klanglicht-module-dmx/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/color/RGBAColor.kt b/klanglicht-module-dmx/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/color/RGBAColor.kt index bb0556e..4b9f587 100644 --- a/klanglicht-module-dmx/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/color/RGBAColor.kt +++ b/klanglicht-module-dmx/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/color/RGBAColor.kt @@ -1,6 +1,5 @@ package de.visualdigits.kotlin.klanglicht.model.color -import org.apache.commons.lang3.StringUtils import java.lang.Long.decode import kotlin.math.min import kotlin.math.roundToInt @@ -28,7 +27,7 @@ class RGBAColor( constructor(hex: String) : this(decode(if (hex.startsWith("#") || hex.startsWith("0x")) hex else "#$hex")) override fun toString(): String { - return "[" + StringUtils.join(listOf(red, green, blue, amber), ", ") + "]" + return "[" + listOf(red, green, blue, amber).joinToString(", ") + "]" } override fun repr(): String { @@ -55,7 +54,7 @@ class RGBAColor( override fun value(): Long = (red.toLong() shl 24) or (green.toLong() shl 16) or (blue.toLong() shl 8) or amber.toLong() - override fun hex(): String = StringUtils.leftPad(java.lang.Long.toHexString(value()), 8, '0') + override fun hex(): String = java.lang.Long.toHexString(value()).padStart(8, '0') override fun web(): String = "#${hex()}" diff --git a/klanglicht-module-dmx/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/color/RGBBaseColor.kt b/klanglicht-module-dmx/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/color/RGBBaseColor.kt index 3230af0..ac7f49a 100644 --- a/klanglicht-module-dmx/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/color/RGBBaseColor.kt +++ b/klanglicht-module-dmx/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/color/RGBBaseColor.kt @@ -1,6 +1,5 @@ package de.visualdigits.kotlin.klanglicht.model.color -import org.apache.commons.lang3.StringUtils import java.lang.Long.decode import java.lang.Long.toHexString import kotlin.math.max @@ -23,7 +22,7 @@ abstract class RGBBaseColor>( constructor(hex: String) : this(decode(if (hex.startsWith("#") || hex.startsWith("0x")) hex else "#$hex")) override fun toString(): String { - return "[" + StringUtils.join(listOf(red, green, blue), ", ") + "]" + return "[" + listOf(red, green, blue).joinToString(", ") + "]" } open fun repr(): String { @@ -50,7 +49,7 @@ abstract class RGBBaseColor>( override fun value(): Long = red.toLong() shl 16 or (green.toLong() shl 8) or blue.toLong() - override fun hex(): String = StringUtils.leftPad(toHexString(value()), 6, '0') + override fun hex(): String = toHexString(value()).padStart( 6, '0') override fun web(): String = "#${hex()}" diff --git a/klanglicht-module-dmx/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/color/RGBWAColor.kt b/klanglicht-module-dmx/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/color/RGBWAColor.kt index e9e788d..339f9cf 100644 --- a/klanglicht-module-dmx/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/color/RGBWAColor.kt +++ b/klanglicht-module-dmx/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/color/RGBWAColor.kt @@ -1,7 +1,7 @@ package de.visualdigits.kotlin.klanglicht.model.color -import org.apache.commons.lang3.StringUtils import java.lang.Long.decode +import java.lang.Long.toHexString import kotlin.math.min import kotlin.math.roundToInt @@ -24,7 +24,7 @@ class RGBWAColor( constructor(hex: String) : this(decode(if (hex.startsWith("#") || hex.startsWith("0x")) hex else "#$hex")) override fun toString(): String { - return "[" + StringUtils.join(listOf(red, green, blue, white, amber), ", ") + "]" + return "[" +listOf(red, green, blue, white, amber).joinToString(", ") + "]" } override fun repr(): String { @@ -53,7 +53,7 @@ class RGBWAColor( override fun value(): Long = (red.toLong() shl 32) or (green.toLong() shl 24) or (blue.toLong() shl 16) or (white.toLong() shl 8) or amber.toLong() - override fun hex(): String = StringUtils.leftPad(java.lang.Long.toHexString(value()), 10, '0') + override fun hex(): String = toHexString(value()).padStart( 10, '0') override fun web(): String = "#${hex()}" diff --git a/klanglicht-module-dmx/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/color/RGBWColor.kt b/klanglicht-module-dmx/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/color/RGBWColor.kt index 8f1447e..f787b40 100644 --- a/klanglicht-module-dmx/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/color/RGBWColor.kt +++ b/klanglicht-module-dmx/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/color/RGBWColor.kt @@ -1,7 +1,7 @@ package de.visualdigits.kotlin.klanglicht.model.color -import org.apache.commons.lang3.StringUtils import java.lang.Long.decode +import java.lang.Long.toHexString import kotlin.math.min import kotlin.math.roundToInt @@ -31,7 +31,7 @@ class RGBWColor( } override fun toString(): String { - return "[" + StringUtils.join(listOf(red, green, blue, white), ", ") + "]" + return "[" + listOf(red, green, blue, white).joinToString(", ") + "]" } override fun repr(): String { @@ -58,7 +58,7 @@ class RGBWColor( override fun value(): Long = (red.toLong() shl 24) or (green.toLong() shl 16) or (blue.toLong() shl 8) or white.toLong() - override fun hex(): String = StringUtils.leftPad(java.lang.Long.toHexString(value()), 8, '0') + override fun hex(): String = toHexString(value()).padStart(8, '0') override fun web(): String = "#${hex()}" diff --git a/klanglicht-module-dmx/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/dmx/DmxFrame.kt b/klanglicht-module-dmx/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/dmx/DmxFrame.kt index 05ddc88..3cb3381 100644 --- a/klanglicht-module-dmx/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/dmx/DmxFrame.kt +++ b/klanglicht-module-dmx/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/dmx/DmxFrame.kt @@ -1,7 +1,6 @@ package de.visualdigits.kotlin.klanglicht.model.dmx -import com.google.common.primitives.Bytes -import org.apache.commons.lang3.StringUtils +import java.lang.Integer.toHexString import java.util.Arrays @@ -38,7 +37,7 @@ class DmxFrame( /** * Returns the bytes for a complete frame including header and footer. */ - fun getFrameBytes(): ByteArray = Bytes.concat(header, data, footer) + fun getFrameBytes(): ByteArray = header + data + footer /** * Sets all data bytes to 0. @@ -58,9 +57,9 @@ class DmxFrame( fun dump(): String { val l: MutableList = ArrayList() for (b in data) { - l.add("0x" + StringUtils.leftPad(Integer.toHexString(b.toInt() and 0xff), 2, '0')) + l.add("0x" + toHexString(b.toInt() and 0xff).padStart( 2, '0')) } - return StringUtils.join(l, ", ") + return l.joinToString(", ") } fun clear() { diff --git a/klanglicht-module-dmx/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/dmx/DmxInterface.kt b/klanglicht-module-dmx/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/dmx/DmxInterface.kt index 80578e5..371985b 100644 --- a/klanglicht-module-dmx/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/dmx/DmxInterface.kt +++ b/klanglicht-module-dmx/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/dmx/DmxInterface.kt @@ -2,7 +2,7 @@ package de.visualdigits.kotlin.klanglicht.model.dmx import jssc.SerialPort import jssc.SerialPortException -import org.apache.commons.lang3.StringUtils +import java.lang.Integer.toHexString open class DmxInterface { @@ -28,7 +28,7 @@ open class DmxInterface { fun repr(): String { val lst = ArrayList() for (b in dmxFrame.getFrameBytes()) { - lst.add(StringUtils.leftPad(Integer.toHexString(b.toInt()), 8, '0')) + lst.add(toHexString(b.toInt()).padStart( 8, '0')) } return lst.toString() } @@ -39,7 +39,7 @@ open class DmxInterface { * @param portName The port name (i.e. 'COM9'. */ open fun open(portName: String) { - if (serialPort == null && !StringUtils.isEmpty(portName)) { + if (serialPort == null && portName.isNotEmpty()) { try { serialPort = SerialPort(portName) serialPort?.openPort() diff --git a/klanglicht-module-dmx/src/test/kotlin/de/visualdigits/kotlin/klanglicht/model/hybrid/HybridDmxSceneTest.kt b/klanglicht-module-dmx/src/test/kotlin/de/visualdigits/kotlin/klanglicht/model/hybrid/HybridDmxSceneTest.kt index 6fd4521..e424d47 100644 --- a/klanglicht-module-dmx/src/test/kotlin/de/visualdigits/kotlin/klanglicht/model/hybrid/HybridDmxSceneTest.kt +++ b/klanglicht-module-dmx/src/test/kotlin/de/visualdigits/kotlin/klanglicht/model/hybrid/HybridDmxSceneTest.kt @@ -1,7 +1,7 @@ package de.visualdigits.kotlin.klanglicht.model.hybrid import de.visualdigits.kotlin.klanglicht.model.preferences.Preferences -import org.apache.commons.lang3.SystemUtils +import de.visualdigits.kotlin.util.SystemUtils import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import java.io.File diff --git a/klanglicht-module-dmx/src/test/kotlin/de/visualdigits/kotlin/klanglicht/model/preferences/PreferencesTest.kt b/klanglicht-module-dmx/src/test/kotlin/de/visualdigits/kotlin/klanglicht/model/preferences/PreferencesTest.kt index 2b5099f..4d9e456 100644 --- a/klanglicht-module-dmx/src/test/kotlin/de/visualdigits/kotlin/klanglicht/model/preferences/PreferencesTest.kt +++ b/klanglicht-module-dmx/src/test/kotlin/de/visualdigits/kotlin/klanglicht/model/preferences/PreferencesTest.kt @@ -3,8 +3,6 @@ package de.visualdigits.kotlin.klanglicht.model.preferences import com.fasterxml.jackson.databind.SerializationFeature import com.fasterxml.jackson.module.kotlin.jacksonMapperBuilder import de.visualdigits.kotlin.klanglicht.model.hybrid.HybridScene -import org.apache.commons.lang3.SystemUtils -import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Assertions.assertNotNull import org.junit.jupiter.api.Test import java.io.File diff --git a/klanglicht-rest/pom.xml b/klanglicht-rest/pom.xml index 4a56df9..336b9d9 100644 --- a/klanglicht-rest/pom.xml +++ b/klanglicht-rest/pom.xml @@ -38,11 +38,11 @@ - + org.apache.commons commons-math3 diff --git a/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/configuration/ConfigHolder.kt b/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/configuration/ConfigHolder.kt index b36e9cc..ac8f809 100644 --- a/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/configuration/ConfigHolder.kt +++ b/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/configuration/ConfigHolder.kt @@ -3,10 +3,9 @@ package de.visualdigits.kotlin.klanglicht.rest.configuration import de.visualdigits.kotlin.klanglicht.model.hybrid.HybridScene import de.visualdigits.kotlin.klanglicht.model.parameter.Fadeable import de.visualdigits.kotlin.klanglicht.model.preferences.Preferences +import de.visualdigits.kotlin.util.SystemUtils import jakarta.annotation.PostConstruct import jakarta.annotation.PreDestroy -import kotlinx.coroutines.runBlocking -import org.apache.commons.lang3.SystemUtils import org.slf4j.Logger import org.slf4j.LoggerFactory import org.springframework.stereotype.Component diff --git a/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/lightmanager/feign/LightmanagerClient.kt b/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/lightmanager/feign/LightmanagerClient.kt index aebb72b..bbda23c 100644 --- a/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/lightmanager/feign/LightmanagerClient.kt +++ b/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/lightmanager/feign/LightmanagerClient.kt @@ -9,7 +9,6 @@ import de.visualdigits.kotlin.klanglicht.rest.lightmanager.model.html.LMScene import de.visualdigits.kotlin.klanglicht.rest.lightmanager.model.html.LMScenes import de.visualdigits.kotlin.klanglicht.rest.lightmanager.model.html.LMZones import jakarta.annotation.PostConstruct -import org.apache.commons.lang3.StringUtils import org.jsoup.Jsoup import org.springframework.beans.factory.annotation.Autowired import org.springframework.stereotype.Component @@ -25,7 +24,7 @@ class LightmanagerClient( @PostConstruct fun initialize() { - if (StringUtils.isEmpty(lightmanagerUrl)) { + if (lightmanagerUrl?.isEmpty() == true) { lightmanagerUrl = configHolder!!.preferences?.getService("lmair")?.url } client = LightmanagerFeignClient.client(lightmanagerUrl) @@ -108,8 +107,8 @@ class LightmanagerClient( LMMarker( id = id, name = elem.text(), - colorOff = if (StringUtils.isNotEmpty(colorOff)) colorOff else COLOR_OFF, - colorOn = if (StringUtils.isNotEmpty(colorOn)) colorOn else COLOR_ON, + colorOff = colorOff.ifEmpty { COLOR_OFF }, + colorOn = colorOn.ifEmpty { COLOR_ON }, state = markerState[id], separate = false, actorId = "", diff --git a/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/lightmanager/model/html/LMActor.kt b/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/lightmanager/model/html/LMActor.kt index 79ad46e..475103c 100644 --- a/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/lightmanager/model/html/LMActor.kt +++ b/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/lightmanager/model/html/LMActor.kt @@ -3,7 +3,6 @@ package de.visualdigits.kotlin.klanglicht.rest.lightmanager.model.html import com.fasterxml.jackson.annotation.JsonIgnore import de.visualdigits.kotlin.klanglicht.rest.configuration.ConfigHolder import de.visualdigits.kotlin.klanglicht.rest.lightmanager.feign.LightmanagerClient -import org.apache.commons.lang3.StringUtils class LMActor( var id: Int? = null, @@ -77,18 +76,18 @@ class LMActor( colorOn = marker?.colorOn isSeparate = marker?.separate } - else if (!markers.isEmpty()) { + else if (markers.isNotEmpty()) { hasSeparateMarkers = true } - if (StringUtils.isEmpty(colorOff)) { + if (colorOff?.isEmpty() == true) { colorOff = - if (StringUtils.isNotEmpty(colorOff)) colorOff else LightmanagerClient.COLOR_OFF + colorOff.ifEmpty { LightmanagerClient.COLOR_OFF } } - if (StringUtils.isEmpty(colorOn)) { - colorOn = if (StringUtils.isNotEmpty(colorOn)) colorOn else LightmanagerClient.COLOR_ON + if (colorOn?.isEmpty() == true) { + colorOn = colorOn.ifEmpty { LightmanagerClient.COLOR_ON } } val lmRequests = requests.values.toList() - if (!lmRequests.isEmpty() && lmRequests.first() is LMDefaultRequest) { + if (lmRequests.isNotEmpty() && lmRequests.first() is LMDefaultRequest) { if (hasSeparateMarkers == true || isSeparate == true) { sb.append("
\n") // Collections.reverse(lmRequests); @@ -116,8 +115,7 @@ class LMActor( else { val rq0 = lmRequests.first() as LMDefaultRequest val smkState0 = determineSmkState(rq0) - var rq: LMRequest? = null - rq = if (markerIsOn == true && !smkState0 || markerIsOn != true && smkState0) { + val rq: LMRequest? = if (markerIsOn == true && !smkState0 || markerIsOn != true && smkState0) { rq0 } else if (lmRequests.size > 1) { @@ -215,7 +213,7 @@ class LMActor( fun addMarker(marker: LMMarker?) { var markerState = marker?.markerState!! - if (StringUtils.isEmpty(markerState)) { + if (markerState.isEmpty()) { markerState = "unified" } markers[markerState] = marker diff --git a/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/lightmanager/model/html/LMMarkers.kt b/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/lightmanager/model/html/LMMarkers.kt index c2c67a5..97dc107 100644 --- a/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/lightmanager/model/html/LMMarkers.kt +++ b/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/lightmanager/model/html/LMMarkers.kt @@ -1,7 +1,5 @@ package de.visualdigits.kotlin.klanglicht.rest.lightmanager.model.html -import org.apache.commons.lang3.StringUtils - class LMMarkers( var name: String? = null, var markers: MutableMap = mutableMapOf() @@ -10,7 +8,7 @@ class LMMarkers( val attributes = LMNamedAttributes(marker.name, "separate", "actorId", "state") if (attributes.matched()) { val name = attributes.name - if (StringUtils.isNotEmpty(name)) { + if (name?.isNotEmpty() == true) { marker.name = name } marker.separate = attributes.getOrDefault("separate", "false").toBoolean() diff --git a/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/lightmanager/model/html/LMScene.kt b/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/lightmanager/model/html/LMScene.kt index 636de35..613c3bb 100644 --- a/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/lightmanager/model/html/LMScene.kt +++ b/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/lightmanager/model/html/LMScene.kt @@ -1,7 +1,6 @@ package de.visualdigits.kotlin.klanglicht.rest.lightmanager.model.html import de.visualdigits.kotlin.klanglicht.rest.configuration.ConfigHolder -import org.apache.commons.lang3.StringUtils class LMScene( @@ -17,7 +16,7 @@ class LMScene( val lightmanagerUrl = configHolder.preferences?.getService("lmair")?.url val sb = StringBuilder() sb.append("
= mutableListOf("Dmx", "Deko", "Rgbw", "Bar", "Starwars") @JsonIgnore - val scenes: Multimap = LinkedListMultimap.create() + val scenes: MultiValueMap = LinkedMultiValueMap() + fun add(scene: LMScene) { var group: String? = "common" val attributes = LMNamedAttributes(scene.name, "group", "color") if (attributes.matched()) { val name = attributes.name - if (StringUtils.isNotEmpty(name)) { + if (name?.isNotEmpty() == true) { scene.name = name } val g = attributes["group"] - if (StringUtils.isNotEmpty(g)) { + if (g.isNotEmpty()) { group = g } scene.color = attributes["color"] } if ("hidden" != group) { - scenes.put(StringUtils.capitalize(group), scene) + group?.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() } + ?.let { scenes.add(it, scene) } } } @@ -52,8 +54,8 @@ class LMScenes( sb.append("
\n") renderLabel(sb, "S C E N E S") - val scenesMap: Map> = TreeMap>(scenes.asMap()) - scenesMap.forEach { (group: String, groupScenes: Collection) -> + val scenesMap: Map> = TreeMap>(scenes.toMap()) + scenesMap.forEach { (group: String, groupScenes: List) -> renderScenesGroup( sb, configHolder, @@ -88,7 +90,7 @@ class LMScenes( sb: StringBuilder, configHolder: ConfigHolder, group: String, - groupScenes: Collection + groupScenes: List ) { val hasColorWheel = COLOR_WHEEL_GROUPS.contains(group) sb.append("