Skip to content
This repository has been archived by the owner on Mar 20, 2018. It is now read-only.

Commit

Permalink
Rename CalendricalRule.getReifiedType() to getType()
Browse files Browse the repository at this point in the history
git-svn-id: https://threeten.svn.sourceforge.net/svnroot/threeten/trunk/threeten@1473 291d795c-afe8-5c46-8ee5-bf9dd72e1864
  • Loading branch information
jodastephen committed May 28, 2011
1 parent 8b50a63 commit 6bc1a86
Show file tree
Hide file tree
Showing 29 changed files with 68 additions and 67 deletions.
1 change: 1 addition & 0 deletions RELEASE-NOTES.txt
Expand Up @@ -79,6 +79,7 @@
- Add ofInstantUTC factories to ZDT, ODT, OD, OT
- Remove Comparable, PeriodUnit, PeriodRange, ID and Chronology from CalendricalRule
- Remove isXxx() methods from enums
- Rename CalendricalRule.getReifiedType() to getType()

0.6.3
===============================================================================
Expand Down
12 changes: 6 additions & 6 deletions src-oracle/test/java/javax/time/i18n/TestHijrahChronology.java
Expand Up @@ -64,7 +64,7 @@ public void testImmutable() throws Exception {
@Test
public void testEra() throws Exception {
DateTimeRule rule = HijrahChronology.eraRule();
assertEquals(rule.getReifiedType(), DateTimeField.class);
assertEquals(rule.getType(), DateTimeField.class);
assertEquals(rule.getName(), "HijrahEra");
assertEquals(rule.getRange(), DateTimeRuleRange.of(0, 1));
assertEquals(rule.getPeriodUnit(), HijrahChronology.periodEras());
Expand All @@ -75,7 +75,7 @@ public void testEra() throws Exception {
@Test
public void testYearOfEra() throws Exception {
DateTimeRule rule = HijrahChronology.yearOfEraRule();
assertEquals(rule.getReifiedType(), DateTimeField.class);
assertEquals(rule.getType(), DateTimeField.class);
assertEquals(rule.getName(), "HijrahYearOfEra");
assertEquals(rule.getRange(), DateTimeRuleRange.of(HijrahDate.MIN_YEAR_OF_ERA, HijrahDate.MAX_YEAR_OF_ERA));
assertEquals(rule.getPeriodUnit(), HijrahChronology.periodYears());
Expand All @@ -86,7 +86,7 @@ public void testYearOfEra() throws Exception {
@Test
public void testMonthOfYear() throws Exception {
DateTimeRule rule = HijrahChronology.monthOfYearRule();
assertEquals(rule.getReifiedType(), DateTimeField.class);
assertEquals(rule.getType(), DateTimeField.class);
assertEquals(rule.getName(), "HijrahMonthOfYear");
assertEquals(rule.getRange(), DateTimeRuleRange.of(1, 12));
assertEquals(rule.getPeriodUnit(), HijrahChronology.periodMonths());
Expand All @@ -96,7 +96,7 @@ public void testMonthOfYear() throws Exception {
@Test
public void testDayOfMonth() throws Exception {
DateTimeRule rule = HijrahChronology.dayOfMonthRule();
assertEquals(rule.getReifiedType(), DateTimeField.class);
assertEquals(rule.getType(), DateTimeField.class);
assertEquals(rule.getName(), "HijrahDayOfMonth");
assertEquals(rule.getRange(), DateTimeRuleRange.of(1, 29, 30));
assertEquals(rule.getPeriodUnit(), HijrahChronology.periodDays());
Expand All @@ -107,7 +107,7 @@ public void testDayOfMonth() throws Exception {
@Test
public void testDayOfYear() throws Exception {
DateTimeRule rule = HijrahChronology.dayOfYearRule();
assertEquals(rule.getReifiedType(), DateTimeField.class);
assertEquals(rule.getType(), DateTimeField.class);
assertEquals(rule.getName(), "HijrahDayOfYear");
assertEquals(rule.getRange(), DateTimeRuleRange.of(1, 354, 355));
assertEquals(rule.getPeriodUnit(), HijrahChronology.periodDays());
Expand All @@ -119,7 +119,7 @@ public void testDayOfYear() throws Exception {
@Test
public void testDayOfWeek() throws Exception {
DateTimeRule rule = HijrahChronology.dayOfWeekRule();
assertEquals(rule.getReifiedType(), DateTimeField.class);
assertEquals(rule.getType(), DateTimeField.class);
assertEquals(rule.getName(), "HijrahDayOfWeek");
assertEquals(rule.getRange(), DateTimeRuleRange.of(1, 7));
assertEquals(rule.getPeriodUnit(), HijrahChronology.periodDays());
Expand Down
12 changes: 6 additions & 6 deletions src-oracle/test/java/javax/time/i18n/TestJapaneseChronology.java
Expand Up @@ -64,7 +64,7 @@ public void testImmutable() throws Exception {
@Test
public void testEra() throws Exception {
DateTimeRule rule = JapaneseChronology.eraRule();
assertEquals(rule.getReifiedType(), DateTimeField.class);
assertEquals(rule.getType(), DateTimeField.class);
assertEquals(rule.getName(), "JapaneseEra");
assertEquals(rule.getRange(), DateTimeRuleRange.of(-3, 2));
assertEquals(rule.getPeriodUnit(), JapaneseChronology.periodEras());
Expand All @@ -75,7 +75,7 @@ public void testEra() throws Exception {
@Test
public void testYearOfEra() throws Exception {
DateTimeRule rule = JapaneseChronology.yearOfEraRule();
assertEquals(rule.getReifiedType(), DateTimeField.class);
assertEquals(rule.getType(), DateTimeField.class);
assertEquals(rule.getName(), "JapaneseYearOfEra");
assertEquals(rule.getRange(), DateTimeRuleRange.of(JapaneseDate.MIN_YEAR_OF_ERA, JapaneseDate.MAX_YEAR_OF_ERA));
assertEquals(rule.getPeriodUnit(), JapaneseChronology.periodYears());
Expand All @@ -86,7 +86,7 @@ public void testYearOfEra() throws Exception {
@Test
public void testMonthOfYear() throws Exception {
DateTimeRule rule = JapaneseChronology.monthOfYearRule();
assertEquals(rule.getReifiedType(), DateTimeField.class);
assertEquals(rule.getType(), DateTimeField.class);
assertEquals(rule.getName(), "JapaneseMonthOfYear");
assertEquals(rule.getRange(), DateTimeRuleRange.of(1, 12));
assertEquals(rule.getPeriodUnit(), JapaneseChronology.periodMonths());
Expand All @@ -96,7 +96,7 @@ public void testMonthOfYear() throws Exception {
@Test
public void testDayOfMonth() throws Exception {
DateTimeRule rule = JapaneseChronology.dayOfMonthRule();
assertEquals(rule.getReifiedType(), DateTimeField.class);
assertEquals(rule.getType(), DateTimeField.class);
assertEquals(rule.getName(), "JapaneseDayOfMonth");
assertEquals(rule.getRange(), DateTimeRuleRange.of(1, 28, 31));
assertEquals(rule.getPeriodUnit(), JapaneseChronology.periodDays());
Expand All @@ -107,7 +107,7 @@ public void testDayOfMonth() throws Exception {
@Test
public void testDayOfYear() throws Exception {
DateTimeRule rule = JapaneseChronology.dayOfYearRule();
assertEquals(rule.getReifiedType(), DateTimeField.class);
assertEquals(rule.getType(), DateTimeField.class);
assertEquals(rule.getName(), "JapaneseDayOfYear");
assertEquals(rule.getRange(), DateTimeRuleRange.of(1, 365, 366));
assertEquals(rule.getPeriodUnit(), JapaneseChronology.periodDays());
Expand All @@ -119,7 +119,7 @@ public void testDayOfYear() throws Exception {
@Test
public void testDayOfWeek() throws Exception {
DateTimeRule rule = JapaneseChronology.dayOfWeekRule();
assertEquals(rule.getReifiedType(), DateTimeField.class);
assertEquals(rule.getType(), DateTimeField.class);
assertEquals(rule.getName(), "JapaneseDayOfWeek");
assertEquals(rule.getRange(), DateTimeRuleRange.of(1, 7));
assertEquals(rule.getPeriodUnit(), JapaneseChronology.periodDays());
Expand Down
12 changes: 6 additions & 6 deletions src-oracle/test/java/javax/time/i18n/TestMinguoChronology.java
Expand Up @@ -64,7 +64,7 @@ public void testImmutable() throws Exception {
@Test
public void testEra() throws Exception {
DateTimeRule rule = MinguoChronology.eraRule();
assertEquals(rule.getReifiedType(), DateTimeField.class);
assertEquals(rule.getType(), DateTimeField.class);
assertEquals(rule.getName(), "MinguoEra");
assertEquals(rule.getRange(), DateTimeRuleRange.of(0, 1));
assertEquals(rule.getPeriodUnit(), MinguoChronology.periodEras());
Expand All @@ -75,7 +75,7 @@ public void testEra() throws Exception {
@Test
public void testYearOfEra() throws Exception {
DateTimeRule rule = MinguoChronology.yearOfEraRule();
assertEquals(rule.getReifiedType(), DateTimeField.class);
assertEquals(rule.getType(), DateTimeField.class);
assertEquals(rule.getName(), "MinguoYearOfEra");
assertEquals(rule.getRange(), DateTimeRuleRange.of(MinguoDate.MIN_YEAR_OF_ERA, MinguoDate.MAX_YEAR_OF_ERA));
assertEquals(rule.getPeriodUnit(), MinguoChronology.periodYears());
Expand All @@ -86,7 +86,7 @@ public void testYearOfEra() throws Exception {
@Test
public void testMonthOfYear() throws Exception {
DateTimeRule rule = MinguoChronology.monthOfYearRule();
assertEquals(rule.getReifiedType(), DateTimeField.class);
assertEquals(rule.getType(), DateTimeField.class);
assertEquals(rule.getName(), "MinguoMonthOfYear");
assertEquals(rule.getRange(), DateTimeRuleRange.of(1, 12));
assertEquals(rule.getPeriodUnit(), MinguoChronology.periodMonths());
Expand All @@ -96,7 +96,7 @@ public void testMonthOfYear() throws Exception {
@Test
public void testDayOfMonth() throws Exception {
DateTimeRule rule = MinguoChronology.dayOfMonthRule();
assertEquals(rule.getReifiedType(), DateTimeField.class);
assertEquals(rule.getType(), DateTimeField.class);
assertEquals(rule.getName(), "MinguoDayOfMonth");
assertEquals(rule.getRange(), DateTimeRuleRange.of(1, 28, 31));
assertEquals(rule.getPeriodUnit(), MinguoChronology.periodDays());
Expand All @@ -107,7 +107,7 @@ public void testDayOfMonth() throws Exception {
@Test
public void testDayOfYear() throws Exception {
DateTimeRule rule = MinguoChronology.dayOfYearRule();
assertEquals(rule.getReifiedType(), DateTimeField.class);
assertEquals(rule.getType(), DateTimeField.class);
assertEquals(rule.getName(), "MinguoDayOfYear");
assertEquals(rule.getRange(), DateTimeRuleRange.of(1, 365, 366));
assertEquals(rule.getPeriodUnit(), MinguoChronology.periodDays());
Expand All @@ -119,7 +119,7 @@ public void testDayOfYear() throws Exception {
@Test
public void testDayOfWeek() throws Exception {
DateTimeRule rule = MinguoChronology.dayOfWeekRule();
assertEquals(rule.getReifiedType(), DateTimeField.class);
assertEquals(rule.getType(), DateTimeField.class);
assertEquals(rule.getName(), "MinguoDayOfWeek");
assertEquals(rule.getRange(), DateTimeRuleRange.of(1, 7));
assertEquals(rule.getPeriodUnit(), MinguoChronology.periodDays());
Expand Down
Expand Up @@ -64,7 +64,7 @@ public void testImmutable() throws Exception {
@Test
public void testEra() throws Exception {
DateTimeRule rule = ThaiBuddhistChronology.eraRule();
assertEquals(rule.getReifiedType(), DateTimeField.class);
assertEquals(rule.getType(), DateTimeField.class);
assertEquals(rule.getName(), "ThaiBuddhistEra");
assertEquals(rule.getRange(), DateTimeRuleRange.of(0, 1));
assertEquals(rule.getPeriodUnit(), ThaiBuddhistChronology.periodEras());
Expand All @@ -75,7 +75,7 @@ public void testEra() throws Exception {
@Test
public void testYearOfEra() throws Exception {
DateTimeRule rule = ThaiBuddhistChronology.yearOfEraRule();
assertEquals(rule.getReifiedType(), DateTimeField.class);
assertEquals(rule.getType(), DateTimeField.class);
assertEquals(rule.getName(), "ThaiBuddhistYearOfEra");
assertEquals(rule.getRange(), DateTimeRuleRange.of(ThaiBuddhistDate.MIN_YEAR_OF_ERA, ThaiBuddhistDate.MAX_YEAR_OF_ERA));
assertEquals(rule.getPeriodUnit(), ThaiBuddhistChronology.periodYears());
Expand All @@ -86,7 +86,7 @@ public void testYearOfEra() throws Exception {
@Test
public void testMonthOfYear() throws Exception {
DateTimeRule rule = ThaiBuddhistChronology.monthOfYearRule();
assertEquals(rule.getReifiedType(), DateTimeField.class);
assertEquals(rule.getType(), DateTimeField.class);
assertEquals(rule.getName(), "ThaiBuddhistMonthOfYear");
assertEquals(rule.getRange(), DateTimeRuleRange.of(1, 12));
assertEquals(rule.getPeriodUnit(), ThaiBuddhistChronology.periodMonths());
Expand All @@ -96,7 +96,7 @@ public void testMonthOfYear() throws Exception {
@Test
public void testDayOfMonth() throws Exception {
DateTimeRule rule = ThaiBuddhistChronology.dayOfMonthRule();
assertEquals(rule.getReifiedType(), DateTimeField.class);
assertEquals(rule.getType(), DateTimeField.class);
assertEquals(rule.getName(), "ThaiBuddhistDayOfMonth");
assertEquals(rule.getRange(), DateTimeRuleRange.of(1, 28, 31));
assertEquals(rule.getPeriodUnit(), ThaiBuddhistChronology.periodDays());
Expand All @@ -107,7 +107,7 @@ public void testDayOfMonth() throws Exception {
@Test
public void testDayOfYear() throws Exception {
DateTimeRule rule = ThaiBuddhistChronology.dayOfYearRule();
assertEquals(rule.getReifiedType(), DateTimeField.class);
assertEquals(rule.getType(), DateTimeField.class);
assertEquals(rule.getName(), "ThaiBuddhistDayOfYear");
assertEquals(rule.getRange(), DateTimeRuleRange.of(1, 365, 366));
assertEquals(rule.getPeriodUnit(), ThaiBuddhistChronology.periodDays());
Expand All @@ -119,7 +119,7 @@ public void testDayOfYear() throws Exception {
@Test
public void testDayOfWeek() throws Exception {
DateTimeRule rule = ThaiBuddhistChronology.dayOfWeekRule();
assertEquals(rule.getReifiedType(), DateTimeField.class);
assertEquals(rule.getType(), DateTimeField.class);
assertEquals(rule.getName(), "ThaiBuddhistDayOfWeek");
assertEquals(rule.getRange(), DateTimeRuleRange.of(1, 7));
assertEquals(rule.getPeriodUnit(), ThaiBuddhistChronology.periodDays());
Expand Down
18 changes: 9 additions & 9 deletions src/main/java/javax/time/calendar/CalendricalRule.java
Expand Up @@ -44,7 +44,7 @@
* <p>
* Each rule uses an underlying type to represent the data.
* This is captured in the generic type of the rule.
* The underlying type is reified and made available via {@link #getReifiedType()}.
* The underlying type is reified and made available via {@link #getType()}.
* It is expected, but not enforced, that the underlying type is {@link Comparable}.
* <p>
* CalendricalRule is an abstract class and must be implemented with care to
Expand All @@ -65,7 +65,7 @@ public abstract class CalendricalRule<T>
private static final long serialVersionUID = 1L;

/** The reified class for the generic type. */
private final Class<T> reified;
private final Class<T> type;
/** The name of the rule, not null. */
private final String name;

Expand All @@ -85,7 +85,7 @@ protected CalendricalRule(
if (name == null) {
throw new NullPointerException("Name must not be null");
}
this.reified = type;
this.type = type;
this.name = name;
}

Expand All @@ -106,7 +106,7 @@ public final String getName() {

//-----------------------------------------------------------------------
/**
* Gets the reified class representing the underlying type of the rule.
* Gets the type of the rule, which is a reification of the generic type.
* <p>
* Each rule uses an underlying type to represent the data.
* This is captured in the generic type of the rule.
Expand All @@ -116,8 +116,8 @@ public final String getName() {
*
* @return the reified type of values of the rule, not null
*/
public final Class<T> getReifiedType() {
return reified;
public final Class<T> getType() {
return type;
}

/**
Expand All @@ -139,10 +139,10 @@ public final T reify(Object value) {
if (value == null) {
return null;
}
if (reified.isInstance(value)) {
if (type.isInstance(value)) {
return (T) value;
}
throw new ClassCastException("Value of type " + value.getClass().getName() + " cannot be cast to type " + reified.getName());
throw new ClassCastException("Value of type " + value.getClass().getName() + " cannot be cast to type " + type.getName());
}

//-----------------------------------------------------------------------
Expand Down Expand Up @@ -281,7 +281,7 @@ protected T derive(Calendrical calendrical) {
* @param value the value to interpret, not null
*/
final T interpretValue(CalendricalMerger merger, Object value) {
if (reified.isInstance(value)) {
if (type.isInstance(value)) {
return reify(value);
}
T result = interpret(merger, value);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/javax/time/i18n/HistoricEra.java
Expand Up @@ -120,7 +120,7 @@ public int getValue() {
* @return the value for the rule, null if the value cannot be returned
*/
public <T> T get(CalendricalRule<T> rule) {
if (rule.getReifiedType() != HistoricEra.class) {
if (rule.getType() != HistoricEra.class) {
return null;
}
return rule.reify(this);
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/javax/time/calendar/TestCalendricalRule.java
Expand Up @@ -87,10 +87,10 @@ public void test_serialization() throws IOException, ClassNotFoundException {
}

//-----------------------------------------------------------------------
// getReifiedType()
// getType()
//-----------------------------------------------------------------------
public void test_getReifiedType() {
assertEquals(new MockBigYearRule().getReifiedType(), BigInteger.class);
public void test_getType() {
assertEquals(new MockBigYearRule().getType(), BigInteger.class);
}

//-----------------------------------------------------------------------
Expand Down
Expand Up @@ -57,7 +57,7 @@ protected DateTimeRule rule() {
//-----------------------------------------------------------------------
public void test_basics() throws Exception {
DateTimeRule rule = ISODateTimeRule.AMPM_OF_DAY;
assertEquals(rule.getReifiedType(), DateTimeField.class);
assertEquals(rule.getType(), DateTimeField.class);
assertEquals(rule.getName(), "AmPmOfDay");
assertEquals(rule.getRange(), DateTimeRuleRange.of(0, 1));
assertEquals(rule.getPeriodUnit(), ISOPeriodUnit._12_HOURS);
Expand Down

0 comments on commit 6bc1a86

Please sign in to comment.