Example #1
0
            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);
            }
Example #2
0
//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(() => EtdExpiryType.of(null), typeof(System.ArgumentException));
 }
 public virtual void test_of_lookup_notFound()
 {
     assertThrows(() => EtdExpiryType.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(EtdExpiryType convention, String name)
        public virtual void test_of_lookup(EtdExpiryType convention, string name)
        {
            assertEquals(EtdExpiryType.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(EtdExpiryType convention, String name)
        public virtual void test_toString(EtdExpiryType convention, string name)
        {
            assertEquals(convention.ToString(), name);
        }