Flavor { @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Flavor flavor = (Flavor) o; if (mStyleResource != flavor.mStyleResource) return false; if (mDialogStyleResource != flavor.mDialogStyleResource) return false; if (mIsDayNight != flavor.mIsDayNight) return false; return mName != null ? mName.equals(flavor.mName) : flavor.mName == null; } Flavor(String name, int styleResource);  Flavor(String name, int styleResource, int dialogStyleResource);  Flavor(String name, int styleResource, int dialogStyleResource, boolean isDayNight); String getName(); @StyleRes int getStyleResource(); @StyleRes int getDialogStyleResource(); boolean isDayNight(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode();  }
@Test public void equals() throws Exception { String name = "Bacon Bacon Bacon"; int styleRes = random.nextInt(); int dialogStyleRes = random.nextInt(); boolean isDN = random.nextBoolean(); Flavor f1 = new Flavor(name, styleRes, dialogStyleRes, isDN); Flavor f2 = new Flavor(name, styleRes, dialogStyleRes, isDN); assertTrue(f1.equals(f2)); Flavor f3 = new Flavor(name, styleRes, dialogStyleRes); Flavor f4 = new Flavor(name, styleRes, dialogStyleRes); assertTrue(f3.equals(f4)); Flavor f6 = new Flavor(name, styleRes); Flavor f7 = new Flavor(name, styleRes); assertTrue(f6.equals(f7)); }