001/* 002 * Shredzone Commons - suncalc 003 * 004 * Copyright (C) 2018 Richard "Shred" Körber 005 * http://commons.shredzone.org 006 * 007 * Licensed under the Apache License, Version 2.0 (the "License"); 008 * you may not use this file except in compliance with the License. 009 * 010 * This program is distributed in the hope that it will be useful, 011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 013 */ 014package org.shredzone.commons.suncalc.param; 015 016/** 017 * Result time based parameters. 018 * <p> 019 * Use them to give information about the desired quality of the result. 020 * 021 * @param <T> 022 * Type of the final builder 023 * @since 2.3 024 */ 025public interface TimeResultParameter<T> { 026 027 /** 028 * Time unit to truncate the result to. 029 * 030 * @param unit 031 * {@link Unit} to use. By default, {@link Unit#MINUTES} is used. 032 * @return itself 033 */ 034 T truncatedTo(Unit unit); 035 036 /** 037 * Available chrono units. 038 * 039 * @since 2.3 040 */ 041 enum Unit { 042 043 /** 044 * Round to the nearest full second. Note that due to the simplified formulas used 045 * in suncalc, the result is never accurate to the second. 046 */ 047 SECONDS, 048 049 /** 050 * Round to the nearest full minute. This is the default. 051 */ 052 MINUTES, 053 054 /** 055 * Round to the nearest full hour. 056 */ 057 HOURS, 058 059 /** 060 * Round down to the full day. Note that, unlike the other {@link Unit}, the 061 * result is always rounded down to full days. 062 */ 063 DAYS 064 065 } 066 067}