370 * This checks to see if the given offset will be valid at some point in the transition. 371 * A gap will always return false. 372 * An overlap will return true if the offset is either the before or after offset. 373 * 374 * @param offset the offset to check, null returns false 375 * @return true if the offset is valid during the transition 376 */ 377 public boolean isValidOffset(ZoneOffset offset) { 378 return isGap() ? false : (getOffsetBefore().equals(offset) || getOffsetAfter().equals(offset)); 379 } 380 381 /** 382 * Gets the valid offsets during this transition. 383 * <p> 384 * A gap will return an empty list, while an overlap will return both offsets. 385 * 386 * @return the list of valid offsets 387 */ 388 List<ZoneOffset> getValidOffsets() { 389 if (isGap()) { 390 return Collections.emptyList(); 391 } 392 return Arrays.asList(getOffsetBefore(), getOffsetAfter()); 393 } 394 395 //----------------------------------------------------------------------- 396 /** 397 * Compares this transition to another based on the transition instant. 398 * <p> 399 * This compares the instants of each transition. 400 * The offsets are ignored, making this order inconsistent with equals. 401 * 402 * @param transition the transition to compare to, not null 403 * @return the comparator value, negative if less, positive if greater 404 */ 405 @Override 406 public int compareTo(ZoneOffsetTransition transition) { 407 return Long.compare(epochSecond, transition.epochSecond); 408 } 409 410 //----------------------------------------------------------------------- 411 /** 412 * Checks if this object equals another. | 370 * This checks to see if the given offset will be valid at some point in the transition. 371 * A gap will always return false. 372 * An overlap will return true if the offset is either the before or after offset. 373 * 374 * @param offset the offset to check, null returns false 375 * @return true if the offset is valid during the transition 376 */ 377 public boolean isValidOffset(ZoneOffset offset) { 378 return isGap() ? false : (getOffsetBefore().equals(offset) || getOffsetAfter().equals(offset)); 379 } 380 381 /** 382 * Gets the valid offsets during this transition. 383 * <p> 384 * A gap will return an empty list, while an overlap will return both offsets. 385 * 386 * @return the list of valid offsets 387 */ 388 List<ZoneOffset> getValidOffsets() { 389 if (isGap()) { 390 return List.of(); 391 } 392 return List.of(getOffsetBefore(), getOffsetAfter()); 393 } 394 395 //----------------------------------------------------------------------- 396 /** 397 * Compares this transition to another based on the transition instant. 398 * <p> 399 * This compares the instants of each transition. 400 * The offsets are ignored, making this order inconsistent with equals. 401 * 402 * @param transition the transition to compare to, not null 403 * @return the comparator value, negative if less, positive if greater 404 */ 405 @Override 406 public int compareTo(ZoneOffsetTransition transition) { 407 return Long.compare(epochSecond, transition.epochSecond); 408 } 409 410 //----------------------------------------------------------------------- 411 /** 412 * Checks if this object equals another. |