@Test public void testEquals() { LotteryNumbers numbers1 = LotteryNumbers.create( new HashSet<>(Arrays.asList(1, 2, 3, 4))); LotteryNumbers numbers2 = LotteryNumbers.create( new HashSet<>(Arrays.asList(1, 2, 3, 4))); assertTrue(numbers1.equals(numbers2)); LotteryNumbers numbers3 = LotteryNumbers.create( new HashSet<>(Arrays.asList(11, 12, 13, 14))); assertFalse(numbers1.equals(numbers3)); }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } LotteryNumbers other = (LotteryNumbers) obj; if (numbers == null) { if (other.numbers != null) { return false; } } else if (!numbers.equals(other.numbers)) { return false; } return true; }
LotteryNumbers { @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } LotteryNumbers other = (LotteryNumbers) obj; if (numbers == null) { if (other.numbers != null) { return false; } } else if (!numbers.equals(other.numbers)) { return false; } return true; } }
LotteryNumbers { @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } LotteryNumbers other = (LotteryNumbers) obj; if (numbers == null) { if (other.numbers != null) { return false; } } else if (!numbers.equals(other.numbers)) { return false; } return true; } private  LotteryNumbers(); private  LotteryNumbers(Set<Integer> givenNumbers); }
LotteryNumbers { @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } LotteryNumbers other = (LotteryNumbers) obj; if (numbers == null) { if (other.numbers != null) { return false; } } else if (!numbers.equals(other.numbers)) { return false; } return true; } private  LotteryNumbers(); private  LotteryNumbers(Set<Integer> givenNumbers); static LotteryNumbers createRandom(); static LotteryNumbers create(Set<Integer> givenNumbers); Set<Integer> getNumbers(); String getNumbersAsString(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); }
LotteryNumbers { @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } LotteryNumbers other = (LotteryNumbers) obj; if (numbers == null) { if (other.numbers != null) { return false; } } else if (!numbers.equals(other.numbers)) { return false; } return true; } private  LotteryNumbers(); private  LotteryNumbers(Set<Integer> givenNumbers); static LotteryNumbers createRandom(); static LotteryNumbers create(Set<Integer> givenNumbers); Set<Integer> getNumbers(); String getNumbersAsString(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); static final int MIN_NUMBER; static final int MAX_NUMBER; static final int NUM_NUMBERS; }