Skip to content

Commit

Permalink
Remove unnecessary Serializable declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
SgtSilvio committed Jul 14, 2024
1 parent d9c6e8b commit f4a7d71
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package io.github.sgtsilvio.gradle.oci.mapping

import java.io.Serializable

/**
* @author Silvio Giebl
*/
internal data class Coordinates(val group: String, val name: String) : Comparable<Coordinates>, Serializable {
internal data class Coordinates(val group: String, val name: String) : Comparable<Coordinates> {
override fun compareTo(other: Coordinates): Int {
group.compareTo(other.group).also { if (it != 0) return it }
return name.compareTo(other.name)
Expand All @@ -17,7 +15,7 @@ internal data class Coordinates(val group: String, val name: String) : Comparabl
internal data class VersionedCoordinates(
val coordinates: Coordinates,
val version: String,
) : Comparable<VersionedCoordinates>, Serializable {
) : Comparable<VersionedCoordinates> {
val group get() = coordinates.group
val name get() = coordinates.name

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package io.github.sgtsilvio.gradle.oci.metadata
import io.github.sgtsilvio.gradle.oci.internal.json.JsonObject
import org.apache.commons.codec.binary.Hex
import java.io.OutputStream
import java.io.Serializable
import java.security.DigestOutputStream
import java.security.MessageDigest
import kotlin.contracts.ExperimentalContracts
Expand Down Expand Up @@ -33,7 +32,7 @@ enum class OciDigestAlgorithm(val id: String, val standardName: String, private
internal fun createMessageDigest(): MessageDigest = MessageDigest.getInstance(standardName)
}

data class OciDigest(val algorithm: OciDigestAlgorithm, val hash: ByteArray) : Serializable {
data class OciDigest(val algorithm: OciDigestAlgorithm, val hash: ByteArray) {
val encodedHash get() = algorithm.encode(hash)

init {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.github.sgtsilvio.gradle.oci.metadata

import java.io.Serializable
import java.time.Instant
import java.util.*

Expand All @@ -25,20 +24,20 @@ class OciMetadata(
val manifestDescriptorAnnotations: SortedMap<String, String>,
val indexAnnotations: SortedMap<String, String>,
val layers: List<OciLayerMetadata>,
) : Serializable
)

class OciLayerMetadata(
val descriptor: OciLayerDescriptor?,
val creationTime: Instant?,
val author: String?,
val createdBy: String?,
val comment: String?,
) : Serializable
)

class OciLayerDescriptor(
override val mediaType: String,
override val digest: OciDigest,
override val size: Long,
val diffId: OciDigest,
override val annotations: SortedMap<String, String>,
) : OciDescriptor, Serializable
) : OciDescriptor
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package io.github.sgtsilvio.gradle.oci.metadata

import java.io.Serializable
import java.time.Instant

/**
* @author Silvio Giebl
*/
internal class OciMetadataBuilder : Serializable {
internal class OciMetadataBuilder {
private var imageReference: OciImageReference? = null
private var creationTime: SerializableInstant? = null
private var author: String? = null
Expand Down Expand Up @@ -64,7 +63,7 @@ internal class OciMetadataBuilder : Serializable {
)
}

internal class OciLayerMetadataBuilder : Serializable {
internal class OciLayerMetadataBuilder {
private var descriptor: OciLayerDescriptor? = null
private var creationTime: SerializableInstant? = null
private var author: String? = null
Expand All @@ -80,7 +79,7 @@ internal class OciLayerMetadataBuilder : Serializable {
fun build() = OciLayerMetadata(descriptor, creationTime?.toInstant(), author, createdBy, comment)
}

internal class OciLayerDescriptorBuilder : Serializable {
internal class OciLayerDescriptorBuilder {
private var mediaType: String? = null
private var digest: OciDigest? = null
private var size: Long? = null
Expand All @@ -105,7 +104,7 @@ internal class OciLayerDescriptorBuilder : Serializable {
}
}

private class SerializableInstant(val epochSecond: Long, val nano: Int) : Serializable
private class SerializableInstant(val epochSecond: Long, val nano: Int)

private fun Instant.toSerializableInstant() = SerializableInstant(epochSecond, nano)

Expand Down

0 comments on commit f4a7d71

Please sign in to comment.