litesoft
@ 942
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 |
package org.litesoft.core.simpletypes.temporal; import org.litesoft.commonfoundation.base.*; import org.litesoft.commonfoundation.typeutils.*; import org.litesoft.commonfoundation.typeutils.gregorian.*; import org.litesoft.core.simpletypes.temporal.nonpublic.*; public abstract class AbstractTemporal<T extends AbstractTemporal> extends CalendarSupport<T> implements Comparable<T>, TemporalSimpleType, CalendarConstants { private static final long serialVersionUID = 1L; abstract public TemporalResolution getResolution(); @Override public final boolean equals( Object them ) { if ( this == them ) { return true; } if ( (them != null) && this.getClass().equals( them.getClass() ) ) { T zThem = Cast.it( them ); return LL_equalsNonNullStrict( zThem ); } return false; } @Override public final int hashCode() { return LL_hashCode(); } @Override public final int compareTo( T them ) { if ( them == null ) { return GREATER; } if ( !this.getClass().equals( them.getClass() ) ) { throw new ClassCastException( "Them '" + them.getClass() + "' is not a '" + this.getClass() + "'" ); } return LL_compareNonNullLoose( them ).result(); } // vvvvvvvvvvvvvvvvvv Support methods vvvvvvvvvvvvvvvvv protected final T us() { return Cast.it( this ); } protected static int fractionOf60( String pFraction ) { return (int) (60 * fractional( pFraction )); } protected static int fractionOf1000( String pFraction ) { return (int) (1000 * fractional( pFraction )); } private static double fractional( String pFraction ) { return fractional( pFraction, Integer.parseInt( pFraction ) ); } protected static double fractional( String pFraction, int pNumerator ) { double zDivisor = 1; for ( int zPowersOf10 = pFraction.length(); zPowersOf10 > 0; zPowersOf10-- ) { zDivisor *= 10; } return pNumerator / zDivisor; } protected static final String[] parseSimple( String pStringForm, String pSequentialSeperators ) { if ( null == (pStringForm = Strings.noEmpty( pStringForm )) ) { return null; } return SimpleParser.parse( pStringForm, pSequentialSeperators, pSequentialSeperators.length() + 1 ); } protected final ClassCastException incompatible( Object them ) { return new ClassCastException( "Them '" + them.getClass() + "' is not compatible with a '" + this.getClass() + "'" ); } abstract protected int LL_hashCode(); /** * T is non-null and of the same class, so should check everything! */ abstract protected boolean LL_equalsNonNullStrict( T them ); abstract protected Compare LL_compareNonNullLoose( Object them ); } |
Commits for litesoft/trunk/Java/core/Anywhere/src/org/litesoft/core/simpletypes/temporal/AbstractTemporal.java
Revision | Author | Commited | Message |
---|---|---|---|
942 Diff | GeorgeS | Mon 02 Jun, 2014 23:41:46 +0000 | Extracting commonfoundation |
939 Diff | GeorgeS | Mon 02 Jun, 2014 21:30:31 +0000 | Extracting commonfoundation |
912 Diff | GeorgeS | Fri 28 Jun, 2013 06:48:05 +0000 | Revert to mixed & Working (PEDS & Prioritizer) code! |
864 Diff | GeorgeS | Mon 19 Nov, 2012 01:48:25 +0000 | |
859 | GeorgeS | Mon 05 Nov, 2012 01:26:38 +0000 |