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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidUnset 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.doubleReturns the elevation, in meters above sea level.Returns theJulianDateto be used.doubleReturns the latitude.doubleReturns the latitude.doubleReturns the longitude.doubleReturns the longitude.booleanReturnstrueif 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 givenInstantinstance.Uses the givenLocalDateinstance, and assumes midnight.on(LocalDateTime dateTime) Uses the givenLocalDateTimeinstance.on(ZonedDateTime dateTime) Uses the givenZonedDateTimeinstance.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 theLocationParameterat 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, waitMethods inherited from interface org.shredzone.commons.suncalc.param.LocationParameter
at, at, elevationFt, height, heightFt, latitude, longitudeMethods inherited from interface org.shredzone.commons.suncalc.param.TimeParameter
localTime, on, on, on, timezone, timezone, today, tomorrow, utcMethods inherited from interface org.shredzone.commons.suncalc.param.WindowParameter
fullCycle, oneDay
-
Constructor Details
-
BaseBuilder
public BaseBuilder()
-
-
Method Details
-
on
Description copied from interface:TimeParameterUses the givenZonedDateTimeinstance.- Specified by:
onin interfaceTimeParameter<T>- Parameters:
dateTime-ZonedDateTimeto be used.- Returns:
- itself
-
on
Description copied from interface:TimeParameterUses the givenLocalDateTimeinstance.- Specified by:
onin interfaceTimeParameter<T>- Parameters:
dateTime-LocalDateTimeto be used.- Returns:
- itself
-
on
Description copied from interface:TimeParameterUses the givenLocalDateinstance, and assumes midnight.- Specified by:
onin interfaceTimeParameter<T>- Parameters:
date-LocalDateto be used.- Returns:
- itself
-
on
Description copied from interface:TimeParameterUses the givenInstantinstance.- Specified by:
onin interfaceTimeParameter<T>- Parameters:
instant-Instantto be used.- Returns:
- itself
-
on
Description copied from interface:TimeParameterSets date and time. Note that also seconds can be passed in for convenience, but the results are not that accurate.- Specified by:
onin 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:TimeParameterSets the current date and time. This is the default.- Specified by:
nowin interfaceTimeParameter<T>- Returns:
- itself
-
plusDays
Description copied from interface:TimeParameterAdds a number of days to the current date.- Specified by:
plusDaysin interfaceTimeParameter<T>- Parameters:
days- Number of days to add- Returns:
- itself
-
midnight
Description copied from interface:TimeParameterSets the time to the start of the current date ("last midnight").- Specified by:
midnightin interfaceTimeParameter<T>- Returns:
- itself
-
timezone
Description copied from interface:TimeParameterSets the givenZoneId. The local time is retained, so the parameter order is not important.- Specified by:
timezonein interfaceTimeParameter<T>- Parameters:
tz-ZoneIdto be used.- Returns:
- itself
-
latitude
Description copied from interface:LocationParameterSets the latitude.- Specified by:
latitudein interfaceLocationParameter<T>- Parameters:
lat- Latitude, in degrees.- Returns:
- itself
-
longitude
Description copied from interface:LocationParameterSets the longitude.- Specified by:
longitudein interfaceLocationParameter<T>- Parameters:
lng- Longitude, in degrees.- Returns:
- itself
-
elevation
Description copied from interface:LocationParameterSets the elevation.- Specified by:
elevationin 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:WindowParameterLimits the calculation window to the givenDuration.- Specified by:
limitin 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:WindowParameterSets a reverse calculation window. It will end at the given date.- Specified by:
reversein interfaceWindowParameter<T>- Returns:
- itself
-
forward
Description copied from interface:WindowParameterSets a forward calculation window. It will start at the given date.This is the default.
- Specified by:
forwardin interfaceWindowParameter<T>- Returns:
- itself
-
sameTimeAs
Description copied from interface:TimeParameterUses the same time as given in theTimeParameter.Changes to the source parameter will not affect this parameter, though.
- Specified by:
sameTimeAsin interfaceTimeParameter<T>- Parameters:
t-TimeParameterto be used.- Returns:
- itself
-
sameLocationAs
Description copied from interface:LocationParameterUses the same location as given in theLocationParameterat this moment.Changes to the source parameter will not affect this parameter, though.
- Specified by:
sameLocationAsin interfaceLocationParameter<T>- Parameters:
l-LocationParameterto be used.- Returns:
- itself
-
sameWindowAs
Description copied from interface:WindowParameterUses the same window as given in theWindowParameter.Changes to the source parameter will not affect this parameter, though.
- Specified by:
sameWindowAsin interfaceWindowParameter<T>- Parameters:
w-WindowParameterto be used.- Returns:
- itself
-
copy
Description copied from interface:GenericParameterCreates a copy of the current parameters. The copy can be changed independently.- Specified by:
copyin 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 theJulianDateto be used.- Returns:
JulianDate
-
hasLocation
Returnstrueif 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
-