net.time4j.format.RawValues Maven / Gradle / Ivy
/*
* -----------------------------------------------------------------------
* Copyright © 2013-2015 Meno Hochschild,
* -----------------------------------------------------------------------
* This file (RawValues.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.format;
import net.time4j.engine.ChronoDisplay;
import net.time4j.engine.ChronoElement;
import net.time4j.engine.ChronoException;
import net.time4j.tz.TZID;
/**
* Stores any kind of raw values as {@code ChronoDisplay}.
*
* @author Meno Hochschild
* @since 3.0
* @doctags.concurrency
*/
/*[deutsch]
* Speichert einen beliebigen Satz von chronologischen Rohwerten.
*
* @author Meno Hochschild
* @since 3.0
* @doctags.concurrency
*/
// TODO: Ab Java 8 aktiv => implements Consumer, Supplier
public class RawValues {
//~ Instanzvariablen --------------------------------------------------
private ChronoDisplay rawValues = new EmptyRawValues();
//~ Konstruktoren -----------------------------------------------------
/**
* Initially this instance has no defined raw values.
*/
/*[deutsch]
* Am Anfang hat diese Instanz keine definierten Rohwerte.
*/
public RawValues() {
super();
}
//~ Methoden ----------------------------------------------------------
/**
* Consumes given chronological raw values.
*
* @param rawValues raw chronological values
* @since 3.0
*/
/*[deutsch]
* Konsumiert die angegebenen Rohwerte.
*
* @param rawValues raw chronological values
* @since 3.0
*/
public void accept(ChronoDisplay rawValues) {
if (rawValues == null) {
throw new NullPointerException("Missing raw values.");
}
this.rawValues = rawValues;
}
/**
* Yields the chronological raw values.
*
* @return raw chronological values, never {@code null}
* @since 3.0
*/
/*[deutsch]
* Liefert die chronologischen Rohwerte.
*
* @return raw chronological values, never {@code null}
* @since 3.0
*/
public ChronoDisplay get() {
return this.rawValues;
}
//~ Innere Klassen ----------------------------------------------------
private static class EmptyRawValues
implements ChronoDisplay {
//~ Methoden ------------------------------------------------------
@Override
public boolean contains(ChronoElement> element) {
return false;
}
@Override
public V get(ChronoElement element) {
throw new ChronoException("Not supported:" + element.name());
}
@Override
public V getMinimum(ChronoElement element) {
throw new ChronoException("Not supported:" + element.name());
}
@Override
public V getMaximum(ChronoElement element) {
throw new ChronoException("Not supported:" + element.name());
}
@Override
public boolean hasTimezone() {
return false;
}
@Override
public TZID getTimezone() {
throw new ChronoException("Timezone does not exist.");
}
@Override
public String toString() {
return "raw-values={}";
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy