MCPcopy Create free account
hub / github.com/MenoData/Time4J / FieldRule

Class FieldRule

base/src/main/java/net/time4j/PlainTimestamp.java:1692–1859  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1690 }
1691
1692 private static class FieldRule<V>
1693 implements ElementRule<PlainTimestamp, V> {
1694
1695 //~ Instanzvariablen ----------------------------------------------
1696
1697 final ChronoElement<V> element;
1698
1699 //~ Konstruktoren -------------------------------------------------
1700
1701 private FieldRule(ChronoElement<V> element) {
1702 super();
1703
1704 this.element = element;
1705
1706 }
1707
1708 //~ Methoden ------------------------------------------------------
1709
1710 static <V> FieldRule<V> of(ChronoElement<V> element) {
1711
1712 return new FieldRule<>(element);
1713
1714 }
1715
1716 @Override
1717 public V getValue(PlainTimestamp context) {
1718
1719 if (this.element.isDateElement()) {
1720 return context.date.get(this.element);
1721 } else if (this.element.isTimeElement()) {
1722 return context.time.get(this.element);
1723 }
1724
1725 throw new ChronoException(
1726 "Missing rule for: " + this.element.name());
1727
1728 }
1729
1730 @Override
1731 public V getMinimum(PlainTimestamp context) {
1732
1733 if (this.element.isDateElement()) {
1734 return context.date.getMinimum(this.element);
1735 } else if (this.element.isTimeElement()) {
1736 return this.element.getDefaultMinimum();
1737 }
1738
1739 throw new ChronoException(
1740 "Missing rule for: " + this.element.name());
1741
1742 }
1743
1744 @Override
1745 public V getMaximum(PlainTimestamp context) {
1746
1747 if (this.element.isDateElement()) {
1748 return context.date.getMaximum(this.element);
1749 } else if (this.element.isTimeElement()) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected