@Test public void timepointsWithDifferentFieldsShouldNotBeDistinctInHashSet() { HashSet<Timepoint> timepoints = new HashSet<>(4); timepoints.add(new Timepoint(12, 1, 0)); timepoints.add(new Timepoint(12, 2, 0)); timepoints.add(new Timepoint(12, 3, 0)); timepoints.add(new Timepoint(12, 4, 0)); Assert.assertEquals(timepoints.size(), 4); }
public void add(TYPE type, int value) { if (type == MINUTE) value *= 60; if (type == HOUR) value *= 3600; value += toSeconds(); switch (type) { case SECOND: int secondVal = (value % 3600) % 60; if(secondVal<0){ second = 60+secondVal; add(MINUTE, -1); }else { second = secondVal; } case MINUTE: int minuteVal = (value % 3600) / 60; if(minuteVal<0){ minute = 60+minuteVal; add(HOUR, -1); }else { minute = minuteVal; } case HOUR: int hourVal = (value / 3600) % 24; if(hourVal<0){ hour = 24+hourVal; }else{ hour=hourVal; } } }
Timepoint implements Parcelable, Comparable<Timepoint> { public void add(TYPE type, int value) { if (type == MINUTE) value *= 60; if (type == HOUR) value *= 3600; value += toSeconds(); switch (type) { case SECOND: int secondVal = (value % 3600) % 60; if(secondVal<0){ second = 60+secondVal; add(MINUTE, -1); }else { second = secondVal; } case MINUTE: int minuteVal = (value % 3600) / 60; if(minuteVal<0){ minute = 60+minuteVal; add(HOUR, -1); }else { minute = minuteVal; } case HOUR: int hourVal = (value / 3600) % 24; if(hourVal<0){ hour = 24+hourVal; }else{ hour=hourVal; } } } }
Timepoint implements Parcelable, Comparable<Timepoint> { public void add(TYPE type, int value) { if (type == MINUTE) value *= 60; if (type == HOUR) value *= 3600; value += toSeconds(); switch (type) { case SECOND: int secondVal = (value % 3600) % 60; if(secondVal<0){ second = 60+secondVal; add(MINUTE, -1); }else { second = secondVal; } case MINUTE: int minuteVal = (value % 3600) / 60; if(minuteVal<0){ minute = 60+minuteVal; add(HOUR, -1); }else { minute = minuteVal; } case HOUR: int hourVal = (value / 3600) % 24; if(hourVal<0){ hour = 24+hourVal; }else{ hour=hourVal; } } } Timepoint(Timepoint time);  Timepoint(@IntRange(from=0, to=23) int hour,
                     @IntRange(from=0, to=59) int minute,
                     @IntRange(from=0, to=59) int second);  Timepoint(@IntRange(from=0, to=23) int hour,
                     @IntRange(from=0, to=59) int minute);  Timepoint(@IntRange(from=0, to=23) int hour);  Timepoint(Parcel in); }
Timepoint implements Parcelable, Comparable<Timepoint> { public void add(TYPE type, int value) { if (type == MINUTE) value *= 60; if (type == HOUR) value *= 3600; value += toSeconds(); switch (type) { case SECOND: int secondVal = (value % 3600) % 60; if(secondVal<0){ second = 60+secondVal; add(MINUTE, -1); }else { second = secondVal; } case MINUTE: int minuteVal = (value % 3600) / 60; if(minuteVal<0){ minute = 60+minuteVal; add(HOUR, -1); }else { minute = minuteVal; } case HOUR: int hourVal = (value / 3600) % 24; if(hourVal<0){ hour = 24+hourVal; }else{ hour=hourVal; } } } Timepoint(Timepoint time);  Timepoint(@IntRange(from=0, to=23) int hour,
                     @IntRange(from=0, to=59) int minute,
                     @IntRange(from=0, to=59) int second);  Timepoint(@IntRange(from=0, to=23) int hour,
                     @IntRange(from=0, to=59) int minute);  Timepoint(@IntRange(from=0, to=23) int hour);  Timepoint(Parcel in); @IntRange(from=0, to=23) int getHour(); @IntRange(from=0, to=59) int getMinute(); @IntRange(from=0, to=59) int getSecond(); boolean isAM(); boolean isPM(); void setAM(); void setPM(); void add(TYPE type, int value); int get(@NonNull TYPE type); int toSeconds(); @Override int hashCode(); @Override boolean equals(Object o); boolean equals(@Nullable Timepoint time, @NonNull TYPE resolution); @Override int compareTo(@NonNull Timepoint t); @Override void writeToParcel(Parcel out, int flags); @Override int describeContents(); @Override String toString(); }
Timepoint implements Parcelable, Comparable<Timepoint> { public void add(TYPE type, int value) { if (type == MINUTE) value *= 60; if (type == HOUR) value *= 3600; value += toSeconds(); switch (type) { case SECOND: int secondVal = (value % 3600) % 60; if(secondVal<0){ second = 60+secondVal; add(MINUTE, -1); }else { second = secondVal; } case MINUTE: int minuteVal = (value % 3600) / 60; if(minuteVal<0){ minute = 60+minuteVal; add(HOUR, -1); }else { minute = minuteVal; } case HOUR: int hourVal = (value / 3600) % 24; if(hourVal<0){ hour = 24+hourVal; }else{ hour=hourVal; } } } Timepoint(Timepoint time);  Timepoint(@IntRange(from=0, to=23) int hour,
                     @IntRange(from=0, to=59) int minute,
                     @IntRange(from=0, to=59) int second);  Timepoint(@IntRange(from=0, to=23) int hour,
                     @IntRange(from=0, to=59) int minute);  Timepoint(@IntRange(from=0, to=23) int hour);  Timepoint(Parcel in); @IntRange(from=0, to=23) int getHour(); @IntRange(from=0, to=59) int getMinute(); @IntRange(from=0, to=59) int getSecond(); boolean isAM(); boolean isPM(); void setAM(); void setPM(); void add(TYPE type, int value); int get(@NonNull TYPE type); int toSeconds(); @Override int hashCode(); @Override boolean equals(Object o); boolean equals(@Nullable Timepoint time, @NonNull TYPE resolution); @Override int compareTo(@NonNull Timepoint t); @Override void writeToParcel(Parcel out, int flags); @Override int describeContents(); @Override String toString(); static final Parcelable.Creator<Timepoint> CREATOR; }