Skip to content

Commit 1b7ddd6

Browse files
authored
Merge pull request #1009 from Kotlin/dataframe-html-data-normal-class
Convert `DataFrameHtmlData` to normal class
2 parents 71b5b57 + dd135e6 commit 1b7ddd6

File tree

1 file changed

+35
-5
lines changed
  • core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io

1 file changed

+35
-5
lines changed

core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/html.kt

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -570,13 +570,13 @@ public fun <T> DataFrame<T>.toHTML(
570570
}
571571

572572
/**
573-
* Container for HTML page data in form of String
573+
* Container for HTML page data in the form of a String
574574
* Can be used to compose rendered dataframe tables with additional HTML elements
575575
*/
576-
public data class DataFrameHtmlData(
577-
@Language("css") val style: String = "",
578-
@Language("html", prefix = "<body>", suffix = "</body>") val body: String = "",
579-
@Language("js") val script: String = "",
576+
public class DataFrameHtmlData(
577+
@Language("css") public val style: String = "",
578+
@Language("html", prefix = "<body>", suffix = "</body>") public val body: String = "",
579+
@Language("js") public val script: String = "",
580580
) {
581581
override fun toString(): String =
582582
buildString {
@@ -646,6 +646,36 @@ public data class DataFrameHtmlData(
646646

647647
public fun withTableDefinitions(): DataFrameHtmlData = tableDefinitions() + this
648648

649+
override fun equals(other: Any?): Boolean {
650+
if (this === other) return true
651+
if (other !is DataFrameHtmlData) return false
652+
653+
if (style != other.style) return false
654+
if (body != other.body) return false
655+
if (script != other.script) return false
656+
657+
return true
658+
}
659+
660+
override fun hashCode(): Int {
661+
var result = style.hashCode()
662+
result = 31 * result + body.hashCode()
663+
result = 31 * result + script.hashCode()
664+
return result
665+
}
666+
667+
public fun copy(
668+
style: String = this.style,
669+
body: String = this.body,
670+
script: String = this.script,
671+
): DataFrameHtmlData = DataFrameHtmlData(style = style, body = body, script = script)
672+
673+
public operator fun component1(): String = style
674+
675+
public operator fun component2(): String = body
676+
677+
public operator fun component3(): String = script
678+
649679
public companion object {
650680
/**
651681
* @return CSS and JS required to render DataFrame tables

0 commit comments

Comments
 (0)