StorageUnit extends Number implements Comparable<StorageUnit<?>> { @Override public final boolean equals(@Nullable final Object other) { if (other instanceof StorageUnit<?>) { final StorageUnit<?> that = (StorageUnit<?>) other; return Objects.equals(this.bytes, that.bytes); } return false; } protected  StorageUnit(@NonNull final BigInteger bytes); @NonNull final StorageUnit<?> asBestMatchingBinaryUnit(); @NonNull final StorageUnit<?> asBestMatchingDecimalUnit(); @NonNull final StorageUnit<?> asBestMatchingCommonUnit(); @NonNull final StorageUnit<?> asBestMatchingUnit(); @NonNull final Byte asByte(); @NonNull final Kibibyte asKibibyte(); @NonNull final Mebibyte asMebibyte(); @NonNull final Gibibyte asGibibyte(); @NonNull final Tebibyte asTebibyte(); @NonNull final Pebibyte asPebibyte(); @NonNull final Exbibyte asExbibyte(); @NonNull final Zebibyte asZebibyte(); @NonNull final Yobibyte asYobibyte(); @NonNull final Kilobyte asKilobyte(); @NonNull final Megabyte asMegabyte(); @NonNull final Gigabyte asGigabyte(); @NonNull final Terabyte asTerabyte(); @NonNull final Petabyte asPetabyte(); @NonNull final Exabyte asExabyte(); @NonNull final Zettabyte asZettabyte(); @NonNull final Yottabyte asYottabyte(); @NonNull final CommonKilobyte asCommonKilobyte(); @NonNull final CommonMegabyte asCommonMegabyte(); @NonNull final CommonGigabyte asCommonGigabyte(); @NonNull final CommonTerabyte asCommonTerabyte(); @NonNull final CommonPetabyte asCommonPetabyte(); @NonNull final CommonExabyte asCommonExabyte(); @NonNull final CommonZettabyte asCommonZettabyte(); @NonNull final CommonYottabyte asCommonYottabyte(); @NonNull final BigInteger inByte(); @NonNull final BigDecimal inKibibyte(); @NonNull final BigDecimal inMebibyte(); @NonNull final BigDecimal inGibibyte(); @NonNull final BigDecimal inTebibyte(); @NonNull final BigDecimal inPebibyte(); @NonNull final BigDecimal inExbibyte(); @NonNull final BigDecimal inZebibyte(); @NonNull final BigDecimal inYobibyte(); @NonNull final BigDecimal inKilobyte(); @NonNull final BigDecimal inMegabyte(); @NonNull final BigDecimal inGigabyte(); @NonNull final BigDecimal inTerabyte(); @NonNull final BigDecimal inPetabyte(); @NonNull final BigDecimal inExabyte(); @NonNull final BigDecimal inZettabyte(); @NonNull final BigDecimal inYottabyte(); @NonNull final BigDecimal inCommonKilobyte(); @NonNull final BigDecimal inCommonMegabyte(); @NonNull final BigDecimal inCommonGigabyte(); @NonNull final BigDecimal inCommonTerabyte(); @NonNull final BigDecimal inCommonPetabyte(); @NonNull final BigDecimal inCommonExabyte(); @NonNull final BigDecimal inCommonZettabyte(); @NonNull final BigDecimal inCommonYottabyte(); @NonNull @Override final String toString(); @NonNull final String toString(final String pattern); @NonNull final String toString(final String pattern, final Locale locale); @NonNull final String toString(final Format format); @Override final int hashCode(); @Override final boolean equals(@Nullable final Object other); @Override final int compareTo(final StorageUnit<?> that); @Override final double doubleValue(); @Override final float floatValue(); @Override final int intValue(); @Override final long longValue(); @NonNull abstract T add(long bytesToAdd); @NonNull abstract T add(@NonNull StorageUnit<?> storageAmount); @NonNull abstract T divide(long divisor); @NonNull abstract T multiply(long factor); @NonNull abstract T subtract(long bytesToSubtract); @NonNull abstract T subtract(@NonNull StorageUnit<?> storageAmount);  }
@Test public void shouldBeEqualToItself() { final StorageUnit<?> unit = StorageUnits.kibibyte(1); final boolean result = unit.equals(unit); Assert.assertTrue("Unit is not equal to itself", result); }
@Test public void shouldNotBeEqualToSomethingElse() { final StorageUnit<?> unit = StorageUnits.kibibyte(1); final boolean result = unit.equals(new Object()); Assert.assertFalse("Unit is equal to something else", result); }