Skip to content

Commit 56af70f

Browse files
Peng Jiangfacebook-github-bot
authored andcommitted
move the Editor class to data class
Summary: as title, only move the simple one to data class for now. Reviewed By: kingsleyadio Differential Revision: D76822282 fbshipit-source-id: 7bdf053780dd88e4675c52ff2cc25d680445dcb7
1 parent 0eb7f77 commit 56af70f

5 files changed

Lines changed: 20 additions & 103 deletions

File tree

litho-editor-core/src/main/java/com/facebook/litho/editor/model/EditorBool.kt

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,29 +16,11 @@
1616

1717
package com.facebook.litho.editor.model
1818

19-
/** Wraps over a boolean to make it an EditorValue */
20-
class EditorBool(@JvmField val value: Boolean) : EditorValue() {
21-
22-
override fun equals(o: Any?): Boolean {
23-
if (o === this) {
24-
return true
25-
}
26-
if (o !is EditorBool) {
27-
return false
28-
}
29-
val thisValue: Any = this.value
30-
val otherValue: Any = o.value
31-
return thisValue == otherValue
32-
}
33-
34-
override fun hashCode(): Int {
35-
val PRIME = 59
36-
var result = 1
37-
val objValue: Any = this.value
38-
result = result * PRIME + objValue.hashCode()
39-
return result
40-
}
19+
import com.facebook.kotlin.compilerplugins.dataclassgenerate.annotation.DataClassGenerate
4120

21+
/** Wraps over a boolean to make it an EditorValue */
22+
@DataClassGenerate
23+
data class EditorBool(@JvmField val value: Boolean) : EditorValue() {
4224
override fun toString(): String {
4325
return value.toString()
4426
}

litho-editor-core/src/main/java/com/facebook/litho/editor/model/EditorColor.kt

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,11 @@
1616

1717
package com.facebook.litho.editor.model
1818

19-
/** Wraps over a color to make it an EditorValue */
20-
class EditorColor(@JvmField val value: Number) : EditorValue() {
21-
22-
override fun equals(o: Any?): Boolean {
23-
if (this === o) {
24-
return true
25-
}
26-
27-
if (o == null || javaClass != o.javaClass) {
28-
return false
29-
}
30-
31-
val that = o as EditorColor
32-
33-
return value == that.value
34-
}
35-
36-
override fun hashCode(): Int {
37-
return value.hashCode()
38-
}
19+
import com.facebook.kotlin.compilerplugins.dataclassgenerate.annotation.DataClassGenerate
3920

21+
/** Wraps over a color to make it an EditorValue */
22+
@DataClassGenerate
23+
data class EditorColor(@JvmField val value: Number) : EditorValue() {
4024
override fun toString(): String {
4125
return value.toString()
4226
}

litho-editor-core/src/main/java/com/facebook/litho/editor/model/EditorNumber.kt

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,11 @@
1616

1717
package com.facebook.litho.editor.model
1818

19-
/** Wraps over a number to make it an EditorValue */
20-
class EditorNumber(@JvmField val value: Number) : EditorValue() {
21-
override fun equals(o: Any?): Boolean {
22-
if (this === o) {
23-
return true
24-
}
25-
26-
if (o == null || javaClass != o.javaClass) {
27-
return false
28-
}
29-
30-
val that = o as EditorNumber
31-
32-
return value == that.value
33-
}
34-
35-
override fun hashCode(): Int {
36-
return value.hashCode()
37-
}
19+
import com.facebook.kotlin.compilerplugins.dataclassgenerate.annotation.DataClassGenerate
3820

21+
/** Wraps over a number to make it an EditorValue */
22+
@DataClassGenerate
23+
data class EditorNumber(@JvmField val value: Number) : EditorValue() {
3924
override fun toString(): String {
4025
return value.toString()
4126
}

litho-editor-core/src/main/java/com/facebook/litho/editor/model/EditorShape.kt

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,11 @@
1616

1717
package com.facebook.litho.editor.model
1818

19-
/** Wraps over a shape to make it an EditorValue */
20-
class EditorShape(@JvmField val value: Map<String, EditorValue>) : EditorValue() {
21-
override fun equals(o: Any?): Boolean {
22-
if (o === this) {
23-
return true
24-
}
25-
if (o !is EditorShape) {
26-
return false
27-
}
28-
val thisValue: Any = this.value
29-
val otherValue: Any = o.value
30-
return thisValue == otherValue
31-
}
32-
33-
override fun hashCode(): Int {
34-
val PRIME = 59
35-
var result = 1
36-
val objValue: Any = this.value
37-
result = result * PRIME + objValue.hashCode()
38-
return result
39-
}
19+
import com.facebook.kotlin.compilerplugins.dataclassgenerate.annotation.DataClassGenerate
4020

21+
/** Wraps over a shape to make it an EditorValue */
22+
@DataClassGenerate
23+
data class EditorShape(@JvmField val value: Map<String, EditorValue>) : EditorValue() {
4124
override fun toString(): String {
4225
return value.toString()
4326
}

litho-editor-core/src/main/java/com/facebook/litho/editor/model/EditorString.kt

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,11 @@
1616

1717
package com.facebook.litho.editor.model
1818

19-
/** Wraps over a String to make it an EditorValue */
20-
class EditorString(@JvmField val value: String) : EditorValue() {
21-
override fun equals(o: Any?): Boolean {
22-
if (o === this) {
23-
return true
24-
}
25-
if (o !is EditorString) {
26-
return false
27-
}
28-
val thisValue: Any = this.value
29-
val otherValue: Any = o.value
30-
return thisValue == otherValue
31-
}
32-
33-
override fun hashCode(): Int {
34-
val PRIME = 59
35-
var result = 1
36-
val objValue: Any = this.value
37-
result = result * PRIME + objValue.hashCode()
38-
return result
39-
}
19+
import com.facebook.kotlin.compilerplugins.dataclassgenerate.annotation.DataClassGenerate
4020

21+
/** Wraps over a String to make it an EditorValue */
22+
@DataClassGenerate
23+
data class EditorString(@JvmField val value: String) : EditorValue() {
4124
override fun toString(): String {
4225
return value
4326
}

0 commit comments

Comments
 (0)