-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
code improvements #230
code improvements #230
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -116,13 +116,13 @@ public class HebrewDateFormatter { | |
* שובה,שירה,הגדול, | ||
* חזון,נחמו"</code> | ||
*/ | ||
private EnumMap<JewishCalendar.Parsha, String> hebrewParshaMap; | ||
private final EnumMap<JewishCalendar.Parsha, String> hebrewParshaMap; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this variable can be final as it is setup in the constructor |
||
|
||
/** | ||
* Default constructor sets the {@link EnumMap}s of Hebrew and default transliterated parshiyos. | ||
*/ | ||
public HebrewDateFormatter() { | ||
transliteratedParshaMap = new EnumMap<JewishCalendar.Parsha, String>(JewishCalendar.Parsha.class); | ||
transliteratedParshaMap = new EnumMap<>(JewishCalendar.Parsha.class); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As of Java 7, the diamond operator <> does not need explicit types. See here: https://stackoverflow.com/a/5999744 |
||
transliteratedParshaMap.put(JewishCalendar.Parsha.NONE, ""); | ||
transliteratedParshaMap.put(JewishCalendar.Parsha.BERESHIS, "Bereshis"); | ||
transliteratedParshaMap.put(JewishCalendar.Parsha.NOACH, "Noach"); | ||
|
@@ -195,7 +195,7 @@ public HebrewDateFormatter() { | |
transliteratedParshaMap.put(JewishCalendar.Parsha.CHAZON, "Chazon"); | ||
transliteratedParshaMap.put(JewishCalendar.Parsha.NACHAMU, "Nachamu"); | ||
|
||
hebrewParshaMap = new EnumMap<JewishCalendar.Parsha, String>(JewishCalendar.Parsha.class); | ||
hebrewParshaMap = new EnumMap<>(JewishCalendar.Parsha.class); | ||
hebrewParshaMap.put(JewishCalendar.Parsha.NONE, ""); | ||
hebrewParshaMap.put(JewishCalendar.Parsha.BERESHIS, "\u05D1\u05E8\u05D0\u05E9\u05D9\u05EA"); | ||
hebrewParshaMap.put(JewishCalendar.Parsha.NOACH, "\u05E0\u05D7"); | ||
|
@@ -292,7 +292,7 @@ public boolean isLongWeekFormat() { | |
*/ | ||
public void setLongWeekFormat(boolean longWeekFormat) { | ||
this.longWeekFormat = longWeekFormat; | ||
if(longWeekFormat) { | ||
if (longWeekFormat) { | ||
weekFormat = new SimpleDateFormat("EEEE"); | ||
} else { | ||
weekFormat = new SimpleDateFormat("EEE"); | ||
|
@@ -496,7 +496,7 @@ public String formatRoshChodesh(JewishCalendar jewishCalendar) { | |
if (!jewishCalendar.isRoshChodesh()) { | ||
return ""; | ||
} | ||
String formattedRoshChodesh = ""; | ||
|
||
int month = jewishCalendar.getJewishMonth(); | ||
if (jewishCalendar.getJewishDayOfMonth() == 30) { | ||
if (month < JewishCalendar.ADAR || (month == JewishCalendar.ADAR && jewishCalendar.isJewishLeapYear())) { | ||
|
@@ -509,7 +509,7 @@ public String formatRoshChodesh(JewishCalendar jewishCalendar) { | |
// This method is only about formatting, so we shouldn't make any changes to the params passed in... | ||
jewishCalendar = (JewishCalendar) jewishCalendar.clone(); | ||
jewishCalendar.setJewishMonth(month); | ||
formattedRoshChodesh = hebrewFormat ? hebrewHolidays[JewishCalendar.ROSH_CHODESH] | ||
String formattedRoshChodesh = hebrewFormat ? hebrewHolidays[JewishCalendar.ROSH_CHODESH] | ||
: transliteratedHolidays[JewishCalendar.ROSH_CHODESH]; | ||
formattedRoshChodesh += " " + formatMonth(jewishCalendar); | ||
return formattedRoshChodesh; | ||
|
@@ -637,18 +637,18 @@ public void setTransliteratedMonthList(String[] transliteratedMonths) { | |
*/ | ||
public String formatDayOfWeek(JewishDate jewishDate) { | ||
if (hebrewFormat) { | ||
if(isLongWeekFormat()) { | ||
if (isLongWeekFormat()) { | ||
return hebrewDaysOfWeek[jewishDate.getDayOfWeek() - 1]; | ||
} else { | ||
if(jewishDate.getDayOfWeek() == 7) { | ||
if (jewishDate.getDayOfWeek() == 7) { | ||
return formatHebrewNumber(300); | ||
} else { | ||
return formatHebrewNumber(jewishDate.getDayOfWeek()); | ||
} | ||
} | ||
} else { | ||
if(jewishDate.getDayOfWeek() == 7) { | ||
if(isLongWeekFormat()) { | ||
if (jewishDate.getDayOfWeek() == 7) { | ||
if (isLongWeekFormat()) { | ||
return getTransliteratedShabbosDayOfWeek(); | ||
} else { | ||
return getTransliteratedShabbosDayOfWeek().substring(0,3); | ||
|
@@ -897,7 +897,7 @@ public String formatDafYomiBavli(Daf daf) { | |
* @return the formatted daf. | ||
*/ | ||
public String formatDafYomiYerushalmi(Daf daf) { | ||
if(daf == null) { | ||
if (daf == null) { | ||
if (hebrewFormat) { | ||
return Daf.getYerushalmiMasechtos()[39]; | ||
} else { | ||
|
@@ -990,7 +990,7 @@ public String formatHebrewNumber(int number) { | |
int tens = number / 10; | ||
if (number % 10 == 0) { // if evenly divisable by 10 | ||
if (!singleDigitNumber) { | ||
if(isUseFinalFormLetters()) { | ||
if (isUseFinalFormLetters()) { | ||
sb.append(jTenEnds[tens]); // years like 5780 will end with a final form ף | ||
} else { | ||
sb.append(jTens[tens]); // years like 5780 will end with a regular פ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was just to get rid of a possible NullPointerException warning. I know it is not necessary, but it is still beneficial to get rid of a few warnings.