public override Builder set(string propertyName, object newValue) { switch (propertyName.GetHashCode()) { case 3575610: // type this.type = (EtdExpiryType)newValue; break; case 1792248507: // dateCode this.dateCode = (int?)newValue; break; case -295448573: // settlementType this.settlementType = (EtdSettlementType)newValue; break; case 1373587791: // optionType this.optionType = (EtdOptionType)newValue; break; default: throw new NoSuchElementException("Unknown property: " + propertyName); } return(this); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @ImmutableConstructor private EtdVariant(EtdExpiryType type, System.Nullable<int> dateCode, EtdSettlementType settlementType, EtdOptionType optionType) private EtdVariant(EtdExpiryType type, int?dateCode, EtdSettlementType settlementType, EtdOptionType optionType) { this.type = ArgChecker.notNull(type, "type"); this.dateCode = dateCode; this.settlementType = settlementType; this.optionType = optionType; if (type == EtdExpiryType.MONTHLY) { ArgChecker.isTrue(dateCode == null, "Monthly variant must have no dateCode"); ArgChecker.isTrue(settlementType == null, "Monthly variant must have no settlementType"); ArgChecker.isTrue(optionType == null, "Monthly variant must have no optionType"); this.code = ""; } else if (type == EtdExpiryType.WEEKLY) { ArgChecker.notNull(dateCode, "dateCode"); ArgChecker.isTrue(dateCode >= 1 && dateCode <= 5, "Week must be from 1 to 5"); ArgChecker.isTrue(settlementType == null, "Weekly variant must have no settlementType"); ArgChecker.isTrue(optionType == null, "Weekly variant must have no optionType"); this.code = "W" + dateCode; } else { // DAILY and Flex ArgChecker.notNull(dateCode, "dateCode"); ArgChecker.isTrue(dateCode >= 1 && dateCode <= 31, "Day-of-week must be from 1 to 31"); ArgChecker.isFalse(settlementType == null && optionType != null, "Flex Option must have both settlementType and optionType"); string dateCodeStr = dateCode < 10 ? "0" + dateCode : Convert.ToString(dateCode); string settlementCode = settlementType != null ? settlementType.Code : ""; string optionCode = optionType != null ? optionType.Code : ""; this.code = dateCodeStr + settlementCode + optionCode; } }
public virtual void test_of_lookup_null() { assertThrows(() => EtdOptionType.of(null), typeof(System.ArgumentException)); }
public virtual void test_of_lookup_notFound() { assertThrows(() => EtdOptionType.of("Rubbish"), typeof(System.ArgumentException)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test(dataProvider = "name") public void test_of_lookup(EtdOptionType convention, String name) public virtual void test_of_lookup(EtdOptionType convention, string name) { assertEquals(EtdOptionType.of(name), convention); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test(dataProvider = "name") public void test_toString(EtdOptionType convention, String name) public virtual void test_toString(EtdOptionType convention, string name) { assertEquals(convention.ToString(), name); }
/// <summary> /// The standard monthly ETD. /// </summary> /// <param name="dayOfMonth"> the day-of-month </param> /// <param name="settlementType"> the settlement type </param> /// <param name="optionType"> the option type </param> /// <returns> the variant </returns> public static EtdVariant ofFlexOption(int dayOfMonth, EtdSettlementType settlementType, EtdOptionType optionType) { return(new EtdVariant(EtdExpiryType.DAILY, dayOfMonth, settlementType, optionType)); }