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

net.time4j.engine.BasicUnit Maven / Gradle / Ivy

There is a newer version: 4.38
Show newest version
/*
 * -----------------------------------------------------------------------
 * Copyright © 2013-2016 Meno Hochschild, 
 * -----------------------------------------------------------------------
 * This file (BasicUnit.java) is part of project Time4J.
 *
 * Time4J is free software: You can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published
 * by the Free Software Foundation, either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * Time4J is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with Time4J. If not, see .
 * -----------------------------------------------------------------------
 */

package net.time4j.engine;


/**
 * 

Abstract time unit class which can define its own rule.

* * @see TimePoint#plus(long, Object) TimePoint.plus(long, U) * @see TimePoint#minus(long, Object) TimePoint.minus(long, U) * @see TimePoint#until(TimePoint, Object) TimePoint.until(T, U) */ /*[deutsch] *

Abstrakte Zeiteinheitsklasse, die ihre eigene Regel definieren kann.

* * @see TimePoint#plus(long, Object) TimePoint.plus(long, U) * @see TimePoint#minus(long, Object) TimePoint.minus(long, U) * @see TimePoint#until(TimePoint, Object) TimePoint.until(T, U) */ public abstract class BasicUnit implements ChronoUnit { //~ Konstruktoren ----------------------------------------------------- /** *

Subclasses usually define a singleton and have no public * constructors.

*/ /*[deutsch] *

Subklassen werden normalerweise ein Singleton definieren und * keine öffentlichen Konstruktoren anbieten.

*/ protected BasicUnit() { super(); } //~ Methoden ---------------------------------------------------------- /** *

Derives an optional unit rule for given chronology.

* *

This implementation yields {@code null} so that a chronology * must register this unit. Specialized subclasses can define a rule * however if the chronology has not registered this unit.

* * @param generic type of time context * @param chronology chronology an unit rule is searched for * @return unit rule or {@code null} if given chronology is * not supported */ /*[deutsch] *

Leitet eine optionale Einheitsregel für die angegebene * Chronologie ab.

* *

Diese Implementierung liefert {@code null}, so daß eine * gegebene Chronologie diese Einheit registrieren muß. * Spezialisierte Subklassen können jedoch eine Regel definieren, * wenn eine Chronologie diese Einheit nicht registriert hat.

* * @param generic type of time context * @param chronology chronology an unit rule is searched for * @return unit rule or {@code null} if given chronology is * not supported */ protected > UnitRule derive( Chronology chronology ) { return null; } /** *

Derives an optional unit rule for given entity.

* * @param generic type of time context * @param entity the entity referencing a chronology * @return unit rule or {@code null} if the underlying chronology is not supported * @since 3.21/4.17 */ /*[deutsch] *

Leitet eine optionale Einheitsregel für die angegebene Entität ab.

* * @param generic type of time context * @param entity the entity referencing a chronology * @return unit rule or {@code null} if the underlying chronology is not supported * @since 3.21/4.17 */ protected final > UnitRule derive(T entity) { return this.derive(entity.getChronology()); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy