286 for (int i = 0; i < savingsInstantTransitions.length; i++) {
287 ZoneOffset before = wallOffsets[i];
288 ZoneOffset after = wallOffsets[i + 1];
289 ZoneOffsetTransition trans = new ZoneOffsetTransition(savingsInstantTransitions[i], before, after);
290 if (trans.isGap()) {
291 localTransitionList.add(trans.getDateTimeBefore());
292 localTransitionList.add(trans.getDateTimeAfter());
293 } else {
294 localTransitionList.add(trans.getDateTimeAfter());
295 localTransitionList.add(trans.getDateTimeBefore());
296 }
297 }
298 this.savingsLocalTransitions = localTransitionList.toArray(new LocalDateTime[localTransitionList.size()]);
299 }
300 }
301
302 /**
303 * Creates an instance of ZoneRules that has fixed zone rules.
304 *
305 * @param offset the offset this fixed zone rules is based on, not null
306 * @return the zone rules, not null
307 * @see #isFixedOffset()
308 */
309 private ZoneRules(ZoneOffset offset) {
310 this.standardOffsets = new ZoneOffset[1];
311 this.standardOffsets[0] = offset;
312 this.standardTransitions = EMPTY_LONG_ARRAY;
313 this.savingsInstantTransitions = EMPTY_LONG_ARRAY;
314 this.savingsLocalTransitions = EMPTY_LDT_ARRAY;
315 this.wallOffsets = standardOffsets;
316 this.lastRules = EMPTY_LASTRULES;
317 }
318
319 /**
320 * Defend against malicious streams.
321 *
322 * @param s the stream to read
323 * @throws InvalidObjectException always
324 */
325 private void readObject(ObjectInputStream s) throws InvalidObjectException {
326 throw new InvalidObjectException("Deserialization via serialization delegate");
953 * <p>
954 * The complete set of transitions for this rules instance is defined by this method
955 * and {@link #getTransitions()}. This method returns instances of {@link ZoneOffsetTransitionRule}
956 * that define an algorithm for when transitions will occur.
957 * <p>
958 * For any given {@code ZoneRules}, this list contains the transition rules for years
959 * beyond those years that have been fully defined. These rules typically refer to future
960 * daylight saving time rule changes.
961 * <p>
962 * If the zone defines daylight savings into the future, then the list will normally
963 * be of size two and hold information about entering and exiting daylight savings.
964 * If the zone does not have daylight savings, or information about future changes
965 * is uncertain, then the list will be empty.
966 * <p>
967 * The list will be empty for fixed offset rules and for any time-zone where there is no
968 * daylight saving time. The list will also be empty if the transition rules are unknown.
969 *
970 * @return an immutable list of transition rules, not null
971 */
972 public List<ZoneOffsetTransitionRule> getTransitionRules() {
973 return Collections.unmodifiableList(Arrays.asList(lastRules));
974 }
975
976 /**
977 * Checks if this set of rules equals another.
978 * <p>
979 * Two rule sets are equal if they will always result in the same output
980 * for any given input instant or local date-time.
981 * Rules from two different groups may return false even if they are in fact the same.
982 * <p>
983 * This definition should result in implementations comparing their entire state.
984 *
985 * @param otherRules the other rules, null returns false
986 * @return true if this rules is the same as that specified
987 */
988 @Override
989 public boolean equals(Object otherRules) {
990 if (this == otherRules) {
991 return true;
992 }
993 if (otherRules instanceof ZoneRules) {
|
286 for (int i = 0; i < savingsInstantTransitions.length; i++) {
287 ZoneOffset before = wallOffsets[i];
288 ZoneOffset after = wallOffsets[i + 1];
289 ZoneOffsetTransition trans = new ZoneOffsetTransition(savingsInstantTransitions[i], before, after);
290 if (trans.isGap()) {
291 localTransitionList.add(trans.getDateTimeBefore());
292 localTransitionList.add(trans.getDateTimeAfter());
293 } else {
294 localTransitionList.add(trans.getDateTimeAfter());
295 localTransitionList.add(trans.getDateTimeBefore());
296 }
297 }
298 this.savingsLocalTransitions = localTransitionList.toArray(new LocalDateTime[localTransitionList.size()]);
299 }
300 }
301
302 /**
303 * Creates an instance of ZoneRules that has fixed zone rules.
304 *
305 * @param offset the offset this fixed zone rules is based on, not null
306 * @see #isFixedOffset()
307 */
308 private ZoneRules(ZoneOffset offset) {
309 this.standardOffsets = new ZoneOffset[1];
310 this.standardOffsets[0] = offset;
311 this.standardTransitions = EMPTY_LONG_ARRAY;
312 this.savingsInstantTransitions = EMPTY_LONG_ARRAY;
313 this.savingsLocalTransitions = EMPTY_LDT_ARRAY;
314 this.wallOffsets = standardOffsets;
315 this.lastRules = EMPTY_LASTRULES;
316 }
317
318 /**
319 * Defend against malicious streams.
320 *
321 * @param s the stream to read
322 * @throws InvalidObjectException always
323 */
324 private void readObject(ObjectInputStream s) throws InvalidObjectException {
325 throw new InvalidObjectException("Deserialization via serialization delegate");
952 * <p>
953 * The complete set of transitions for this rules instance is defined by this method
954 * and {@link #getTransitions()}. This method returns instances of {@link ZoneOffsetTransitionRule}
955 * that define an algorithm for when transitions will occur.
956 * <p>
957 * For any given {@code ZoneRules}, this list contains the transition rules for years
958 * beyond those years that have been fully defined. These rules typically refer to future
959 * daylight saving time rule changes.
960 * <p>
961 * If the zone defines daylight savings into the future, then the list will normally
962 * be of size two and hold information about entering and exiting daylight savings.
963 * If the zone does not have daylight savings, or information about future changes
964 * is uncertain, then the list will be empty.
965 * <p>
966 * The list will be empty for fixed offset rules and for any time-zone where there is no
967 * daylight saving time. The list will also be empty if the transition rules are unknown.
968 *
969 * @return an immutable list of transition rules, not null
970 */
971 public List<ZoneOffsetTransitionRule> getTransitionRules() {
972 return List.of(lastRules);
973 }
974
975 /**
976 * Checks if this set of rules equals another.
977 * <p>
978 * Two rule sets are equal if they will always result in the same output
979 * for any given input instant or local date-time.
980 * Rules from two different groups may return false even if they are in fact the same.
981 * <p>
982 * This definition should result in implementations comparing their entire state.
983 *
984 * @param otherRules the other rules, null returns false
985 * @return true if this rules is the same as that specified
986 */
987 @Override
988 public boolean equals(Object otherRules) {
989 if (this == otherRules) {
990 return true;
991 }
992 if (otherRules instanceof ZoneRules) {
|