Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Effective java 2 Effective Kotlin short version

rallat
January 22, 2019

Effective java 2 Effective Kotlin short version

Short version of Droidcon SF talk

rallat

January 22, 2019
Tweet

More Decks by rallat

Other Decks in Programming

Transcript

  1. Integer x = 300; Integer y = 300; if(x ==

    y) { println("Same Int"); } else { println("Diff Int”); }A
  2. Integer x = 300; Integer y = 300; if(x ==

    y) { println("Same Int"); } else { println("Diff Int”); }A prints Diff Int
  3. Integer x = 300; Integer y = 300; if(x.equals(y)) {

    println("Same Int"); } else { println("Diff Int”); }A prints Diff Int
  4. Integer x = 300; Integer y = 300; if(x.equals(y)) {

    println("Same Int"); } else { println("Diff Int”); }A prints Same Int
  5. public class Item { public final String id; public final

    String name; public final String description; }A
  6. public class Item { public final String id; public final

    String name; public final String description; }A public static class Builder { private String name = ""; private String description = ""; public Item create(String id) { return new Item(id, description, name); }B public Builder name(String name) { this.name = name; return this; }C public Builder description(String description) { this.description = description; return this; }D }E
  7. public static class Builder { private String name = "";

    private String description = ""; public Item create(String id) { return new Item(id, description, name); }B public Builder name(String name) { this.name = name; return this; }C public Builder description(String description) { this.description = description; return this; }D }E
  8. class Item( val id: String, val name: String = "",

    val description: String = "" ) public static class Builder { private String name = ""; private String description = ""; public Item create(String id) { return new Item(id, description, name); }B public Builder name(String name) { this.name = name; return this; }C public Builder description(String description) { this.description = description; return this; }D }E
  9. class Item @JvmOverloads constructor( val id: String, val name: String

    = "", val description: String = "" )A public static class Builder { private String name = ""; private String description = ""; public Item create(String id) { return new Item(id, description, name); }B public Builder name(String name) { this.name = name; return this; }C public Builder description(String description) { this.description = description; return this; }D }E
  10. class Item @JvmOverloads constructor( val id: String, val name: String

    = "", val description: String = "" )A Item("1")
  11. class Item @JvmOverloads constructor( val id: String, val name: String

    = "", val description: String = "" )A Item("1") Item(name= "the name",id = "1")
  12. interface Pump { void startMotor(); } class RotaryVane implements Pump

    interface Boiler { void heat(); } class DoubleBoiler implements Boiler
  13. public class EspressoCoffeeMachine implements Boiler, Pump { private final DoubleBoiler

    boiler; private final RotaryVane pump; public EspressoCoffeeMachine(DoubleBoiler boiler, RotaryVane pump) { this.boiler = boiler; this.pump = pump; } @Override public void heat() { boiler.heat(); } @Override public void startMotor() { pump.startMotor(); } }
  14. class EspressoCoffeeMachine : Boiler by DoubleBoiler, Pump by RotaryVane public

    class EspressoCoffeeMachine implements Boiler, Pump { private final DoubleBoiler boiler; private final RotaryVane pump; public EspressoCoffeeMachine(DoubleBoiler boiler, RotaryVane pump) { this.boiler = boiler; this.pump = pump; } @Override public void heat() { boiler.heat(); } @Override public void startMotor() { pump.startMotor(); } }
  15. public final class EspressoCoffeeMachine implements Boiler, Pump { private final

    DoubleBoiler $$delegate_0; private final RotaryVane $$delegate_1; public EspressoCoffeeMachine() { this.$$delegate_0 = DoubleBoiler.INSTANCE; this.$$delegate_1 = RotaryVane.INSTANCE; } } class EspressoCoffeeMachine : Boiler by DoubleBoiler, Pump by RotaryVane
  16. public class ItemJava { @NotNull public final String id; @NotNull

    public final String name; @NotNull public final String description; } public ItemJava(@NotNull String id, @NotNull String name, @NotNull String description) { Intrinsics.checkParameterIsNotNull(id, "id"); Intrinsics.checkParameterIsNotNull(name, "name"); Intrinsics.checkParameterIsNotNull(description, " this.id = id; this.name = name; this.description = description;
  17. public class ItemJava { @NotNull public final String id; @NotNull

    public final String name; @NotNull public final String description; public ItemJava(@NotNull String id, @NotNull String name, @NotNull String description) { Intrinsics.checkParameterIsNotNull(id, "id"); Intrinsics.checkParameterIsNotNull(name, "name"); Intrinsics.checkParameterIsNotNull(description, "description"); this.id = id; this.name = name; this.description = description; }A } public boolean equals(Object var1) { if (this != var1) { if (var1 instanceof ItemJava) { ItemJava var2 = (ItemJava) var1; return Intrinsics.areEqual(this.id, var2.id) && Intrinsics.areEqual(this.name, var2.name) &&
  18. public class ItemJava { @NotNull public final String id; @NotNull

    public final String name; @NotNull public final String description; public ItemJava(@NotNull String id, @NotNull String name, @NotNull String description) { Intrinsics.checkParameterIsNotNull(id, "id"); Intrinsics.checkParameterIsNotNull(name, "name"); Intrinsics.checkParameterIsNotNull(description, "description"); this.id = id; this.name = name; this.description = description; }A public boolean equals(Object var1) { if (this != var1) { if (var1 instanceof ItemJava) { ItemJava var2 = (ItemJava) var1; return Intrinsics.areEqual(this.id, var2.id) && Intrinsics.areEqual(this.name, var2.name) && Intrinsics.areEqual(this.description, var2.description); }B return false; } else { return true; }C }D } public int hashCode() {
  19. public class ItemJava { @NotNull public final String id; @NotNull

    public final String name; @NotNull public final String description; public ItemJava(@NotNull String id, @NotNull String name, @NotNull String description) { Intrinsics.checkParameterIsNotNull(id, "id"); Intrinsics.checkParameterIsNotNull(name, "name"); Intrinsics.checkParameterIsNotNull(description, "description"); this.id = id; this.name = name; this.description = description; }A public boolean equals(Object var1) { if (this != var1) { if (var1 instanceof ItemJava) { ItemJava var2 = (ItemJava) var1; return Intrinsics.areEqual(this.id, var2.id) && Intrinsics.areEqual(this.name, var2.name) && Intrinsics.areEqual(this.description, var2.description); }B return false; } else { return true; }C }D public int hashCode() { return (this.id.hashCode() * 31 + this.name.hashCode()) * 31 + this.description.hashCode(); }E }F
  20. public class ItemJava { @NotNull public final String id; @NotNull

    public final String name; @NotNull public final String description; public ItemJava(@NotNull String id, @NotNull String name, @NotNull String description) { Intrinsics.checkParameterIsNotNull(id, "id"); Intrinsics.checkParameterIsNotNull(name, "name"); Intrinsics.checkParameterIsNotNull(description, "description"); this.id = id; this.name = name; this.description = description; }A public boolean equals(Object var1) { if (this != var1) { if (var1 instanceof ItemJava) { ItemJava var2 = (ItemJava) var1; return Intrinsics.areEqual(this.id, var2.id) && Intrinsics.areEqual(this.name, var2.name) && Intrinsics.areEqual(this.description, var2.description); }B return false; } else { return true; }C }D public int hashCode() { return (this.id.hashCode() * 31 + this.name.hashCode()) * 31 + this.description.hashCode(); }E }F
  21. public class ItemJava { @NotNull public final String id; @NotNull

    public final String name; @NotNull public final String description; public ItemJava(@NotNull String id, @NotNull String name, @NotNull String description) { Intrinsics.checkParameterIsNotNull(id, "id"); Intrinsics.checkParameterIsNotNull(name, "name"); Intrinsics.checkParameterIsNotNull(description, "description"); this.id = id; this.name = name; this.description = description; }A public boolean equals(Object var1) { if (this != var1) { if (var1 instanceof ItemJava) { ItemJava var2 = (ItemJava) var1; return Intrinsics.areEqual(this.id, var2.id) && Intrinsics.areEqual(this.name, var2.name) && Intrinsics.areEqual(this.description, var2.description); }B return false; } else { return true; }C }D public int hashCode() { return (this.id.hashCode() * 31 + this.name.hashCode()) * 31 + this.description.hashCode(); }E }F data class Item(val id: String, val name: String, val description: String)
  22. data class Item(val id: String, val name: String, val description:

    String) public final class Item { @NotNull private final String id; @NotNull private final String name; @NotNull private final String description; @NotNull public final String getId() { return this.id; } @NotNull public final String getName() { return this.name; } @NotNull public final String getDescription() { return this.description; } public Item(@NotNull String id, @NotNull String name, @NotNull String description) { Intrinsics.checkParameterIsNotNull(id, "id"); Intrinsics.checkParameterIsNotNull(name, "name"); Intrinsics.checkParameterIsNotNull(description, "description"); super(); this.id = id; this.name = name; this.description = description; } @NotNull public final String component1() { return this.id; } @NotNull public final String component2() { return this.name; } @NotNull public final String component3() { return this.description; } @NotNull public final Item copy(@NotNull String id, @NotNull String name, @NotNull String description) { Intrinsics.checkParameterIsNotNull(id, "id"); Intrinsics.checkParameterIsNotNull(name, "name"); Intrinsics.checkParameterIsNotNull(description, "description"); return new Item(id, name, description); } // $FF: synthetic method // $FF: bridge method @NotNull public static Item copy$default(Item var0, String var1, String var2, String var3, int var4, Object var5) { if ((var4 & 1) != 0) { var1 = var0.id; } if ((var4 & 2) != 0) { var2 = var0.name; } if ((var4 & 4) != 0) { var3 = var0.description; } return var0.copy(var1, var2, var3); } public String toString() { return "Item(id=" + this.id + ", name=" + this.name + ", description=" + this.description + ")"; } public int hashCode() { return ((this.id != null ? this.id.hashCode() : 0) * 31 + (this.name != null ? this.name.hashCode() : 0)) * 31 + (this.description != null ? this.description.hashCode() : 0); } public boolean equals(Object var1) { if (this != var1) { if (var1 instanceof Item) { Item var2 = (Item)var1; if (Intrinsics.areEqual(this.id, var2.id) && Intrinsics.areEqual(this.name, var2.name) && Intrinsics.areEqual(this.description, var2.description)) { return true; } } return false; } else { return true;
  23. data class Item(val id: String, val name: String, val description:

    String) public Item(@NotNull String id, @NotNull String name, @NotNull String description) { Intrinsics.checkParameterIsNotNull(id, "id"); Intrinsics.checkParameterIsNotNull(name, "name"); Intrinsics.checkParameterIsNotNull(description, "description"); super(); this.id = id; this.name = name; this.description = description; }
  24. data class Item(val id: String, val name: String, val description:

    String) public final class Item { @NotNull private final String id; @NotNull private final String name; @NotNull private final String description; @NotNull public final String getId() { return this.id; } @NotNull public final String getName() { return this.name; } @NotNull public final String getDescription() { return this.description; } public Item(@NotNull String id, @NotNull String name, @NotNull String description) { Intrinsics.checkParameterIsNotNull(id, "id"); Intrinsics.checkParameterIsNotNull(name, "name"); Intrinsics.checkParameterIsNotNull(description, "description"); super(); this.id = id; this.name = name; this.description = description; } @NotNull public final String component1() { return this.id; } @NotNull public final String component2() { return this.name; } @NotNull public final String component3() { return this.description; } @NotNull public final Item copy(@NotNull String id, @NotNull String name, @NotNull String description) { Intrinsics.checkParameterIsNotNull(id, "id"); Intrinsics.checkParameterIsNotNull(name, "name"); Intrinsics.checkParameterIsNotNull(description, "description"); return new Item(id, name, description); } // $FF: synthetic method // $FF: bridge method @NotNull public static Item copy$default(Item var0, String var1, String var2, String var3, int var4, Object var5) { if ((var4 & 1) != 0) { var1 = var0.id; } if ((var4 & 2) != 0) { var2 = var0.name; } if ((var4 & 4) != 0) { var3 = var0.description; } return var0.copy(var1, var2, var3); } public String toString() { return "Item(id=" + this.id + ", name=" + this.name + ", description=" + this.description + ")"; } public int hashCode() { return ((this.id != null ? this.id.hashCode() : 0) * 31 + (this.name != null ? this.name.hashCode() : 0)) * 31 + (this.description != null ? this.description.hashCode() : 0); } public boolean equals(Object var1) { if (this != var1) { if (var1 instanceof Item) { Item var2 = (Item)var1; if (Intrinsics.areEqual(this.id, var2.id) && Intrinsics.areEqual(this.name, var2.name) && Intrinsics.areEqual(this.description, var2.description)) { return true; } } return false; } else { return true;
  25. data class Item(val id: String, val name: String, val description:

    String) @NotNull public final String getId() { return this.id; } @NotNull public final String getName() { return this.name; } @NotNull public final String getDescription() { return this.description; }
  26. data class Item(val id: String, val name: String, val description:

    String) public final class Item { @NotNull private final String id; @NotNull private final String name; @NotNull private final String description; @NotNull public final String getId() { return this.id; } @NotNull public final String getName() { return this.name; } @NotNull public final String getDescription() { return this.description; } public Item(@NotNull String id, @NotNull String name, @NotNull String description) { Intrinsics.checkParameterIsNotNull(id, "id"); Intrinsics.checkParameterIsNotNull(name, "name"); Intrinsics.checkParameterIsNotNull(description, "description"); super(); this.id = id; this.name = name; this.description = description; } @NotNull public final String component1() { return this.id; } @NotNull public final String component2() { return this.name; } @NotNull public final String component3() { return this.description; } @NotNull public final Item copy(@NotNull String id, @NotNull String name, @NotNull String description) { Intrinsics.checkParameterIsNotNull(id, "id"); Intrinsics.checkParameterIsNotNull(name, "name"); Intrinsics.checkParameterIsNotNull(description, "description"); return new Item(id, name, description); } // $FF: synthetic method // $FF: bridge method @NotNull public static Item copy$default(Item var0, String var1, String var2, String var3, int var4, Object var5) { if ((var4 & 1) != 0) { var1 = var0.id; } if ((var4 & 2) != 0) { var2 = var0.name; } if ((var4 & 4) != 0) { var3 = var0.description; } return var0.copy(var1, var2, var3); } public String toString() { return "Item(id=" + this.id + ", name=" + this.name + ", description=" + this.description + ")"; } public int hashCode() { return ((this.id != null ? this.id.hashCode() : 0) * 31 + (this.name != null ? this.name.hashCode() : 0)) * 31 + (this.description != null ? this.description.hashCode() : 0); } public boolean equals(Object var1) { if (this != var1) { if (var1 instanceof Item) { Item var2 = (Item)var1; if (Intrinsics.areEqual(this.id, var2.id) && Intrinsics.areEqual(this.name, var2.name) && Intrinsics.areEqual(this.description, var2.description)) { return true; } } return false; } else { return true;
  27. data class Item(val id: String, val name: String, val description:

    String) public boolean equals(Object var1) { if (this != var1) { if (var1 instanceof Item) { Item var2 = (Item)var1; if (Intrinsics.areEqual(this.id, var2.id) && Intrinsics.areEqual(this.name, var2.name) && Intrinsics.areEqual(this.description, var2.description)) { return true; } } return false; } else { return true; } }
  28. data class Item(val id: String, val name: String, val description:

    String) public final class Item { @NotNull private final String id; @NotNull private final String name; @NotNull private final String description; @NotNull public final String getId() { return this.id; } @NotNull public final String getName() { return this.name; } @NotNull public final String getDescription() { return this.description; } public Item(@NotNull String id, @NotNull String name, @NotNull String description) { Intrinsics.checkParameterIsNotNull(id, "id"); Intrinsics.checkParameterIsNotNull(name, "name"); Intrinsics.checkParameterIsNotNull(description, "description"); super(); this.id = id; this.name = name; this.description = description; } @NotNull public final String component1() { return this.id; } @NotNull public final String component2() { return this.name; } @NotNull public final String component3() { return this.description; } @NotNull public final Item copy(@NotNull String id, @NotNull String name, @NotNull String description) { Intrinsics.checkParameterIsNotNull(id, "id"); Intrinsics.checkParameterIsNotNull(name, "name"); Intrinsics.checkParameterIsNotNull(description, "description"); return new Item(id, name, description); } // $FF: synthetic method // $FF: bridge method @NotNull public static Item copy$default(Item var0, String var1, String var2, String var3, int var4, Object var5) { if ((var4 & 1) != 0) { var1 = var0.id; } if ((var4 & 2) != 0) { var2 = var0.name; } if ((var4 & 4) != 0) { var3 = var0.description; } return var0.copy(var1, var2, var3); } public String toString() { return "Item(id=" + this.id + ", name=" + this.name + ", description=" + this.description + ")"; } public int hashCode() { return ((this.id != null ? this.id.hashCode() : 0) * 31 + (this.name != null ? this.name.hashCode() : 0)) * 31 + (this.description != null ? this.description.hashCode() : 0); } public boolean equals(Object var1) { if (this != var1) { if (var1 instanceof Item) { Item var2 = (Item)var1; if (Intrinsics.areEqual(this.id, var2.id) && Intrinsics.areEqual(this.name, var2.name) && Intrinsics.areEqual(this.description, var2.description)) { return true; } } return false; } else { return true;
  29. data class Item(val id: String, val name: String, val description:

    String) public int hashCode() { return ((this.id != null ? this.id.hashCode() : 0) * 31 + (this.name != null ? this.name.hashCode() : 0)) * 31 + (this.description != null ? this.description.hashCode() : 0); }
  30. data class Item(val id: String, val name: String, val description:

    String) public final class Item { @NotNull private final String id; @NotNull private final String name; @NotNull private final String description; @NotNull public final String getId() { return this.id; } @NotNull public final String getName() { return this.name; } @NotNull public final String getDescription() { return this.description; } public Item(@NotNull String id, @NotNull String name, @NotNull String description) { Intrinsics.checkParameterIsNotNull(id, "id"); Intrinsics.checkParameterIsNotNull(name, "name"); Intrinsics.checkParameterIsNotNull(description, "description"); super(); this.id = id; this.name = name; this.description = description; } @NotNull public final String component1() { return this.id; } @NotNull public final String component2() { return this.name; } @NotNull public final String component3() { return this.description; } @NotNull public final Item copy(@NotNull String id, @NotNull String name, @NotNull String description) { Intrinsics.checkParameterIsNotNull(id, "id"); Intrinsics.checkParameterIsNotNull(name, "name"); Intrinsics.checkParameterIsNotNull(description, "description"); return new Item(id, name, description); } // $FF: synthetic method // $FF: bridge method @NotNull public static Item copy$default(Item var0, String var1, String var2, String var3, int var4, Object var5) { if ((var4 & 1) != 0) { var1 = var0.id; } if ((var4 & 2) != 0) { var2 = var0.name; } if ((var4 & 4) != 0) { var3 = var0.description; } return var0.copy(var1, var2, var3); } public String toString() { return "Item(id=" + this.id + ", name=" + this.name + ", description=" + this.description + ")"; } public int hashCode() { return ((this.id != null ? this.id.hashCode() : 0) * 31 + (this.name != null ? this.name.hashCode() : 0)) * 31 + (this.description != null ? this.description.hashCode() : 0); } public boolean equals(Object var1) { if (this != var1) { if (var1 instanceof Item) { Item var2 = (Item)var1; if (Intrinsics.areEqual(this.id, var2.id) && Intrinsics.areEqual(this.name, var2.name) && Intrinsics.areEqual(this.description, var2.description)) { return true; } } return false; } else { return true;
  31. data class Item(val id: String, val name: String, val description:

    String) @NotNull public final Item copy(@NotNull String id, @NotNull String name, @NotNull String description) { Intrinsics.checkParameterIsNotNull(id, "id"); Intrinsics.checkParameterIsNotNull(name, "name"); Intrinsics.checkParameterIsNotNull(description, "description"); return new Item(id, name, description); } public String toString() { return "Item(id=" + this.id + ", name=" + this.name + ", description=" + this.description + ")"; }
  32. data class Item(val id: String, val name: String, val description:

    String) public final class Item { @NotNull private final String id; @NotNull private final String name; @NotNull private final String description; @NotNull public final String getId() { return this.id; } @NotNull public final String getName() { return this.name; } @NotNull public final String getDescription() { return this.description; } public Item(@NotNull String id, @NotNull String name, @NotNull String description) { Intrinsics.checkParameterIsNotNull(id, "id"); Intrinsics.checkParameterIsNotNull(name, "name"); Intrinsics.checkParameterIsNotNull(description, "description"); super(); this.id = id; this.name = name; this.description = description; } @NotNull public final String component1() { return this.id; } @NotNull public final String component2() { return this.name; } @NotNull public final String component3() { return this.description; } @NotNull public final Item copy(@NotNull String id, @NotNull String name, @NotNull String description) { Intrinsics.checkParameterIsNotNull(id, "id"); Intrinsics.checkParameterIsNotNull(name, "name"); Intrinsics.checkParameterIsNotNull(description, "description"); return new Item(id, name, description); } // $FF: synthetic method // $FF: bridge method @NotNull public static Item copy$default(Item var0, String var1, String var2, String var3, int var4, Object var5) { if ((var4 & 1) != 0) { var1 = var0.id; } if ((var4 & 2) != 0) { var2 = var0.name; } if ((var4 & 4) != 0) { var3 = var0.description; } return var0.copy(var1, var2, var3); } public String toString() { return "Item(id=" + this.id + ", name=" + this.name + ", description=" + this.description + ")"; } public int hashCode() { return ((this.id != null ? this.id.hashCode() : 0) * 31 + (this.name != null ? this.name.hashCode() : 0)) * 31 + (this.description != null ? this.description.hashCode() : 0); } public boolean equals(Object var1) { if (this != var1) { if (var1 instanceof Item) { Item var2 = (Item)var1; if (Intrinsics.areEqual(this.id, var2.id) && Intrinsics.areEqual(this.name, var2.name) && Intrinsics.areEqual(this.description, var2.description)) { return true; } } return false; } else { return true;
  33. data class Item(val id: String, val name: String, val description:

    String) @NotNull public final String component1() { return this.id; } @NotNull public final String component2() { return this.name; } @NotNull public final String component3() { return this.description; }
  34. data class Item(val id: String, val name: String, val description:

    String) @NotNull public final String component1() { return this.id; } @NotNull public final String component2() { return this.name; } @NotNull public final String component3() { return this.description; } val(id, name, description) = fooItem() fun fooItem(): Item { return Item("id", "name", "description") }
  35. data class Item(val id: String, val name: String, val description:

    String) : Parcelable public final class Item { @NotNull private final String id; @NotNull private final String name; @NotNull private final String description; @NotNull public final String getId() { return this.id; } @NotNull public final String getName() { return this.name; } @NotNull public final String getDescription() { return this.description; } public Item(@NotNull String id, @NotNull String name, @NotNull String description) { Intrinsics.checkParameterIsNotNull(id, "id"); Intrinsics.checkParameterIsNotNull(name, "name"); Intrinsics.checkParameterIsNotNull(description, "description"); super(); this.id = id; this.name = name; this.description = description; } @NotNull public final String component1() { return this.id; } @NotNull public final String component2() { return this.name; } @NotNull public final String component3() { return this.description; } @NotNull public final Item copy(@NotNull String id, @NotNull String name, @NotNull String description) { Intrinsics.checkParameterIsNotNull(id, "id"); Intrinsics.checkParameterIsNotNull(name, "name"); Intrinsics.checkParameterIsNotNull(description, "description"); return new Item(id, name, description); } // $FF: synthetic method // $FF: bridge method @NotNull public static Item copy$default(Item var0, String var1, String var2, String var3, int var4, Object var5) { if ((var4 & 1) != 0) { var1 = var0.id; } if ((var4 & 2) != 0) { var2 = var0.name; } if ((var4 & 4) != 0) { var3 = var0.description; } return var0.copy(var1, var2, var3); } public String toString() { return "Item(id=" + this.id + ", name=" + this.name + ", description=" + this.description + ")"; } public int hashCode() { return ((this.id != null ? this.id.hashCode() : 0) * 31 + (this.name != null ? this.name.hashCode() : 0)) * 31 + (this.description != null ? this.description.hashCode() : 0); } public boolean equals(Object var1) { if (this != var1) { if (var1 instanceof Item) { Item var2 = (Item)var1; if (Intrinsics.areEqual(this.id, var2.id) && Intrinsics.areEqual(this.name, var2.name) && Intrinsics.areEqual(this.description, var2.description)) { return true; } } return false; } else { return true; val(id, name, description) = fooItem() fun fooItem(): Item { return Item("id", "name", "description") }
  36. data class Item(val id: String, val name: String, val description:

    String) : Parcelable public final class Item { @NotNull private final String id; @NotNull private final String name; @NotNull private final String description; @NotNull public final String getId() { return this.id; } @NotNull public final String getName() { return this.name; } @NotNull public final String getDescription() { return this.description; } public Item(@NotNull String id, @NotNull String name, @NotNull String description) { Intrinsics.checkParameterIsNotNull(id, "id"); Intrinsics.checkParameterIsNotNull(name, "name"); Intrinsics.checkParameterIsNotNull(description, "description"); super(); this.id = id; this.name = name; this.description = description; } @NotNull public final String component1() { return this.id; } @NotNull public final String component2() { return this.name; } @NotNull public final String component3() { return this.description; } @NotNull public final Item copy(@NotNull String id, @NotNull String name, @NotNull String description) { Intrinsics.checkParameterIsNotNull(id, "id"); Intrinsics.checkParameterIsNotNull(name, "name"); Intrinsics.checkParameterIsNotNull(description, "description"); return new Item(id, name, description); } // $FF: synthetic method // $FF: bridge method @NotNull public static Item copy$default(Item var0, String var1, String var2, String var3, int var4, Object var5) { if ((var4 & 1) != 0) { var1 = var0.id; } if ((var4 & 2) != 0) { var2 = var0.name; } if ((var4 & 4) != 0) { var3 = var0.description; } return var0.copy(var1, var2, var3); } public String toString() { return "Item(id=" + this.id + ", name=" + this.name + ", description=" + this.description + ")"; } public int hashCode() { return ((this.id != null ? this.id.hashCode() : 0) * 31 + (this.name != null ? this.name.hashCode() : 0)) * 31 + (this.description != null ? this.description.hashCode() : 0); } public boolean equals(Object var1) { if (this != var1) { if (var1 instanceof Item) { Item var2 = (Item)var1; if (Intrinsics.areEqual(this.id, var2.id) && Intrinsics.areEqual(this.name, var2.name) && Intrinsics.areEqual(this.description, var2.description)) { return true; } } return false; } else { return true;
  37. @Parcelize data class Item(val id: String, val name: String, val

    description: String) : Parcelable public final class Item { @NotNull private final String id; @NotNull private final String name; @NotNull private final String description; @NotNull public final String getId() { return this.id; } @NotNull public final String getName() { return this.name; } @NotNull public final String getDescription() { return this.description; } public Item(@NotNull String id, @NotNull String name, @NotNull String description) { Intrinsics.checkParameterIsNotNull(id, "id"); Intrinsics.checkParameterIsNotNull(name, "name"); Intrinsics.checkParameterIsNotNull(description, "description"); super(); this.id = id; this.name = name; this.description = description; } @NotNull public final String component1() { return this.id; } @NotNull public final String component2() { return this.name; } @NotNull public final String component3() { return this.description; } @NotNull public final Item copy(@NotNull String id, @NotNull String name, @NotNull String description) { Intrinsics.checkParameterIsNotNull(id, "id"); Intrinsics.checkParameterIsNotNull(name, "name"); Intrinsics.checkParameterIsNotNull(description, "description"); return new Item(id, name, description); } // $FF: synthetic method // $FF: bridge method @NotNull public static Item copy$default(Item var0, String var1, String var2, String var3, int var4, Object var5) { if ((var4 & 1) != 0) { var1 = var0.id; } if ((var4 & 2) != 0) { var2 = var0.name; } if ((var4 & 4) != 0) { var3 = var0.description; } return var0.copy(var1, var2, var3); } public String toString() { return "Item(id=" + this.id + ", name=" + this.name + ", description=" + this.description + ")"; } public int hashCode() { return ((this.id != null ? this.id.hashCode() : 0) * 31 + (this.name != null ? this.name.hashCode() : 0)) * 31 + (this.description != null ? this.description.hashCode() : 0); } public boolean equals(Object var1) { if (this != var1) { if (var1 instanceof Item) { Item var2 = (Item)var1; if (Intrinsics.areEqual(this.id, var2.id) && Intrinsics.areEqual(this.name, var2.name) && Intrinsics.areEqual(this.description, var2.description)) { return true; } } return false; } else { return true;
  38. public void writeToParcel(@NotNull Parcel parcel, int flags) { Intrinsics.checkParameterIsNotNull(parcel, "parcel");

    parcel.writeString(this.id); parcel.writeString(this.name); parcel.writeString(this.description); } @Metadata( mv = {1, 1, 13}, bv = {1, 0, 3}, k = 3 ) public static class Creator implements Parcelable.Creator { @NotNull public final Object[] newArray(int size) { return new Item[size]; } @NotNull public final Object createFromParcel(@NotNull Parcel in) { Intrinsics.checkParameterIsNotNull(in, "in"); return new Item(in.readString(), in.readString(), in.readString()); } } @Parcelize data class Item(val id: String, val name: String, val description: String) : Parcelable
  39. public final class Item { @NotNull private final String id;

    @NotNull private final String name; @NotNull private final String description; @NotNull public final String getId() { return this.id; } @NotNull public final String getName() { return this.name; } @NotNull public final String getDescription() { return this.description; } public Item(@NotNull String id, @NotNull String name, @NotNull String description) { Intrinsics.checkParameterIsNotNull(id, "id"); Intrinsics.checkParameterIsNotNull(name, "name"); Intrinsics.checkParameterIsNotNull(description, "description"); super(); this.id = id; this.name = name; this.description = description; } @NotNull public final String component1() { return this.id; } @NotNull public final String component2() { return this.name; } @NotNull public final String component3() { return this.description; } @NotNull public final Item copy(@NotNull String id, @NotNull String name, @NotNull String description) { Intrinsics.checkParameterIsNotNull(id, "id"); Intrinsics.checkParameterIsNotNull(name, "name"); Intrinsics.checkParameterIsNotNull(description, "description"); return new Item(id, name, description); } // $FF: synthetic method // $FF: bridge method @NotNull public static Item copy$default(Item var0, String var1, String var2, String var3, int var4, Object var5) { if ((var4 & 1) != 0) { var1 = var0.id; } if ((var4 & 2) != 0) { var2 = var0.name; } if ((var4 & 4) != 0) { var3 = var0.description; } return var0.copy(var1, var2, var3); } public String toString() { return "Item(id=" + this.id + ", name=" + this.name + ", description=" + this.description + ")"; } public int hashCode() { return ((this.id != null ? this.id.hashCode() : 0) * 31 + (this.name != null ? this.name.hashCode() : 0)) * 31 + (this.description != null ? this.description.hashCode() : 0); } public boolean equals(Object var1) { if (this != var1) { if (var1 instanceof Item) { Item var2 = (Item)var1; if (Intrinsics.areEqual(this.id, var2.id) && Intrinsics.areEqual(this.name, var2.name) && Intrinsics.areEqual(this.description, var2.description)) { return true; } } return false; } else { return true; @Parcelize data class Item(val id: String, val name: String, val description: String) : Parcelable
  40. sealed class RemoteData { object NotInitialized : RemoteData() data class

    Loading(val progress: Progress) : RemoteData() }A
  41. sealed class RemoteData { object NotInitialized : RemoteData() data class

    Loading(val progress: Progress) : RemoteData() class Success : RemoteData() }A
  42. sealed class RemoteData { object NotInitialized : RemoteData() data class

    Loading(val progress: Progress) : RemoteData() class Success : RemoteData() class Failure : RemoteData() }A
  43. sealed class RemoteData { object NotInitialized : RemoteData() data class

    Loading(val progress: Progress) : RemoteData() class Success(result: Response) : RemoteData() class Failure : RemoteData() }A
  44. sealed class RemoteData { object NotInitialized : RemoteData() data class

    Loading(val progress: Progress) : RemoteData() class Success(result: Response) : RemoteData() class Failure(exception: Exception) : RemoteData() }A
  45. fun newState(request: RemoteData) = when (request) { RemoteData.NotInitialized -> request

    is RemoteData.Loading -> { viewModel.loading(request.progress) }B }A
  46. fun newState(request: RemoteData) = when (request) { RemoteData.NotInitialized -> request

    is RemoteData.Loading -> { viewModel.loading(request.progress) }B is RemoteData.Success -> { viewModel.transform(request.result) }C }A
  47. fun newState(request: RemoteData) = when (request) { RemoteData.NotInitialized -> request

    is RemoteData.Loading -> { viewModel.loading(request.progress) }B is RemoteData.Success -> { viewModel.transform(request.result) }C is RemoteData.Failure -> { viewModel.showError(request.exception) }D }A
  48. ?

  49. class Stack<E> { public void pushAll(Iterable<? extends E> src) {

    for (E e : src) push(e); }A }B Stack<Number> stack = new Stack<>(); List<Integer> integers = new ArrayList<>(); stack.pushAll(integers);
  50. class Stack<E> { public void pushAll(Iterable<? extends E> src) {

    for (E e : src) push(e); } public void popAll(Collection<? super E> dst) { while (!isEmpty()) dst.add(pop()); } }
  51. class Stack<E> { public void pushAll(Iterable<? extends E> src) {

    for (E e : src) push(e); } public void popAll(Collection<? super E> dst) { while (!isEmpty()) dst.add(pop()); } }
  52. class Stack<E> { public void pushAll(Iterable<? extends E> src) {

    for (E e : src) push(e); } public void popAll(Collection<? super E> dst) { while (!isEmpty()) dst.add(pop()); } } class Stack<E> { fun pushAll(src: Iterable<out E>) { for (e in src) push(e) } fun popAll(dst: MutableList<in E>) { while (!isEmpty()) dst.add(pop()) } }