public virtual void test_resolve_invalid()
        {
            ValueStepSequence test     = ValueStepSequence.of(date(2016, 4, 20), date(2016, 10, 20), Frequency.P12M, ADJ);
            ValueStep         baseStep = ValueStep.of(date(2016, 1, 20), ValueAdjustment.ofReplace(500d));

            assertThrowsIllegalArg(() => test.resolve(ImmutableList.of(baseStep), RollConventions.NONE));
        }
        //-------------------------------------------------------------------------
        public virtual void test_resolveValues_sequence()
        {
            ValueStepSequence seq  = ValueStepSequence.of(date(2014, 2, 1), date(2014, 3, 1), Frequency.P1M, ValueAdjustment.ofDeltaAmount(100));
            ValueSchedule     test = ValueSchedule.of(200d, seq);

            assertEquals(test.resolveValues(SCHEDULE), DoubleArray.of(200d, 300d, 400d));
        }
 private ValueSchedule(double initialValue, IList <ValueStep> steps, ValueStepSequence stepSequence)
 {
     JodaBeanUtils.notNull(steps, "steps");
     this.initialValue = initialValue;
     this.steps        = ImmutableList.copyOf(steps);
     this.stepSequence = stepSequence;
 }
        public virtual void test_resolveValues_sequenceAndSteps()
        {
            ValueStepSequence seq   = ValueStepSequence.of(date(2014, 2, 1), date(2014, 3, 1), Frequency.P1M, ValueAdjustment.ofDeltaAmount(100));
            ValueStep         step1 = ValueStep.of(date(2014, 1, 1), ValueAdjustment.ofReplace(350d));
            ValueSchedule     test  = ValueSchedule.builder().initialValue(200d).steps(step1).stepSequence(seq).build();

            assertEquals(test.resolveValues(SCHEDULE), DoubleArray.of(350d, 450d, 550d));
        }
        public virtual void test_resolveValues_sequenceAndStepClash()
        {
            ValueStepSequence seq   = ValueStepSequence.of(date(2014, 2, 1), date(2014, 3, 1), Frequency.P1M, ValueAdjustment.ofDeltaAmount(100));
            ValueStep         step1 = ValueStep.of(date(2014, 2, 1), ValueAdjustment.ofReplace(350d));
            ValueSchedule     test  = ValueSchedule.builder().initialValue(200d).steps(step1).stepSequence(seq).build();

            assertThrowsIllegalArg(() => test.resolveValues(SCHEDULE));
        }
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            ValueStepSequence test = ValueStepSequence.of(date(2016, 4, 20), date(2016, 10, 20), Frequency.P3M, ADJ);

            coverImmutableBean(test);
            ValueStepSequence test2 = ValueStepSequence.of(date(2016, 4, 1), date(2016, 10, 1), Frequency.P1M, ADJ2);

            coverImmutableBean(test2);
        }
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            ValueStepSequence seq = ValueStepSequence.of(date(2014, 2, 1), date(2014, 3, 1), Frequency.P1M, ValueAdjustment.ofDeltaAmount(100));

            ValueSchedule test = ValueSchedule.of(10000d, Lists.newArrayList(STEP1, STEP2));

            coverImmutableBean(test);
            coverBeanEquals(test, ValueSchedule.of(20000d, seq));
        }
        //-------------------------------------------------------------------------
        public virtual void test_of()
        {
            ValueStepSequence test = ValueStepSequence.of(date(2016, 4, 20), date(2016, 10, 20), Frequency.P3M, ADJ);

            assertEquals(test.FirstStepDate, date(2016, 4, 20));
            assertEquals(test.LastStepDate, date(2016, 10, 20));
            assertEquals(test.Frequency, Frequency.P3M);
            assertEquals(test.Adjustment, ADJ);
        }
        public virtual void test_builder_validFull()
        {
            ValueStepSequence seq  = ValueStepSequence.of(date(2016, 4, 20), date(2016, 10, 20), Frequency.P3M, ValueAdjustment.ofDeltaAmount(-100));
            ValueSchedule     test = ValueSchedule.builder().initialValue(2000d).steps(STEP1, STEP2).stepSequence(seq).build();

            assertEquals(test.InitialValue, 2000d, TOLERANCE);
            assertEquals(test.Steps, ImmutableList.of(STEP1, STEP2));
            assertEquals(test.StepSequence, seq);
        }
        public virtual void test_of_sequence()
        {
            ValueStepSequence seq  = ValueStepSequence.of(date(2016, 4, 20), date(2016, 10, 20), Frequency.P3M, ValueAdjustment.ofDeltaAmount(-100));
            ValueSchedule     test = ValueSchedule.of(10000d, seq);

            assertEquals(test.InitialValue, 10000d, TOLERANCE);
            assertEquals(test.Steps, ImmutableList.of());
            assertEquals(test.StepSequence, seq);
        }
        //-------------------------------------------------------------------------
        public virtual void test_resolve()
        {
            ValueStepSequence test     = ValueStepSequence.of(date(2016, 4, 20), date(2016, 10, 20), Frequency.P3M, ADJ);
            ValueStep         baseStep = ValueStep.of(date(2016, 1, 20), ValueAdjustment.ofReplace(500d));
            IList <ValueStep> steps    = test.resolve(ImmutableList.of(baseStep), RollConventions.NONE);

            assertEquals(steps.Count, 4);
            assertEquals(steps[0], baseStep);
            assertEquals(steps[1], ValueStep.of(date(2016, 4, 20), ADJ));
            assertEquals(steps[2], ValueStep.of(date(2016, 7, 20), ADJ));
            assertEquals(steps[3], ValueStep.of(date(2016, 10, 20), ADJ));
        }
Exemple #12
0
 //-----------------------------------------------------------------------
 public override bool Equals(object obj)
 {
     if (obj == this)
     {
         return(true);
     }
     if (obj != null && obj.GetType() == this.GetType())
     {
         ValueStepSequence other = (ValueStepSequence)obj;
         return(JodaBeanUtils.equal(firstStepDate, other.firstStepDate) && JodaBeanUtils.equal(lastStepDate, other.lastStepDate) && JodaBeanUtils.equal(frequency, other.frequency) && JodaBeanUtils.equal(adjustment, other.adjustment));
     }
     return(false);
 }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") @Override public Builder set(String propertyName, Object newValue)
            public override Builder set(string propertyName, object newValue)
            {
                switch (propertyName.GetHashCode())
                {
                case -418368371:         // initialValue
                    this.initialValue_Renamed = (double?)newValue.Value;
                    break;

                case 109761319:         // steps
                    this.steps_Renamed = (IList <ValueStep>)newValue;
                    break;

                case 2141410989:         // stepSequence
                    this.stepSequence_Renamed = (ValueStepSequence)newValue;
                    break;

                default:
                    throw new NoSuchElementException("Unknown property: " + propertyName);
                }
                return(this);
            }
 /// <summary>
 /// Restricted copy constructor. </summary>
 /// <param name="beanToCopy">  the bean to copy from, not null </param>
 internal Builder(ValueSchedule beanToCopy)
 {
     this.initialValue_Renamed = beanToCopy.InitialValue;
     this.steps_Renamed        = ImmutableList.copyOf(beanToCopy.Steps);
     this.stepSequence_Renamed = beanToCopy.stepSequence;
 }
        public virtual void test_serialization()
        {
            ValueStepSequence test = ValueStepSequence.of(date(2016, 4, 20), date(2016, 10, 20), Frequency.P3M, ADJ);

            assertSerialization(test);
        }
 /// <summary>
 /// Sets the sequence of steps changing the value.
 /// <para>
 /// This allows a regular pattern of steps to be encoded.
 /// All step dates must be unique, thus the list of steps must not contain any date implied by this sequence.
 /// </para>
 /// </summary>
 /// <param name="stepSequence">  the new value </param>
 /// <returns> this, for chaining, not null </returns>
 public Builder stepSequence(ValueStepSequence stepSequence)
 {
     this.stepSequence_Renamed = stepSequence;
     return(this);
 }
 public virtual void test_of_invalid()
 {
     assertThrowsIllegalArg(() => ValueStepSequence.of(date(2016, 4, 20), date(2016, 4, 19), Frequency.P3M, ADJ));
     assertThrowsIllegalArg(() => ValueStepSequence.of(date(2016, 4, 20), date(2016, 10, 20), Frequency.P3M, ADJ_BAD));
 }
 /// <summary>
 /// Obtains an instance from an initial value and a sequence of steps.
 /// <para>
 /// The sequence defines changes from one date to another date using a frequency.
 /// For example, the value might change every year from 2011-06-01 to 2015-06-01.
 ///
 /// </para>
 /// </summary>
 /// <param name="initialValue">  the initial value used for the first period </param>
 /// <param name="stepSequence">  the full definition of how the value changes over time </param>
 /// <returns> the value schedule </returns>
 public static ValueSchedule of(double initialValue, ValueStepSequence stepSequence)
 {
     return(new ValueSchedule(initialValue, ImmutableList.of(), stepSequence));
 }