//-------------------------------------------------------------------------
        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);
        }
        public virtual void test_builder_addListEntry()
        {
            ExplainMapBuilder @base   = ExplainMap.builder();
            ExplainMapBuilder result1 = @base.addListEntry(ExplainKey.LEGS, child => child.put(ExplainKey.ACCRUAL_DAYS, 2));
            ExplainMapBuilder result2 = result1.addListEntry(ExplainKey.LEGS, child => child.put(ExplainKey.ACCRUAL_DAYS, 3));
            ExplainMap        test    = result2.build();

            assertEquals(test.Map.size(), 1);
            assertEquals(test.get(ExplainKey.LEGS).Present, true);
            assertEquals(test.get(ExplainKey.LEGS).get().size(), 2);
            assertEquals(test.get(ExplainKey.LEGS).get().get(0).get(ExplainKey.ACCRUAL_DAYS), 2);
            assertEquals(test.get(ExplainKey.LEGS).get().get(1).get(ExplainKey.ACCRUAL_DAYS), 3);
        }
        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);
        }
        /// <summary>
        /// Closes the currently open list.
        /// <para>
        /// This returns the parent builder.
        ///
        /// </para>
        /// </summary>
        /// @param <R>  the type of the value </param>
        /// <param name="key">  the list key to close </param>
        /// <returns> the parent builder </returns>
        public ExplainMapBuilder closeListEntry <R>(ExplainKey <R> key)
        {
            object value = parent.map[key];

            if (value is ArrayList == false)
            {
                throw new System.InvalidOperationException("ExplainMapBuilder.closeList() called but no list found to close");
            }
            // close entry by converting it from ExplainMapBuilder to ExplainMap
//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;
            ExplainMapBuilder closedEntry = (ExplainMapBuilder)list[list.Count - 1];

            list[list.Count - 1] = closedEntry.build();
            return(parent);
        }