/** * Gets a hash code for the ReadablePartial that is compatible with the * equals method. * * @return a suitable hash code */ public int hashCode() { int total = 157; for (int i = 0, isize = size(); i < isize; i++) { total = 23 * total + getValue(i); total = 23 * total + getFieldType(i).hashCode(); } total += getChronology().hashCode(); return total; }
/** * Is this partial the same as the specified partial. * <p> * The fields are compared in order, from largest to smallest. * If all fields are equal, the result is true. * <p> * You may not pass null into this method. This is because you need * a time zone to accurately determine the current date. * * @param partial a partial to check against, must not be null * @return true if this date is the same as the date passed in * @throws IllegalArgumentException if the specified partial is null * @throws ClassCastException if the partial has field types that don't match * @since 1.1 */ public boolean isEqual(ReadablePartial partial) { if (partial == null) { throw new IllegalArgumentException("Partial cannot be null"); } return compareTo(partial) == 0; }
/** * Gets the field at the specified index. * * @param index the index * @return the field * @throws IndexOutOfBoundsException if the index is invalid */ public DateTimeField getField(int index) { return getField(index, getChronology()); }
/** * Get the value of one of the fields of a datetime. * <p> * The field specified must be one of those that is supported by the partial. * * @param type a DateTimeFieldType instance that is supported by this partial * @return the value of that field * @throws IllegalArgumentException if the field is null or not supported */ public int get(DateTimeFieldType type) { return getValue(indexOfSupported(type)); }
/** * Gets an array of the fields that this partial supports. * <p> * The fields are returned largest to smallest, for example Hour, Minute, Second. * * @return the fields supported in an array that may be altered, largest to smallest */ public DateTimeField[] getFields() { DateTimeField[] result = new DateTimeField[size()]; for (int i = 0; i < result.length; i++) { result[i] = getField(i); } return result; }
/** * Gets an array of the field types that this partial supports. * <p> * The fields are returned largest to smallest, for example Hour, Minute, Second. * * @return the fields supported in an array that may be altered, largest to smallest */ public DateTimeFieldType[] getFieldTypes() { DateTimeFieldType[] result = new DateTimeFieldType[size()]; for (int i = 0; i < result.length; i++) { result[i] = getFieldType(i); } return result; }
return 0; if (size() != other.size()) { throw new ClassCastException("ReadablePartial objects must have matching field types"); for (int i = 0, isize = size(); i < isize; i++) { if (getFieldType(i) != other.getFieldType(i)) { throw new ClassCastException("ReadablePartial objects must have matching field types"); for (int i = 0, isize = size(); i < isize; i++) { if (getValue(i) > other.getValue(i)) { return 1; if (getValue(i) < other.getValue(i)) { return -1;
/** * Checks whether the field specified is supported by this partial. * * @param type the type to check, may be null which returns false * @return true if the field is supported */ public boolean isSupported(DateTimeFieldType type) { return (indexOf(type) != -1); }
/** * Gets an array of the value of each of the fields that this partial supports. * <p> * The fields are returned largest to smallest, for example Hour, Minute, Second. * Each value corresponds to the same array index as <code>getFields()</code> * * @return the current values of each field in an array that may be altered, largest to smallest */ public int[] getValues() { int[] result = new int[size()]; for (int i = 0; i < result.length; i++) { result[i] = getValue(i); } return result; }
/** * Gets the index of the specified field, or -1 if the field is unsupported. * * @param type the type to check, may be null which returns -1 * @return the index of the field, -1 if unsupported */ public int indexOf(DateTimeFieldType type) { for (int i = 0, isize = size(); i < isize; i++) { if (getFieldType(i) == type) { return i; } } return -1; }
/** * Get the value of one of the fields of a datetime. * <p> * The field specified must be one of those that is supported by the partial. * * @param type a DateTimeFieldType instance that is supported by this partial * @return the value of that field * @throws IllegalArgumentException if the field is null or not supported */ public int get(DateTimeFieldType type) { return getValue(indexOfSupported(type)); }
return 0; if (size() != other.size()) { throw new ClassCastException("ReadablePartial objects must have matching field types"); for (int i = 0, isize = size(); i < isize; i++) { if (getFieldType(i) != other.getFieldType(i)) { throw new ClassCastException("ReadablePartial objects must have matching field types"); for (int i = 0, isize = size(); i < isize; i++) { if (getValue(i) > other.getValue(i)) { return 1; if (getValue(i) < other.getValue(i)) { return -1;
/** * Checks whether the field specified is supported by this partial. * * @param type the type to check, may be null which returns false * @return true if the field is supported */ public boolean isSupported(DateTimeFieldType type) { return (indexOf(type) != -1); }
/** * Gets an array of the fields that this partial supports. * <p> * The fields are returned largest to smallest, for example Hour, Minute, Second. * * @return the fields supported in an array that may be altered, largest to smallest */ public DateTimeField[] getFields() { DateTimeField[] result = new DateTimeField[size()]; for (int i = 0; i < result.length; i++) { result[i] = getField(i); } return result; }
/** * Gets an array of the value of each of the fields that this partial supports. * <p> * The fields are returned largest to smallest, for example Hour, Minute, Second. * Each value corresponds to the same array index as <code>getFields()</code> * * @return the current values of each field in an array that may be altered, largest to smallest */ public int[] getValues() { int[] result = new int[size()]; for (int i = 0; i < result.length; i++) { result[i] = getValue(i); } return result; }
/** * Gets a hash code for the ReadablePartial that is compatible with the * equals method. * * @return a suitable hash code */ public int hashCode() { int total = 157; for (int i = 0, isize = size(); i < isize; i++) { total = 23 * total + getValue(i); total = 23 * total + getFieldType(i).hashCode(); } total += getChronology().hashCode(); return total; }
/** * Gets the field at the specified index. * * @param index the index * @return the field * @throws IndexOutOfBoundsException if the index is invalid */ public DateTimeField getField(int index) { return getField(index, getChronology()); }
/** * Gets an array of the field types that this partial supports. * <p> * The fields are returned largest to smallest, for example Hour, Minute, Second. * * @return the fields supported in an array that may be altered, largest to smallest */ public DateTimeFieldType[] getFieldTypes() { DateTimeFieldType[] result = new DateTimeFieldType[size()]; for (int i = 0; i < result.length; i++) { result[i] = getFieldType(i); } return result; }
/** * Get the value of one of the fields of a datetime. * <p> * The field specified must be one of those that is supported by the partial. * * @param type a DateTimeFieldType instance that is supported by this partial * @return the value of that field * @throws IllegalArgumentException if the field is null or not supported */ public int get(DateTimeFieldType type) { return getValue(indexOfSupported(type)); }
return 0; if (size() != other.size()) { throw new ClassCastException("ReadablePartial objects must have matching field types"); for (int i = 0, isize = size(); i < isize; i++) { if (getFieldType(i) != other.getFieldType(i)) { throw new ClassCastException("ReadablePartial objects must have matching field types"); for (int i = 0, isize = size(); i < isize; i++) { if (getValue(i) > other.getValue(i)) { return 1; if (getValue(i) < other.getValue(i)) { return -1;