Skip to content

Instantly share code, notes, and snippets.

@kewp kewp/Movie.java
Created Sep 6, 2018

Embed
What would you like to do?
Kotlin Data Class - Java Equivalent
// 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
You can’t perform that action at this time.