Created
April 29, 2024 14:37
-
-
Save Mercandj/ed8e2f7951d205e8ad24280a56bbb524 to your computer and use it in GitHub Desktop.
medium_article_kotlin_sealed_class_1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sealed class Response { | |
abstract val httpCode: Int | |
} | |
data class Success( | |
override val httpCode: Int, | |
val data: String | |
) : Response() | |
data class Failed( | |
override val httpCode: Int | |
) : Response() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class Response { | |
private final int httpCode; | |
public int getHttpCode() { | |
return this.httpCode; | |
} | |
private Response(int httpCode) { | |
this.httpCode = httpCode; | |
} | |
// $FF: synthetic method | |
public Response(int httpCode, DefaultConstructorMarker $constructor_marker) { | |
this(httpCode); | |
} | |
} | |
public final class Success extends Response { | |
private final int httpCode; | |
@NotNull | |
private final String data; | |
public int getHttpCode() { | |
return this.httpCode; | |
} | |
@NotNull | |
public final String getData() { | |
return this.data; | |
} | |
public Success(int httpCode, @NotNull String data) { | |
Intrinsics.checkNotNullParameter(data, "data"); | |
super(httpCode, (DefaultConstructorMarker)null); | |
this.httpCode = httpCode; | |
this.data = data; | |
} | |
public final int component1() { | |
return this.getHttpCode(); | |
} | |
@NotNull | |
public final String component2() { | |
return this.data; | |
} | |
@NotNull | |
public final Success copy(int httpCode, @NotNull String data) { | |
Intrinsics.checkNotNullParameter(data, "data"); | |
return new Success(httpCode, data); | |
} | |
// $FF: synthetic method | |
public static Success copy$default(Success var0, int var1, String var2, int var3, Object var4) { | |
if ((var3 & 1) != 0) { | |
var1 = var0.getHttpCode(); | |
} | |
if ((var3 & 2) != 0) { | |
var2 = var0.data; | |
} | |
return var0.copy(var1, var2); | |
} | |
@NotNull | |
public String toString() { | |
return "Success(httpCode=" + this.getHttpCode() + ", data=" + this.data + ")"; | |
} | |
public int hashCode() { | |
int var10000 = Integer.hashCode(this.getHttpCode()) * 31; | |
String var10001 = this.data; | |
return var10000 + (var10001 != null ? var10001.hashCode() : 0); | |
} | |
public boolean equals(@Nullable Object var1) { | |
if (this != var1) { | |
if (var1 instanceof Success) { | |
Success var2 = (Success)var1; | |
if (this.getHttpCode() == var2.getHttpCode() && Intrinsics.areEqual(this.data, var2.data)) { | |
return true; | |
} | |
} | |
return false; | |
} else { | |
return true; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sealed class Response { | |
abstract val httpCode: Int | |
} | |
data class Success( | |
override val httpCode: Int, | |
val data: String | |
) : Response() | |
data class Failed( | |
override val httpCode: Int | |
) : Response() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class Response { | |
public abstract int getHttpCode(); | |
private Response() { | |
} | |
// $FF: synthetic method | |
public Response(DefaultConstructorMarker $constructor_marker) { | |
this(); | |
} | |
} | |
public final class Success extends Response { | |
private final int httpCode; | |
@NotNull private final String data; | |
public int getHttpCode() { | |
return this.httpCode; | |
} | |
@NotNull public final String getData() { | |
return this.data; | |
} | |
public Success(int httpCode, @NotNull String data) { | |
Intrinsics.checkNotNullParameter(data, "data"); | |
super((DefaultConstructorMarker)null); | |
this.httpCode = httpCode; | |
this.data = data; | |
} | |
public final int component1() { | |
return this.getHttpCode(); | |
} | |
@NotNull | |
public final String component2() { | |
return this.data; | |
} | |
@NotNull | |
public final Success copy(int httpCode, @NotNull String data) { | |
Intrinsics.checkNotNullParameter(data, "data"); | |
return new Success(httpCode, data); | |
} | |
// $FF: synthetic method | |
public static Success copy$default(Success var0, int var1, String var2, int var3, Object var4) { | |
if ((var3 & 1) != 0) { | |
var1 = var0.getHttpCode(); | |
} | |
if ((var3 & 2) != 0) { | |
var2 = var0.data; | |
} | |
return var0.copy(var1, var2); | |
} | |
@NotNull | |
public String toString() { | |
return "Success(httpCode=" + this.getHttpCode() + ", data=" + this.data + ")"; | |
} | |
public int hashCode() { | |
int var10000 = Integer.hashCode(this.getHttpCode()) * 31; | |
String var10001 = this.data; | |
return var10000 + (var10001 != null ? var10001.hashCode() : 0); | |
} | |
public boolean equals(@Nullable Object var1) { | |
if (this != var1) { | |
if (var1 instanceof Success) { | |
Success var2 = (Success)var1; | |
if (this.getHttpCode() == var2.getHttpCode() && Intrinsics.areEqual(this.data, var2.data)) { | |
return true; | |
} | |
} | |
return false; | |
} else { | |
return true; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment