----- Mail original ----- > De: "Michael Kuhlmann" <j...@fiolino.de> > À: "core-libs-dev" <core-libs-dev@openjdk.java.net> > Envoyé: Mercredi 24 Mars 2021 13:23:08 > Objet: Re: RFR: 8263668: Update java.time to use instanceof pattern variable
> On 3/24/21 12:09 PM, Rémi Forax wrote: >> On Wed, 24 Mar 2021 09:56:16 GMT, Patrick Concannon <pconcan...@openjdk.org> >> wrote: >> >>> Hi, >>> >>> Could someone please review my code for updating the code in the `java.time` >>> package to make use of the `instanceof` pattern variable? >>> >>> Kind regards, >>> Patrick >> >> src/java.base/share/classes/java/time/format/DateTimeFormatterBuilder.java >> line >> 168: >> >>> 166: private static final TemporalQuery<ZoneId> QUERY_REGION_ONLY = >>> (temporal) -> { >>> 167: ZoneId zone = temporal.query(TemporalQueries.zoneId()); >>> 168: return (zone != null && (!(zone instanceof ZoneOffset)) ? zone >>> : >>> null); >> >> i find this code hard to read >> `return (zone != null && (!(zone instanceof ZoneOffset))) ? zone : null;` >> seems better` > > The whole null check is not necessary. > > `return zone instanceof ZoneOffset ? null : zone;` yes, you are right ! > >> ------------- >> >> PR: https://git.openjdk.java.net/jdk/pull/3170 Rémi