/** * A limit chronology is only equal to a limit chronology with the same base chronology and * limits. * * @param obj the object to compare to * @return true if equal * @since 1.4 */ public boolean equals(Object obj) { if (this == obj) { return true; } if (obj instanceof LimitChronology == false) { return false; } LimitChronology chrono = (LimitChronology) obj; return getBase().equals(chrono.getBase()) && FieldUtils.equals(getLowerLimit(), chrono.getLowerLimit()) && FieldUtils.equals(getUpperLimit(), chrono.getUpperLimit()); }
/** * Gets an instance of the EthiopicChronology in the given time zone. * * @param zone the time zone to get the chronology in, null is default * @param minDaysInFirstWeek minimum number of days in first week of the year; default is 4 * @return a chronology in the specified time zone */ public static EthiopicChronology getInstance(DateTimeZone zone, int minDaysInFirstWeek) { if (zone == null) { zone = DateTimeZone.getDefault(); } EthiopicChronology chrono; EthiopicChronology[] chronos = cCache.get(zone); if (chronos == null) { chronos = new EthiopicChronology[7]; EthiopicChronology[] oldChronos = cCache.putIfAbsent(zone, chronos); if (oldChronos != null) { chronos = oldChronos; } } try { chrono = chronos[minDaysInFirstWeek - 1]; } catch (ArrayIndexOutOfBoundsException e) { throw new IllegalArgumentException("Invalid min days in first week: " + minDaysInFirstWeek); } if (chrono == null) { synchronized (chronos) { chrono = chronos[minDaysInFirstWeek - 1]; if (chrono == null) { if (zone == DateTimeZone.UTC) { // First create without a lower limit. chrono = new EthiopicChronology(null, null, minDaysInFirstWeek); // Impose lower limit and make another EthiopicChronology. DateTime lowerLimit = new DateTime(1, 1, 1, 0, 0, 0, 0, chrono); chrono = new EthiopicChronology( LimitChronology.getInstance(chrono, lowerLimit, null), null, minDaysInFirstWeek); } else { chrono = getInstance(DateTimeZone.UTC, minDaysInFirstWeek); chrono = new EthiopicChronology( ZonedChronology.getInstance(chrono, zone), null, minDaysInFirstWeek); } chronos[minDaysInFirstWeek - 1] = chrono; } } } return chrono; }