if (attribute != null && attribute.getInjectionPoint() != null) { String propertyName = attribute.getInjectionPoint().getProperty(); if (!prefix.isEmpty()) { propertyName = prefix + "." + propertyName;
for (ConfigurationMetadata.InjectionPointMetaData deprecated : attribute.getLegacyInjectionPoints()) { knownDeprecatedProperties.add(deprecated.getProperty());
if (attribute.getInjectionPoint().getProperty() != null) { nonDeprecatedAttributes.add(attribute.getName()); Method getter = attribute.getGetter(); if (getter == null) { continue; Object expectedAttributeValue = expectedAttributeValues.get(attribute.getName()); assertEquals(expectedAttributeValue, actualAttributeValue, attribute.getName());
if (attribute != null && attribute.getInjectionPoint() != null) { String propertyName = attribute.getInjectionPoint().getProperty(); if (!prefix.isEmpty()) { propertyName = prefix + propertyName;
if (attribute != null && attribute.getInjectionPoint() != null) { String propertyName = attribute.getInjectionPoint().getProperty(); if (!prefix.isEmpty()) { propertyName = prefix + propertyName;
private ConfigurationMetadata.InjectionPointMetaData findOperativeInjectionPoint(AttributeMetadata attribute, String prefix, Problems problems) throws ConfigurationException ConfigurationMetadata.InjectionPointMetaData operativeInjectionPoint = attribute.getInjectionPoint(); String operativeName = null; String operativeValue = null; if (attribute.isSecuritySensitive()) { printableOperativeValue = "[REDACTED]"; for (ConfigurationMetadata.InjectionPointMetaData injectionPoint : attribute.getLegacyInjectionPoints()) { String fullName = prefix + injectionPoint.getProperty(); String value = properties.get(fullName); String printableValue = value; if (attribute.isSecuritySensitive()) { printableValue = "[REDACTED]"; if (attribute.getInjectionPoint() != null) { replacement = format("replaced. Use '%s' instead.", prefix + attribute.getInjectionPoint().getProperty());
private ConfigurationMetadata.InjectionPointMetaData findOperativeInjectionPoint(AttributeMetadata attribute, String prefix, Problems problems) throws ConfigurationException ConfigurationMetadata.InjectionPointMetaData operativeInjectionPoint = attribute.getInjectionPoint(); String operativeName = null; String operativeValue = null; if (attribute.isSecuritySensitive()) { printableOperativeValue = "[REDACTED]"; for (ConfigurationMetadata.InjectionPointMetaData injectionPoint : attribute.getLegacyInjectionPoints()) { String fullName = prefix + injectionPoint.getProperty(); String value = properties.get(fullName); String printableValue = value; if (attribute.isSecuritySensitive()) { printableValue = "[REDACTED]"; if (attribute.getInjectionPoint() != null) { replacement = format("replaced. Use '%s' instead.", prefix + attribute.getInjectionPoint().getProperty());
for (ConfigurationMetadata.InjectionPointMetaData deprecated : attribute.getLegacyInjectionPoints()) { knownDeprecatedProperties.add(deprecated.getProperty());
for (ConfigurationMetadata.InjectionPointMetaData deprecated : attribute.getLegacyInjectionPoints()) { knownDeprecatedProperties.add(deprecated.getProperty());
if (attributes.containsKey(attribute.getName())) { problems.addError("Configuration class [%s] Multiple methods are annotated for @Config attribute [%s]", configClass.getName(), attribute.getName()); attributes.put(attribute.getName(), attribute); for (InjectionPointMetaData injectionPoint : attribute.getLegacyInjectionPoints()) { if (legacyMethods.contains(injectionPoint.getSetter())) {
Set<Method> validSetterMethods = new HashSet<>(); for (AttributeMetadata attribute : metadata.getAttributes().values()) { if (attribute.getInjectionPoint().getProperty() != null) { validSetterMethods.add(attribute.getInjectionPoint().getSetter()); if (invokedMethods.contains(attribute.getInjectionPoint().getSetter())) { if (attribute.getInjectionPoint().getProperty() != null) { Object value = invoke(config, attribute.getGetter()); attributeValues.put(attribute.getName(), value); setDeprecatedAttributes.add(attribute.getName());
if (attribute.getInjectionPoint().getProperty() != null) { nonDeprecatedAttributes.add(attribute.getName()); Method getter = attribute.getGetter(); if (getter == null) { continue; Object expectedAttributeValue = expectedAttributeValues.get(attribute.getName()); assertEquals(expectedAttributeValue, actualAttributeValue, attribute.getName());
if (attribute.getInjectionPoint().getProperty() != null) { nonDeprecatedAttributes.add(attribute.getName()); Method getter = attribute.getGetter(); if (getter == null) { continue; Object expectedAttributeValue = expectedAttributeValues.get(attribute.getName()); Assert.assertEquals(expectedAttributeValue, actualAttributeValue, attribute.getName());
if (attributes.containsKey(attribute.getName())) { problems.addError("Configuration class [%s] Multiple methods are annotated for @Config attribute [%s]", configClass.getName(), attribute.getName()); attributes.put(attribute.getName(), attribute); for (InjectionPointMetaData injectionPoint : attribute.getLegacyInjectionPoints()) { if (legacyMethods.contains(injectionPoint.getSetter())) {
private ConfigurationMetadata.InjectionPointMetaData findOperativeInjectionPoint(AttributeMetadata attribute, String prefix, Problems problems) throws ConfigurationException ConfigurationMetadata.InjectionPointMetaData operativeInjectionPoint = attribute.getInjectionPoint(); String operativeName = null; String operativeValue = null; for (ConfigurationMetadata.InjectionPointMetaData injectionPoint : attribute.getLegacyInjectionPoints()) { String fullName = prefix + injectionPoint.getProperty(); String value = properties.get(fullName); if (value != null) { String replacement = "deprecated."; if (attribute.getInjectionPoint() != null) { replacement = format("replaced. Use '%s' instead.", prefix + attribute.getInjectionPoint().getProperty());
Set<Method> validSetterMethods = new HashSet<>(); for (AttributeMetadata attribute : metadata.getAttributes().values()) { if (attribute.getInjectionPoint().getProperty() != null) { validSetterMethods.add(attribute.getInjectionPoint().getSetter()); if (invokedMethods.contains(attribute.getInjectionPoint().getSetter())) { if (attribute.getInjectionPoint().getProperty() != null) { Object value = invoke(config, attribute.getGetter()); attributeValues.put(attribute.getName(), value); setDeprecatedAttributes.add(attribute.getName());
Set<Method> validSetterMethods = new HashSet<>(); for (AttributeMetadata attribute : metadata.getAttributes().values()) { if (attribute.getInjectionPoint().getProperty() != null) { validSetterMethods.add(attribute.getInjectionPoint().getSetter()); if (invokedMethods.contains(attribute.getInjectionPoint().getSetter())) { if (attribute.getInjectionPoint().getProperty() != null) { Object value = invoke(config, attribute.getGetter()); attributeValues.put(attribute.getName(), value); setDeprecatedAttributes.add(attribute.getName());
String propertyName = prefix + attribute.getInjectionPoint().getProperty(); Method getter = attribute.getGetter(); String description = attribute.getDescription(); if (description == null) { description = ""; builder.add(new ConfigAttribute(attribute.getName(), propertyName, defaultValue, currentValue, description, attribute.isSecuritySensitive()));
String propertyName = prefix + attribute.getInjectionPoint().getProperty(); Method getter = attribute.getGetter(); String description = attribute.getDescription(); if (description == null) { description = ""; builder.add(new ConfigAttribute(attribute.getName(), propertyName, defaultValue, currentValue, description, attribute.isSecuritySensitive()));
private Map<String, AttributeMetadata> buildAttributeMetadata(Class<T> configClass) { Map<String, AttributeMetadata> attributes = Maps.newHashMap(); for (Method configMethod : findConfigMethods(configClass)) { AttributeMetadata attribute = buildAttributeMetadata(configClass, configMethod); if (attribute != null) { if (attributes.containsKey(attribute.getName())) { problems.addError("Configuration class [%s] Multiple methods are annotated for @Config attribute [%s]", configClass.getName(), attribute.getName()); } attributes.put(attribute.getName(), attribute); } } // Find orphan @LegacyConfig methods, in order to report errors Collection<Method> legacyMethods = findLegacyConfigMethods(configClass); for (AttributeMetadata attribute : attributes.values()) { for (InjectionPointMetaData injectionPoint : attribute.getLegacyInjectionPoints()) { if (legacyMethods.contains(injectionPoint.getSetter())) { // Don't care about legacy methods which are related to current attributes legacyMethods.remove(injectionPoint.getSetter()); } } } for (Method method : legacyMethods) { if (!method.isAnnotationPresent(Config.class)) { validateSetter(method); problems.addError("@LegacyConfig method [%s] is not associated with any valid @Config attribute.", method.toGenericString()); } } return attributes; }