2222import java .util .HashMap ;
2323import java .util .List ;
2424import java .util .Map ;
25- import java .util .stream .Collectors ;
2625
2726/**
2827 * Represents an extract of properties (typically {@link MCRConfiguration2#getPropertiesMap()}) used to
@@ -407,134 +406,6 @@ public Map<String, MCRInstanceConfiguration> nestedConfigurationMap(String commo
407406 return nestedConfigurationMap ;
408407 }
409408
410- /**
411- * Returns a {@link List} of configurations for nested instances, ordered by the first name segment
412- * (which all must be integer values).
413- * <p>
414- * Example: Given an {@link MCRInstanceConfiguration}
415- * representing the {@link MCRInstanceName} <code>Some.Instance.Name</code>, properties
416- * <ul>
417- * <li><code>1=some.nested.ClassName1</code></li>
418- * <li><code>1.Key1=ValueA1</code></li>
419- * <li><code>1.Key2=ValueA2</code></li>
420- * <li><code>3=some.nested.ClassName3</code></li>
421- * <li><code>3.Key1=ValueB1</code></li>
422- * <li><code>3.Key2=ValueB2</code></li>
423- * </ul>
424- * this will return a list containing
425- * <ol>
426- * <li>
427- * at index <code>0</code> an {@link MCRInstanceConfiguration}
428- * representing the {@link MCRInstanceConfiguration#name()} <code>Some.Instance.Name.Foo.1</code>,
429- * {@link MCRInstanceConfiguration#className()} <code>some.nested.ClassName1</code> and
430- * {@link MCRInstanceConfiguration#properties()}
431- * <ul>
432- * <li><code>Key1=ValueA1</code></li>
433- * <li><code>Key2=ValueA2</code></li>
434- * </ul>
435- * and {@link MCRInstanceConfiguration#fullProperties()} that are equal to the the full properties of this
436- * configuration (i.e. the full properties used to create the top level configuration).
437- * </li>
438- * <li>
439- * at index <code>1</code> an {@link MCRInstanceConfiguration}
440- * representing the {@link MCRInstanceConfiguration#name()} <code>Some.Instance.Name.Foo.3</code>,
441- * {@link MCRInstanceConfiguration#className()} <code>some.nested.ClassName3</code> and
442- * {@link MCRInstanceConfiguration#properties()}
443- * <ul>
444- * <li><code>Key1=ValueB1</code></li>
445- * <li><code>Key2=ValueB2</code></li>
446- * </ul>
447- * and {@link MCRInstanceConfiguration#fullProperties()} that are equal to the the full properties of this
448- * configuration (i.e. the full properties used to create the top level configuration).
449- * </li>
450- * </ol>
451- * <p>
452- * If an {@link MCRInstanceName} with suffix <code>.Class</code> or <code>.class</code> would have been used in
453- * the top level {@link MCRInstanceConfiguration}, the same suffix is used for nested configurations.
454- * <p>
455- * Example: If a property with suffix <code>.Class</code> would have been used to convey the original class name
456- * in the top level configuration, properties <code>Foo.1.Class</code>/<code>Foo.3.Class</code> would be used to
457- * convey the class name for the nested configurations and properties
458- * <code>Foo.1.class</code>/<code>Foo.3.class</code> and <code>Foo.1</code>/<code>Foo.3</code> would be ignored.
459- * The resulting {@link MCRInstanceConfiguration#properties()} would not contain entries with keys
460- * <code>class</code> or the empty key, respectively.
461- *
462- * @return the nested configuration list
463- */
464- public List <MCRInstanceConfiguration > nestedConfigurationList () {
465- return mapToList (nestedConfigurationMap ());
466- }
467-
468- /**
469- * Returns a {@link List} of configurations for nested instances with a common prefix, ordered by the
470- * name segment following that common prefix (which all must be integer values).
471- * <p>
472- * Example: Given an {@link MCRInstanceConfiguration}
473- * representing the {@link MCRInstanceName} <code>Some.Instance.Name</code>, properties
474- * <ul>
475- * <li><code>Foo.1=some.nested.ClassName1</code></li>
476- * <li><code>Foo.1.Key1=ValueA1</code></li>
477- * <li><code>Foo.1.Key2=ValueA2</code></li>
478- * <li><code>Foo.3=some.nested.ClassName3</code></li>
479- * <li><code>Foo.3.Key1=ValueB1</code></li>
480- * <li><code>Foo.3.Key2=ValueB2</code></li>
481- * <li><code>Bar=UnrelatedValue</code></li>
482- * </ul>
483- * and a <em>commonPrefix</em> of <code>Foo</code>, this will return a list containing
484- * <ol>
485- * <li>
486- * at index <code>0</code> an {@link MCRInstanceConfiguration}
487- * representing the {@link MCRInstanceConfiguration#name()} <code>Some.Instance.Name.Foo.1</code>,
488- * {@link MCRInstanceConfiguration#className()} <code>some.nested.ClassName1</code> and
489- * {@link MCRInstanceConfiguration#properties()}
490- * <ul>
491- * <li><code>Key1=ValueA1</code></li>
492- * <li><code>Key2=ValueA2</code></li>
493- * </ul>
494- * and {@link MCRInstanceConfiguration#fullProperties()} that are equal to the the full properties of this
495- * configuration (i.e. the full properties used to create the top level configuration).
496- * </li>
497- * <li>
498- * at index <code>1</code> an {@link MCRInstanceConfiguration}
499- * representing the {@link MCRInstanceConfiguration#name()} <code>Some.Instance.Name.Foo.3</code>,
500- * {@link MCRInstanceConfiguration#className()} <code>some.nested.ClassName3</code> and
501- * {@link MCRInstanceConfiguration#properties()}
502- * <ul>
503- * <li><code>Key1=ValueB1</code></li>
504- * <li><code>Key2=ValueB2</code></li>
505- * </ul>
506- * and {@link MCRInstanceConfiguration#fullProperties()} that are equal to the the full properties of this
507- * configuration (i.e. the full properties used to create the top level configuration).
508- * </li>
509- * </ol>
510- * <p>
511- * If an {@link MCRInstanceName} with suffix <code>.Class</code> or <code>.class</code> would have been used in
512- * the top level {@link MCRInstanceConfiguration}, the same suffix is used for nested configurations.
513- * <p>
514- * Example: If a property with suffix <code>.Class</code> would have been used to convey the original class name
515- * in the top level configuration, properties <code>Foo.1.Class</code>/<code>Foo.3.Class</code> would be used to
516- * convey the class name for the nested configurations and properties
517- * <code>Foo.1.class</code>/<code>Foo.3.class</code> and <code>Foo.1</code>/<code>Foo.3</code> would be ignored.
518- * The resulting {@link MCRInstanceConfiguration#properties()} would not contain entries with keys
519- * <code>class</code> or the empty key, respectively.
520- *
521- * @param commonPrefix the common prefix
522- * @return the nested configuration list
523- */
524- public List <MCRInstanceConfiguration > nestedConfigurationList (String commonPrefix ) {
525- return mapToList (nestedConfigurationMap (commonPrefix ));
526- }
527-
528- private List <MCRInstanceConfiguration > mapToList (Map <String , MCRInstanceConfiguration > map ) {
529- return map
530- .entrySet ()
531- .stream ()
532- .map (entry -> Map .entry (Integer .parseInt (entry .getKey ()), entry .getValue ()))
533- .sorted (Map .Entry .comparingByKey ())
534- .map (Map .Entry ::getValue )
535- .collect (Collectors .toList ());
536- }
537-
538409 /**
539410 * Returns the configuration with a fixed class name.
540411 * <p>
@@ -560,7 +431,7 @@ private List<MCRInstanceConfiguration> mapToList(Map<String, MCRInstanceConfigur
560431 * @param fixedClass the class to be used as a class name
561432 * @return the modified configuration
562433 */
563- public <S > MCRInstanceConfiguration fixedClass (Class <S > fixedClass ) {
434+ public <S > MCRInstanceConfiguration withClass (Class <S > fixedClass ) {
564435 return new MCRInstanceConfiguration (name , fixedClass .getName (), properties , fullProperties );
565436 }
566437
0 commit comments