public virtual void test_builder_openClose_wrongCloseKey()
        {
            ExplainMapBuilder builder = ExplainMap.builder();
            ExplainMapBuilder child   = builder.openListEntry(ExplainKey.LEGS);

            child.put(ExplainKey.ACCRUAL_DAYS, 2);
            assertThrows(() => child.closeListEntry(ExplainKey.PAYMENT_PERIODS), typeof(System.InvalidOperationException));
        }
        //-------------------------------------------------------------------------
        public virtual void test_builder_simple()
        {
            ExplainMapBuilder builder = ExplainMap.builder();

            builder.put(ExplainKey.ACCRUAL_DAYS, 2);
            ExplainMap test = builder.build();

            assertEquals(test.Map.size(), 1);
            assertEquals(test.get(ExplainKey.ACCRUAL_DAYS), 2);
            assertEquals(test.get(ExplainKey.ACCRUAL_DAY_COUNT), null);
        }
        /// <summary>
        /// Adds a list entry using a consumer callback function, including the list index.
        /// <para>
        /// This is an alternative to using <seealso cref="#openListEntry(ExplainKey)"/> and
        /// <seealso cref="#closeListEntry(ExplainKey)"/> directly.
        /// The consumer function receives the child builder and must add data to it.
        ///
        /// </para>
        /// </summary>
        /// @param <R>  the type of the value </param>
        /// <param name="key">  the list key to open </param>
        /// <param name="consumer">  the consumer that receives the list entry builder and adds to it </param>
        /// <returns> this builder </returns>
        public ExplainMapBuilder addListEntryWithIndex <R>(ExplainKey <R> key, System.Action <ExplainMapBuilder> consumer)
        {
            ExplainMapBuilder child = openListEntry(key);
            // find index
            object value = map[key];
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.ArrayList<Object> list = (java.util.ArrayList<Object>) value;
            List <object> list = (List <object>)value;

            child.put(ExplainKey.ENTRY_INDEX, list.Count - 1);
            consumer(child);
            return(child.closeListEntry(key));
        }
        public virtual void test_builder_openClose()
        {
            ExplainMapBuilder builder = ExplainMap.builder();
            ExplainMapBuilder child   = builder.openListEntry(ExplainKey.LEGS);

            child.put(ExplainKey.ACCRUAL_DAYS, 2);
            ExplainMapBuilder result = child.closeListEntry(ExplainKey.LEGS);
            ExplainMap        test   = result.build();

            assertEquals(test.Map.size(), 1);
            assertEquals(test.get(ExplainKey.LEGS).Present, true);
            assertEquals(test.get(ExplainKey.LEGS).get().size(), 1);
            assertEquals(test.get(ExplainKey.LEGS).get().get(0).get(ExplainKey.ACCRUAL_DAYS), 2);
        }