@Test public void testMightBeList() { assertFalse("expect json string might not be list ", converter().mightBeList(xml("fooBar.xml"))); assertTrue("expect json array might be list ", converter().mightBeList(xml("foosFoo.xml"))); assertFalse("expect json object might not be list ", converter().mightBeList(xml("foosBar.xml"))); }
boolean mightBeList(final @NotNull PlexusConfiguration config) { if (config.getChildCount() >= 1) { final String parentStem = plexusPluralStem(config.getName()); final String firstChild = config.getChild(0).getName(); return !parentStem.isEmpty() && parentStem.equals(plexusPluralStem(firstChild)) && Arrays.stream(config.getChildren()) .allMatch(child -> firstChild.equals(child.getName())); } return false; }
JsonConverter extends AbstractConfigurationConverter { boolean mightBeList(final @NotNull PlexusConfiguration config) { if (config.getChildCount() >= 1) { final String parentStem = plexusPluralStem(config.getName()); final String firstChild = config.getChild(0).getName(); return !parentStem.isEmpty() && parentStem.equals(plexusPluralStem(firstChild)) && Arrays.stream(config.getChildren()) .allMatch(child -> firstChild.equals(child.getName())); } return false; } }
JsonConverter extends AbstractConfigurationConverter { boolean mightBeList(final @NotNull PlexusConfiguration config) { if (config.getChildCount() >= 1) { final String parentStem = plexusPluralStem(config.getName()); final String firstChild = config.getChild(0).getName(); return !parentStem.isEmpty() && parentStem.equals(plexusPluralStem(firstChild)) && Arrays.stream(config.getChildren()) .allMatch(child -> firstChild.equals(child.getName())); } return false; }  }
JsonConverter extends AbstractConfigurationConverter { boolean mightBeList(final @NotNull PlexusConfiguration config) { if (config.getChildCount() >= 1) { final String parentStem = plexusPluralStem(config.getName()); final String firstChild = config.getChild(0).getName(); return !parentStem.isEmpty() && parentStem.equals(plexusPluralStem(firstChild)) && Arrays.stream(config.getChildren()) .allMatch(child -> firstChild.equals(child.getName())); } return false; }  static String plexusPluralStem(final String key); @Override boolean canConvert(final Class<?> type); @Override Object fromConfiguration(final ConverterLookup lookup,
                                    final PlexusConfiguration configuration,
                                    final Class<?> type,
                                    final Class<?> enclosingType,
                                    final ClassLoader loader,
                                    final ExpressionEvaluator evaluator,
                                    final ConfigurationListener listener); JsonValue convertChild(final @NotNull PlexusConfiguration child, final ExpressionEvaluator evaluator); static Object stringToValue(String string); }
JsonConverter extends AbstractConfigurationConverter { boolean mightBeList(final @NotNull PlexusConfiguration config) { if (config.getChildCount() >= 1) { final String parentStem = plexusPluralStem(config.getName()); final String firstChild = config.getChild(0).getName(); return !parentStem.isEmpty() && parentStem.equals(plexusPluralStem(firstChild)) && Arrays.stream(config.getChildren()) .allMatch(child -> firstChild.equals(child.getName())); } return false; }  static String plexusPluralStem(final String key); @Override boolean canConvert(final Class<?> type); @Override Object fromConfiguration(final ConverterLookup lookup,
                                    final PlexusConfiguration configuration,
                                    final Class<?> type,
                                    final Class<?> enclosingType,
                                    final ClassLoader loader,
                                    final ExpressionEvaluator evaluator,
                                    final ConfigurationListener listener); JsonValue convertChild(final @NotNull PlexusConfiguration child, final ExpressionEvaluator evaluator); static Object stringToValue(String string);  }