Created
September 6, 2018 13:03
-
-
Save kewp/1efc1a4c406577342c43ccb258bf8739 to your computer and use it in GitHub Desktop.
Kotlin Data Class - Java Equivalent
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
// Kotlin: data class Movie( val id: Int, val name: String ) | |
import kotlin.jvm.internal.Intrinsics; | |
import org.jetbrains.annotations.NotNull; | |
public final class Movie { | |
private final int id; | |
@NotNull | |
private final String name; | |
public final int getId() { | |
return this.id; | |
} | |
@NotNull | |
public final String getName() { | |
return this.name; | |
} | |
public Movie(int id, @NotNull String name) { | |
Intrinsics.checkParameterIsNotNull(name, "name"); | |
super(); | |
this.id = id; | |
this.name = name; | |
} | |
public final int component1() { | |
return this.id; | |
} | |
@NotNull | |
public final String component2() { | |
return this.name; | |
} | |
@NotNull | |
public final Movie copy(int id, @NotNull String name) { | |
Intrinsics.checkParameterIsNotNull(name, "name"); | |
return new Movie(id, name); | |
} | |
// $FF: synthetic method | |
// $FF: bridge method | |
@NotNull | |
public static Movie copy$default(Movie var0, int var1, String var2, int var3, Object var4) { | |
if ((var3 & 1) != 0) { | |
var1 = var0.id; | |
} | |
if ((var3 & 2) != 0) { | |
var2 = var0.name; | |
} | |
return var0.copy(var1, var2); | |
} | |
public String toString() { | |
return "Movie(id=" + this.id + ", name=" + this.name + ")"; | |
} | |
public int hashCode() { | |
return this.id * 31 + (this.name != null ? this.name.hashCode() : 0); | |
} | |
public boolean equals(Object var1) { | |
if (this != var1) { | |
if (var1 instanceof Movie) { | |
Movie var2 = (Movie)var1; | |
if (this.id == var2.id && Intrinsics.areEqual(this.name, var2.name)) { | |
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