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

Effective Java to Effective Kotlin

rallat
November 20, 2018

Effective Java to Effective Kotlin

rallat

November 20, 2018
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. object EffectiveSingleton public final class EffectiveSingleton { public static final

    EffectiveSingleton INSTANCE; static { EffectiveSingleton var0 = new EffectiveSingleton(); INSTANCE = var0; } }
  6. public class Item { public final String id; public final

    String name; public final String description; }A
  7. 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
  8. 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( 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
  10. class Item @JvmOverloads constructor( 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
  11. class Item @JvmOverloads constructor( val id: String, val name: String

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

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

    interface Boiler { void heat(); } class DoubleBoiler implements Boiler
  14. 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. 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(); } }
  16. 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
  17. public int getCastValueToInt(String str) { int num = -1; try

    { num = Integer.parseInt(str); } catch (NumberFormatException ignored) {} return num; }
  18. public int getCastValueToInt(String str) { int num = -1; try

    { num = Integer.parseInt(str); } catch (NumberFormatException ignored) {} return num; } fun getCastValueToInt(string: String) = try { Integer.parseInt(string); } catch (e: NumberFormatException) { -1 }
  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, " this.id = id; this.name = name; this.description = description;
  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) &&
  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() {
  22. 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
  23. 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
  24. 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)
  25. 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;
  26. 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; }
  27. 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;
  28. 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; }
  29. 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;
  30. 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; } }
  31. 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;
  32. 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); }
  33. 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;
  34. 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 + ")"; }
  35. 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;
  36. 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; }
  37. 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") }
  38. 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") }
  39. 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;
  40. @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;
  41. 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
  42. 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
  43. sealed class RemoteData { object NotInitialized : RemoteData() data class

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

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

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

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

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

    is RemoteData.Loading -> { viewModel.loading(request.progress) }B }A
  49. 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
  50. 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
  51. Integer[] integers = new Integer[1]; Number[] numbers = integers; numbers[0]

    = 1L; java.lang.ArrayStoreException: Long cannot be stored in an array of type Integer[] public final class Integer extends Number
  52. Integer[] integers = new Integer[1]; Number[] numbers = integers; numbers[0]

    = 1L; java.lang.ArrayStoreException: Long cannot be stored in an array of type Integer[]
  53. Integer[] integers = new Integer[1]; Number[] numbers = integers; numbers[0]

    = 1L; java.lang.ArrayStoreException: Long cannot be stored in an array of type Integer[]
  54. ?

  55. 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);
  56. 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()); } }
  57. 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()); } }
  58. 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()) } }
  59. IntelliJ Lambda expressions Smart casts String templates Type inference Typealias

    Range expressions Operator overloading Companion objects
  60. IntelliJ Lambda expressions Smart casts String templates Type inference Typealias

    Range expressions Operator overloading Companion objects Coroutines
  61. IntelliJ Lambda expressions Smart casts String templates Type inference Typealias

    Range expressions Operator overloading Companion objects Coroutines Contracts
  62. IntelliJ Lambda expressions Smart casts String templates Type inference Typealias

    Range expressions Operator overloading Companion objects Coroutines Contracts Inline classes