Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix warning Classes that contain only a companion object should be re… #28710

Merged
merged 1 commit into from
Aug 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 19 additions & 21 deletions src/controller/java/src/chip/onboardingpayload/Verhoeff.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,27 @@

package chip.onboardingpayload

class Verhoeff {
companion object {
fun dihedralMultiply(x: Int, y: Int, n: Int): Int {
val n2 = n * 2
var newX = x % n2
var newY = y % n2
if (newX < n) {
if (newY < n) return (newX + newY) % n
return ((newX + (newY - n)) % n) + n
}
if (newY < n) return ((n + (newX - n) - newY) % n) + n
return (n + (newX - n) - (newY - n)) % n
object Verhoeff {
fun dihedralMultiply(x: Int, y: Int, n: Int): Int {
val n2 = n * 2
var newX = x % n2
var newY = y % n2
if (newX < n) {
if (newY < n) return (newX + newY) % n
return ((newX + (newY - n)) % n) + n
}
if (newY < n) return ((n + (newX - n) - newY) % n) + n
return (n + (newX - n) - (newY - n)) % n
}

fun dihedralInvert(value: Int, n: Int): Int {
if (value > 0 && value < n) return n - value
return value
}
fun dihedralInvert(value: Int, n: Int): Int {
if (value > 0 && value < n) return n - value
return value
}

fun permute(value: Int, permTable: ByteArray, permTableLen: Int, iterCount: Int): Int {
var newValue = value % permTableLen
if (iterCount == 0) return newValue
return permute(permTable[newValue].toInt(), permTable, permTableLen, iterCount - 1)
}
fun permute(value: Int, permTable: ByteArray, permTableLen: Int, iterCount: Int): Int {
var newValue = value % permTableLen
if (iterCount == 0) return newValue
return permute(permTable[newValue].toInt(), permTable, permTableLen, iterCount - 1)
}
}