More mapping from string to daycount convention.
@@ -41,29 +41,38 @@ public class DayCountConventionFactory implements Serializable {
* @param convention A convention string.
* @return A day count convention object.
*/
- public static DayCountConvention getDayCountConvention(final String convention) {
- if(convention.compareToIgnoreCase("act/act isda") == 0) {
- return new DayCountConvention_ACT_ACT_ISDA();
+ public static DayCountConvention getDayCountConvention(String convention) {
+ if(convention == null) {
+ throw new IllegalArgumentException();
}
- else if(convention.compareToIgnoreCase("30/360") == 0) {
+
+ convention = convention.replace('.', ' ').toLowerCase();
+
+ switch(convention) {
+ case "30e/360 isda":
+ case "e30/360 isda":
+ case "30/360":
return new DayCountConvention_30E_360_ISDA();
- }
- else if(convention.compareToIgnoreCase("30e/360") == 0) {
+ case "30e/360":
+ case "e30/360":
return new DayCountConvention_30E_360();
- }
- else if(convention.compareToIgnoreCase("30u/360") == 0) {
+ case "30u/360":
+ case "u30/360":
return new DayCountConvention_30U_360();
- }
- else if(convention.compareToIgnoreCase("act/360") == 0) {
+ case "act/360":
return new DayCountConvention_ACT_360();
- }
- else if(convention.compareToIgnoreCase("act/365") == 0) {
+ case "act/365":
+ case "act/365 fixed":
return new DayCountConvention_ACT_365();
- }
- else if(convention.compareToIgnoreCase("act/act yearfrac") == 0) {
+ case "act/act":
+ case "act/act isda":
+ return new DayCountConvention_ACT_ACT_ISDA();
+ case "act/act yearfrac":
return new DayCountConvention_ACT_ACT_YEARFRAC();
+ case "act/act afb":
+ return new DayCountConvention_ACT_ACT_AFB();
+ default:
}
-
throw new IllegalArgumentException("Unknow day count convention: " + convention);
}
