Class BaseBuilder<T>
java.lang.Object
org.shredzone.commons.suncalc.util.BaseBuilder<T>
- Type Parameters:
T
- Type of the final builder
- All Implemented Interfaces:
Cloneable
,GenericParameter<T>
,LocationParameter<T>
,TimeParameter<T>
,WindowParameter<T>
public class BaseBuilder<T>
extends Object
implements GenericParameter<T>, LocationParameter<T>, TimeParameter<T>, WindowParameter<T>, Cloneable
A base implementation of
LocationParameter
, TimeParameter
, and
WindowParameter
.
For internal use only.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Unset the geolocation.copy()
Creates a copy of the current parameters.elevation
(double h) Sets the elevation.forward()
Sets a forward calculation window.Returns the duration of the time window.double
Returns the elevation, in meters above sea level.Returns theJulianDate
to be used.double
Returns the latitude.double
Returns the latitude.double
Returns the longitude.double
Returns the longitude.boolean
Returnstrue
if a geolocation has been set.latitude
(double lat) Sets the latitude.Limits the calculation window to the givenDuration
.longitude
(double lng) Sets the longitude.midnight()
Sets the time to the start of the current date ("last midnight").now()
Sets the current date and time.on
(int year, int month, int date, int hour, int minute, int second) Sets date and time.Uses the givenInstant
instance.Uses the givenLocalDate
instance, and assumes midnight.on
(LocalDateTime dateTime) Uses the givenLocalDateTime
instance.on
(ZonedDateTime dateTime) Uses the givenZonedDateTime
instance.plusDays
(int days) Adds a number of days to the current date.reverse()
Sets a reverse calculation window.Uses the same location as given in theLocationParameter
at this moment.sameTimeAs
(TimeParameter<?> t) Uses the same time as given in theTimeParameter
.sameWindowAs
(WindowParameter<?> w) Uses the same window as given in theWindowParameter
.Sets the givenZoneId
.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.shredzone.commons.suncalc.param.LocationParameter
at, at, elevationFt, height, heightFt, latitude, longitude
Methods inherited from interface org.shredzone.commons.suncalc.param.TimeParameter
localTime, on, on, on, timezone, timezone, today, tomorrow, utc
Methods inherited from interface org.shredzone.commons.suncalc.param.WindowParameter
fullCycle, oneDay
-
Constructor Details
-
BaseBuilder
public BaseBuilder()
-
-
Method Details
-
on
Description copied from interface:TimeParameter
Uses the givenZonedDateTime
instance.- Specified by:
on
in interfaceTimeParameter<T>
- Parameters:
dateTime
-ZonedDateTime
to be used.- Returns:
- itself
-
on
Description copied from interface:TimeParameter
Uses the givenLocalDateTime
instance.- Specified by:
on
in interfaceTimeParameter<T>
- Parameters:
dateTime
-LocalDateTime
to be used.- Returns:
- itself
-
on
Description copied from interface:TimeParameter
Uses the givenLocalDate
instance, and assumes midnight.- Specified by:
on
in interfaceTimeParameter<T>
- Parameters:
date
-LocalDate
to be used.- Returns:
- itself
-
on
Description copied from interface:TimeParameter
Uses the givenInstant
instance.- Specified by:
on
in interfaceTimeParameter<T>
- Parameters:
instant
-Instant
to be used.- Returns:
- itself
-
on
Description copied from interface:TimeParameter
Sets date and time. Note that also seconds can be passed in for convenience, but the results are not that accurate.- Specified by:
on
in interfaceTimeParameter<T>
- Parameters:
year
- Yearmonth
- Month (1 = January, 2 = February, ...)date
- Day of monthhour
- Hour of dayminute
- Minutesecond
- Second- Returns:
- itself
-
now
Description copied from interface:TimeParameter
Sets the current date and time. This is the default.- Specified by:
now
in interfaceTimeParameter<T>
- Returns:
- itself
-
plusDays
Description copied from interface:TimeParameter
Adds a number of days to the current date.- Specified by:
plusDays
in interfaceTimeParameter<T>
- Parameters:
days
- Number of days to add- Returns:
- itself
-
midnight
Description copied from interface:TimeParameter
Sets the time to the start of the current date ("last midnight").- Specified by:
midnight
in interfaceTimeParameter<T>
- Returns:
- itself
-
timezone
Description copied from interface:TimeParameter
Sets the givenZoneId
. The local time is retained, so the parameter order is not important.- Specified by:
timezone
in interfaceTimeParameter<T>
- Parameters:
tz
-ZoneId
to be used.- Returns:
- itself
-
latitude
Description copied from interface:LocationParameter
Sets the latitude.- Specified by:
latitude
in interfaceLocationParameter<T>
- Parameters:
lat
- Latitude, in degrees.- Returns:
- itself
-
longitude
Description copied from interface:LocationParameter
Sets the longitude.- Specified by:
longitude
in interfaceLocationParameter<T>
- Parameters:
lng
- Longitude, in degrees.- Returns:
- itself
-
elevation
Description copied from interface:LocationParameter
Sets the elevation.- Specified by:
elevation
in interfaceLocationParameter<T>
- Parameters:
h
- Elevation, in meters above sea level. Default: 0.0 m. Negative values are silently changed to the acceptable minimum of 0.0 m.- Returns:
- itself
- See Also:
-
limit
Description copied from interface:WindowParameter
Limits the calculation window to the givenDuration
.- Specified by:
limit
in interfaceWindowParameter<T>
- Parameters:
duration
- Duration of the calculation window. A negative duration sets a reverse time window, giving result times in the past.- Returns:
- itself
-
reverse
Description copied from interface:WindowParameter
Sets a reverse calculation window. It will end at the given date.- Specified by:
reverse
in interfaceWindowParameter<T>
- Returns:
- itself
-
forward
Description copied from interface:WindowParameter
Sets a forward calculation window. It will start at the given date.This is the default.
- Specified by:
forward
in interfaceWindowParameter<T>
- Returns:
- itself
-
sameTimeAs
Description copied from interface:TimeParameter
Uses the same time as given in theTimeParameter
.Changes to the source parameter will not affect this parameter, though.
- Specified by:
sameTimeAs
in interfaceTimeParameter<T>
- Parameters:
t
-TimeParameter
to be used.- Returns:
- itself
-
sameLocationAs
Description copied from interface:LocationParameter
Uses the same location as given in theLocationParameter
at this moment.Changes to the source parameter will not affect this parameter, though.
- Specified by:
sameLocationAs
in interfaceLocationParameter<T>
- Parameters:
l
-LocationParameter
to be used.- Returns:
- itself
-
sameWindowAs
Description copied from interface:WindowParameter
Uses the same window as given in theWindowParameter
.Changes to the source parameter will not affect this parameter, though.
- Specified by:
sameWindowAs
in interfaceWindowParameter<T>
- Parameters:
w
-WindowParameter
to be used.- Returns:
- itself
-
copy
Description copied from interface:GenericParameter
Creates a copy of the current parameters. The copy can be changed independently.- Specified by:
copy
in interfaceGenericParameter<T>
-
getLongitude
Returns the longitude.- Returns:
- Longitude, in degrees.
-
getLatitude
Returns the latitude.- Returns:
- Latitude, in degrees.
-
getLongitudeRad
Returns the longitude.- Returns:
- Longitude, in radians.
-
getLatitudeRad
Returns the latitude.- Returns:
- Latitude, in radians.
-
getElevation
Returns the elevation, in meters above sea level.- Returns:
- Elevation, meters above sea level
-
getJulianDate
Returns theJulianDate
to be used.- Returns:
JulianDate
-
hasLocation
Returnstrue
if a geolocation has been set.- Since:
- 3.9
-
clearLocation
Unset the geolocation.- Since:
- 3.9
-
getDuration
Returns the duration of the time window.- Since:
- 3.11
-