8310033: Clarify return value of Java Time compareTo methods

Reviewed-by: bpb, scolebourne, prappo, naoto
This commit is contained in:
Roger Riggs 2023-07-27 14:01:25 +00:00
parent 25058cd23a
commit 8650026ff1
17 changed files with 84 additions and 35 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -656,7 +656,7 @@ public abstract class AbstractChronology implements Chronology {
* Subclasses must compare any additional state that they store.
*
* @param other the other chronology to compare to, not null
* @return the comparator value, negative if less, positive if greater
* @return the comparator value, that is this ID string compared with the {@code other}'s ID string
*/
@Override
public int compareTo(Chronology other) {

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -700,7 +700,11 @@ public interface ChronoLocalDate
* This default implementation performs the comparison defined above.
*
* @param other the other date to compare to, not null
* @return the comparator value, negative if less, positive if greater
* @return the comparator value, that is the comparison of this local date with
* the {@code other} local date and this chronology with the {@code other} chronology,
* in order, returning the first non-zero result, and otherwise returning zero
* @see #isBefore
* @see #isAfter
*/
@Override
default int compareTo(ChronoLocalDate other) {

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -500,7 +500,11 @@ public interface ChronoLocalDateTime<D extends ChronoLocalDate>
* This default implementation performs the comparison defined above.
*
* @param other the other date-time to compare to, not null
* @return the comparator value, negative if less, positive if greater
* @return the comparator value, that is the comparison of this local date-time with
* the {@code other} local date-time and this chronology with the {@code other} chronology,
* in order, returning the first non-zero result, and otherwise returning zero
* @see #isBefore
* @see #isAfter
*/
@Override
default int compareTo(ChronoLocalDateTime<?> other) {

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -569,7 +569,11 @@ public interface ChronoZonedDateTime<D extends ChronoLocalDate>
* This default implementation performs the comparison defined above.
*
* @param other the other date-time to compare to, not null
* @return the comparator value, negative if less, positive if greater
* @return the comparator value, that is the comparison of this with the {@code other} values for the instant,
* the local date-time, the zone ID, and the chronology, in order, returning the first non-zero result,
* and otherwise returning zero
* @see #isBefore
* @see #isAfter
*/
@Override
default int compareTo(ChronoZonedDateTime<?> other) {

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -807,7 +807,9 @@ public interface Chronology extends Comparable<Chronology> {
* It is "consistent with equals", as defined by {@link Comparable}.
*
* @param other the other chronology to compare to, not null
* @return the comparator value, negative if less, positive if greater
* @return the comparator value, that is this ID string compared with the {@code other}'s ID string
* unless the ID strings are equal and
* the chronology distinguishes instances using additional information
*/
@Override
int compareTo(Chronology other);