test/java/time/tck/java/time/chrono/CopticEra.java

Print this page

        

@@ -51,27 +51,15 @@
  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-package tck.java.time.calendar;
+package tck.java.time.chrono;
 
-import static java.time.temporal.ChronoField.ERA;
-
-import java.util.Locale;
 
 import java.time.DateTimeException;
-import java.time.temporal.ChronoField;
-import java.time.temporal.Queries;
-import java.time.temporal.Temporal;
-import java.time.temporal.TemporalField;
-import java.time.temporal.TemporalQuery;
-import java.time.temporal.ValueRange;
-import java.time.temporal.ChronoLocalDate;
-import java.time.temporal.Era;
-import java.time.format.DateTimeFormatterBuilder;
-import java.time.format.TextStyle;
+import java.time.chrono.Era;
 
 /**
  * An era in the Coptic calendar system.
  * <p>
  * The Coptic calendar system uses the 'Era of the Martyrs'.

@@ -81,11 +69,11 @@
  * Use {@code getValue()} instead.</b>
  *
  * <h4>Implementation notes</h4>
  * This is an immutable and thread-safe enum.
  */
-enum CopticEra implements Era<CopticChrono> {
+enum CopticEra implements Era {
 
     /**
      * The singleton instance for the era BEFORE_AM, 'Before Era of the Martyrs'.
      * This has the numeric value of {@code 0}.
      */

@@ -129,82 +117,22 @@
     public int getValue() {
         return ordinal();
     }
 
     @Override
-    public CopticChrono getChrono() {
-        return CopticChrono.INSTANCE;
+    public CopticChronology getChronology() {
+        return CopticChronology.INSTANCE;
     }
 
     // JDK8 default methods:
     //-----------------------------------------------------------------------
     @Override
-    public ChronoLocalDate<CopticChrono> date(int year, int month, int day) {
-        return getChrono().date(this, year, month, day);
-    }
-
-    @Override
-    public ChronoLocalDate<CopticChrono> dateYearDay(int year, int dayOfYear) {
-        return getChrono().dateYearDay(this, year, dayOfYear);
+    public CopticDate date(int year, int month, int day) {
+        return (CopticDate)(getChronology().date(this, year, month, day));
     }
 
-    //-----------------------------------------------------------------------
-    @Override
-    public boolean isSupported(TemporalField field) {
-        if (field instanceof ChronoField) {
-            return field == ERA;
-        }
-        return field != null && field.doIsSupported(this);
-    }
-
-    @Override
-    public ValueRange range(TemporalField field) {
-        if (field == ERA) {
-            return field.range();
-        } else if (field instanceof ChronoField) {
-            throw new DateTimeException("Unsupported field: " + field.getName());
-        }
-        return field.doRange(this);
-    }
-
-    @Override
-    public int get(TemporalField field) {
-        if (field == ERA) {
-            return getValue();
-        }
-        return range(field).checkValidIntValue(getLong(field), field);
-    }
-
-    @Override
-    public long getLong(TemporalField field) {
-        if (field == ERA) {
-            return getValue();
-        } else if (field instanceof ChronoField) {
-            throw new DateTimeException("Unsupported field: " + field.getName());
-        }
-        return field.doGet(this);
-    }
-
-    //-------------------------------------------------------------------------
-    @Override
-    public Temporal adjustInto(Temporal dateTime) {
-        return dateTime.with(ERA, getValue());
-    }
-
-    @SuppressWarnings("unchecked")
-    @Override
-    public <R> R query(TemporalQuery<R> query) {
-        if (query == Queries.zoneId()) {
-            return null;
-        } else if (query == Queries.chrono()) {
-            return (R) getChrono();
-        }
-        return query.queryFrom(this);
-    }
-
-    //-----------------------------------------------------------------------
     @Override
-    public String getText(TextStyle style, Locale locale) {
-        return new DateTimeFormatterBuilder().appendText(ERA, style).toFormatter(locale).print(this);
+    public CopticDate dateYearDay(int year, int dayOfYear) {
+        return (CopticDate)(getChronology().dateYearDay(this, year, dayOfYear));
     }
 
 }