@Test public void testReadBooleanFromValue() throws Exception { assertSame("box true", Boolean.TRUE, converter().readBooleanFromValue("", Boolean.TRUE)); assertSame("box false", Boolean.FALSE, converter().readBooleanFromValue("", Boolean.FALSE)); assertTrue("string true", converter().readBooleanFromValue("", "true")); assertFalse("string false", converter().readBooleanFromValue("", "false")); assertFalse("null false", converter().readBooleanFromValue("", null)); assertFalse("empty string false", converter().readBooleanFromValue("", "")); assertFalse("null string false", converter().readBooleanFromValue("", "null")); assertFalse("integer always false", converter().readBooleanFromValue("", 1)); assertFalse("long always false", converter().readBooleanFromValue("", 1L)); assertFalse("float always false", converter().readBooleanFromValue("", 1.0F)); assertFalse("double always false", converter().readBooleanFromValue("", 1.0D)); }
Boolean readBooleanFromValue(final String key, final @Nullable Object value) throws ComponentConfigurationException { if (value instanceof Boolean) { return (Boolean) value; } else if (value instanceof String) { Object readValue = stringToValue((String) value); if (readValue instanceof Boolean) { return (Boolean) readValue; } else if (!isBlankish(readValue)) { throw new ComponentConfigurationException("Failed to parse value for key " + key + " as boolean."); } } return false; }
JsonConverter extends AbstractConfigurationConverter { Boolean readBooleanFromValue(final String key, final @Nullable Object value) throws ComponentConfigurationException { if (value instanceof Boolean) { return (Boolean) value; } else if (value instanceof String) { Object readValue = stringToValue((String) value); if (readValue instanceof Boolean) { return (Boolean) readValue; } else if (!isBlankish(readValue)) { throw new ComponentConfigurationException("Failed to parse value for key " + key + " as boolean."); } } return false; } }
JsonConverter extends AbstractConfigurationConverter { Boolean readBooleanFromValue(final String key, final @Nullable Object value) throws ComponentConfigurationException { if (value instanceof Boolean) { return (Boolean) value; } else if (value instanceof String) { Object readValue = stringToValue((String) value); if (readValue instanceof Boolean) { return (Boolean) readValue; } else if (!isBlankish(readValue)) { throw new ComponentConfigurationException("Failed to parse value for key " + key + " as boolean."); } } return false; }  }
JsonConverter extends AbstractConfigurationConverter { Boolean readBooleanFromValue(final String key, final @Nullable Object value) throws ComponentConfigurationException { if (value instanceof Boolean) { return (Boolean) value; } else if (value instanceof String) { Object readValue = stringToValue((String) value); if (readValue instanceof Boolean) { return (Boolean) readValue; } else if (!isBlankish(readValue)) { throw new ComponentConfigurationException("Failed to parse value for key " + key + " as boolean."); } } 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 readBooleanFromValue(final String key, final @Nullable Object value) throws ComponentConfigurationException { if (value instanceof Boolean) { return (Boolean) value; } else if (value instanceof String) { Object readValue = stringToValue((String) value); if (readValue instanceof Boolean) { return (Boolean) readValue; } else if (!isBlankish(readValue)) { throw new ComponentConfigurationException("Failed to parse value for key " + key + " as boolean."); } } 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);  }