#
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. Licensed under the Elastic License
# 2.0 and the Server Side Public License, v 1; you may not use this file except
# in compliance with, at your election, the Elastic License 2.0 or the Server
# Side Public License, v 1.
#

#
# Painless definition file. This defines the hierarchy of classes,
# what methods and fields they have, etc.
#

#### Interfaces

class java.time.temporal.Temporal {
  Temporal minus(long,TemporalUnit)
  Temporal minus(TemporalAmount)
  Temporal plus(long,TemporalUnit)
  Temporal plus(TemporalAmount)
  long until(Temporal,TemporalUnit)
  Temporal with(TemporalAdjuster)
  Temporal with(TemporalField,long)
}

class java.time.temporal.TemporalAccessor {
  int get(TemporalField)
  long getLong(TemporalField)
  boolean isSupported(TemporalField)
  def query(TemporalQuery)
  ValueRange range(TemporalField)
  # An easy method to convert temporalAccessors to millis since epoch similar to Instan#toEpochMilli.
  long org.elasticsearch.painless.api.Augmentation toEpochMilli()
}

class java.time.temporal.TemporalAdjuster {
  Temporal adjustInto(Temporal)
}

class java.time.temporal.TemporalAmount {
  Temporal addTo(Temporal)
  long get(TemporalUnit)
  List getUnits()
  Temporal subtractFrom(Temporal)
}

class java.time.temporal.TemporalField {
  Temporal adjustInto(Temporal,long)
  TemporalUnit getBaseUnit()
  String getDisplayName(Locale)
  long getFrom(TemporalAccessor)
  TemporalUnit getRangeUnit()
  boolean isDateBased()
  boolean isSupportedBy(TemporalAccessor)
  boolean isTimeBased()
  ValueRange range()
  ValueRange rangeRefinedBy(TemporalAccessor)
  TemporalAccessor resolve(Map,TemporalAccessor,ResolverStyle)
  String toString()
}

class java.time.temporal.TemporalQuery {
  def queryFrom(TemporalAccessor)
}

class java.time.temporal.TemporalUnit {
  Temporal addTo(Temporal,long)
  long between(Temporal,Temporal)
  Duration getDuration()
  boolean isDateBased()
  boolean isDurationEstimated()
  boolean isSupportedBy(Temporal)
  boolean isTimeBased()
  String toString()
}

#### Classes

class java.time.temporal.IsoFields {
  TemporalField DAY_OF_QUARTER
  TemporalField QUARTER_OF_YEAR
  TemporalUnit QUARTER_YEARS
  TemporalField WEEK_BASED_YEAR
  TemporalUnit WEEK_BASED_YEARS
  TemporalField WEEK_OF_WEEK_BASED_YEAR
}

class java.time.temporal.JulianFields {
  TemporalField JULIAN_DAY
  TemporalField MODIFIED_JULIAN_DAY
  TemporalField RATA_DIE
}

class java.time.temporal.TemporalAdjusters {
  TemporalAdjuster dayOfWeekInMonth(int,DayOfWeek)
  TemporalAdjuster firstDayOfMonth()
  TemporalAdjuster firstDayOfNextMonth()
  TemporalAdjuster firstDayOfNextYear()
  TemporalAdjuster firstDayOfYear()
  TemporalAdjuster firstInMonth(DayOfWeek)
  TemporalAdjuster lastDayOfMonth()
  TemporalAdjuster lastDayOfYear()
  TemporalAdjuster lastInMonth(DayOfWeek)
  TemporalAdjuster next(DayOfWeek)
  TemporalAdjuster nextOrSame(DayOfWeek)
  TemporalAdjuster ofDateAdjuster(UnaryOperator)
  TemporalAdjuster previous(DayOfWeek)
  TemporalAdjuster previousOrSame(DayOfWeek)
}

class java.time.temporal.TemporalQueries {
  TemporalQuery chronology()
  TemporalQuery localDate()
  TemporalQuery localTime()
  TemporalQuery offset()
  TemporalQuery precision()
  TemporalQuery zone()
  TemporalQuery zoneId()
}

class java.time.temporal.ValueRange {
  int checkValidIntValue(long,TemporalField)
  long checkValidValue(long,TemporalField)
  long getLargestMinimum()
  long getMaximum()
  long getMinimum()
  long getSmallestMaximum()
  boolean isFixed()
  boolean isIntValue()
  boolean isValidIntValue(long)
  boolean isValidValue(long)
  ValueRange of(long,long)
  ValueRange of(long,long,long)
  ValueRange of(long,long,long,long)
}

class java.time.temporal.WeekFields {
  WeekFields ISO
  WeekFields SUNDAY_START
  TemporalUnit WEEK_BASED_YEARS
  TemporalField dayOfWeek()
  DayOfWeek getFirstDayOfWeek()
  int getMinimalDaysInFirstWeek()
  WeekFields of(DayOfWeek,int)
  WeekFields of(Locale)
  TemporalField weekBasedYear()
  TemporalField weekOfMonth()
  TemporalField weekOfWeekBasedYear()
  TemporalField weekOfYear()
}

#### Enums

class java.time.temporal.ChronoField {
  ChronoField ALIGNED_DAY_OF_WEEK_IN_MONTH
  ChronoField ALIGNED_DAY_OF_WEEK_IN_YEAR
  ChronoField ALIGNED_WEEK_OF_MONTH
  ChronoField ALIGNED_WEEK_OF_YEAR
  ChronoField AMPM_OF_DAY
  ChronoField CLOCK_HOUR_OF_AMPM
  ChronoField CLOCK_HOUR_OF_DAY
  ChronoField DAY_OF_MONTH
  ChronoField DAY_OF_WEEK
  ChronoField DAY_OF_YEAR
  ChronoField EPOCH_DAY
  ChronoField ERA
  ChronoField HOUR_OF_AMPM
  ChronoField HOUR_OF_DAY
  ChronoField INSTANT_SECONDS
  ChronoField MICRO_OF_DAY
  ChronoField MICRO_OF_SECOND
  ChronoField MILLI_OF_DAY
  ChronoField MILLI_OF_SECOND
  ChronoField MINUTE_OF_DAY
  ChronoField MINUTE_OF_HOUR
  ChronoField MONTH_OF_YEAR
  ChronoField NANO_OF_DAY
  ChronoField NANO_OF_SECOND
  ChronoField OFFSET_SECONDS
  ChronoField PROLEPTIC_MONTH
  ChronoField SECOND_OF_DAY
  ChronoField SECOND_OF_MINUTE
  ChronoField YEAR
  ChronoField YEAR_OF_ERA
  int checkValidIntValue(long)
  long checkValidValue(long)
  ChronoField valueOf(String)
  ChronoField[] values()
}

class java.time.temporal.ChronoUnit {
  ChronoUnit CENTURIES
  ChronoUnit DAYS
  ChronoUnit DECADES
  ChronoUnit ERAS
  ChronoUnit FOREVER
  ChronoUnit HALF_DAYS
  ChronoUnit HOURS
  ChronoUnit MICROS
  ChronoUnit MILLENNIA
  ChronoUnit MILLIS
  ChronoUnit MINUTES
  ChronoUnit MONTHS
  ChronoUnit NANOS
  ChronoUnit SECONDS
  ChronoUnit WEEKS
  ChronoUnit YEARS
  ChronoUnit valueOf(String)
  ChronoUnit[] values()
}

#### Exceptions

class java.time.temporal.UnsupportedTemporalTypeException {
  (String)
}
