litesoft
@ HEAD
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
// This Source Code is in the Public Domain per: http://unlicense.org package org.litesoft.ui.support.nonpublic; import org.litesoft.commonfoundation.base.*; import org.litesoft.core.simpletypes.temporal.*; import java.util.*; public class CreditsData implements Comparable { private String mWho; private CalendarYMD mStartDate, mEndDate = null; public CreditsData( String pStartDateYYYY_MM_DD, String pWho, String pEndDateYYYY_MM_DD ) { mStartDate = CalendarYMD.fromYMD( Confirm.significant( "StartDate", pStartDateYYYY_MM_DD ) ); mWho = Confirm.significant( "Who", pWho ); if ( null != (pEndDateYYYY_MM_DD = ConstrainTo.significantOrNull( pEndDateYYYY_MM_DD )) ) { mEndDate = CalendarYMD.fromYMD( pEndDateYYYY_MM_DD ); } } public CreditsData( String pStartDateYYYY_MM_DD, String pWho ) { this( pStartDateYYYY_MM_DD, pWho, null ); } public String getWho() { return mWho; } public CalendarYMD getStartDate() { return mStartDate; } public CalendarYMD getEndDate() { return (mEndDate != null) ? mEndDate : new CalendarYMD( new Date() ); } public boolean wasActiveDuring( int pYear, int pMonth, int pFromDay, int pThruDay ) { return new CalendarYMDRange( new CalendarYMD( pYear, pMonth, pFromDay ), new CalendarYMD( pYear, pMonth, pThruDay ) ).sharesDates( new CalendarYMDRange( getStartDate(), getEndDate() ) ); } private Integer getActiveDuration() { return getStartDate().daysTill( getEndDate() ); } @Override public int compareTo( Object o ) { return compareTo( (CreditsData) o ); } public int compareTo( CreditsData them ) { // Note Reverse Order int rv = them.getActiveDuration().compareTo( this.getActiveDuration() ); return (rv != 0) ? rv : this.getWho().compareTo( them.getWho() ); } public boolean equals( CreditsData them ) { return (this == them) || ((them != null) && // this.mWho.equals( them.mWho ) && // this.mStartDate.equals( them.mStartDate ) && // Currently.areEqual( this.mEndDate, them.mEndDate )); } @Override public boolean equals( Object o ) { return (this == o) || ((o instanceof CreditsData) && equals( (CreditsData) o )); } @Override public int hashCode() { int result = (mEndDate == null) ? 0 : mEndDate.hashCode(); result = 31 * result + mStartDate.hashCode(); result = 31 * result + mWho.hashCode(); return result; } public static class MonthYear { private int mY, mM; public MonthYear( int pY, int pM ) { mY = pY; mM = pM; } public MonthYear( CalendarYMD pCalendarYMD ) { mY = pCalendarYMD.getYear(); mM = pCalendarYMD.getMonth(); } public int getYear() { return mY; } public int getMonth() { return mM; } public MonthYear incMonth() { if ( 13 == ++mM ) { mM = 1; mY++; } return this; } public String toString() { return twoDigits( mM ) + "/" + twoDigits( mY ); } private String twoDigits( int i ) { String s = Integer.toString( i + 100 ); while ( s.length() > 2 ) { s = s.substring( 1 ); } return s; } public boolean isLessThan( CalendarYMD them ) { if ( this.mY == them.getYear() ) { return (this.mM < them.getMonth()); } return (this.mY < them.getYear()); } public boolean isLessThanOrEqual( CalendarYMD them ) { if ( this.mY == them.getYear() ) { return (this.mM <= them.getMonth()); } return (this.mY < them.getYear()); } } } |
Commits for litesoft/trunk/Java/core/jvm1.4/src/org/litesoft/ui/support/nonpublic/CreditsData.java
Revision | Author | Commited | Message |
---|---|---|---|
950 Diff | GeorgeS | Thu 19 Jun, 2014 17:57:04 +0000 | New Lines |
948 Diff | GeorgeS | Sat 07 Jun, 2014 23:42:39 +0000 | Jusefuls Formatter Updated to New Code Format |
947 Diff | GeorgeS | Fri 06 Jun, 2014 23:36:56 +0000 | Correct Spelling of package! |
939 Diff | GeorgeS | Mon 02 Jun, 2014 21:30:31 +0000 | Extracting commonfoundation |
863 Diff | GeorgeS | Fri 16 Nov, 2012 22:14:29 +0000 | |
860 Diff | GeorgeS | Mon 05 Nov, 2012 01:39:02 +0000 | |
853 Diff | GeorgeS | Sun 04 Nov, 2012 15:18:21 +0000 | |
821 Diff | GeorgeS | Sun 19 Aug, 2012 00:08:41 +0000 | |
804 Diff | GeorgeS | Wed 15 Aug, 2012 12:48:51 +0000 | |
49 | GeorgeS | Mon 12 Apr, 2010 02:59:10 +0000 | License Text |