All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.vaadin.v7.shared.ui.datefield.Resolution Maven / Gradle / Ivy

There is a newer version: 8.27.3
Show newest version
/*
 * Copyright (C) 2000-2023 Vaadin Ltd
 *
 * This program is available under Vaadin Commercial License and Service Terms.
 *
 * See  for the full
 * license.
 */
package com.vaadin.v7.shared.ui.datefield;

import java.util.ArrayList;
import java.util.List;

import com.vaadin.shared.ui.datefield.DateResolution;
import com.vaadin.shared.ui.datefield.DateTimeResolution;

/**
 * Resolutions for DateFields.
 *
 * @author Vaadin Ltd.
 * @since 7.0
 *
 * @deprecated As of 8.0, replaced by {@link DateResolution} and
 *             {@link DateTimeResolution}, used by new
 *             {@code com.vaadin.ui.DateField} and
 *             {@code com.vaadin.ui.DateTimeField}
 */
public enum Resolution {
    // Values from Calendar.SECOND etc. Set as ints to avoid Calendar dependency
    // (does not exist on the client side)
    SECOND(13), MINUTE(12), HOUR(11), DAY(5), MONTH(2), YEAR(1);

    private int calendarField;

    private Resolution(int calendarField) {
        this.calendarField = calendarField;
    }

    /**
     * Returns the field in java.util.Calendar that corresponds to this
     * resolution.
     *
     * @return one of the field numbers used by Calendar
     */
    public int getCalendarField() {
        return calendarField;
    }

    /**
     * Returns the resolutions that are higher or equal to the given resolution,
     * starting from the given resolution. In other words passing DAY to this
     * methods returns DAY,MONTH,YEAR
     *
     * @param r
     *            The resolution to start from
     * @return An iterable for the resolutions higher or equal to r
     */
    public static Iterable getResolutionsHigherOrEqualTo(
            Resolution r) {
        List resolutions = new ArrayList();
        Resolution[] values = Resolution.values();
        for (int i = r.ordinal(); i < values.length; i++) {
            resolutions.add(values[i]);
        }
        return resolutions;
    }

    /**
     * Returns the resolutions that are lower than the given resolution,
     * starting from the given resolution. In other words passing DAY to this
     * methods returns HOUR,MINUTE,SECOND.
     *
     * @param r
     *            The resolution to start from
     * @return An iterable for the resolutions lower than r
     */
    public static List getResolutionsLowerThan(Resolution r) {
        List resolutions = new ArrayList();
        Resolution[] values = Resolution.values();
        for (int i = r.ordinal() - 1; i >= 0; i--) {
            resolutions.add(values[i]);
        }
        return resolutions;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy