@Override public <T> T getProperty(PropertyDescriptor<T> propertyDescriptor) { checkValidPropertyDescriptor(propertyDescriptor); T result = propertyDescriptor.defaultValue(); if (propertyValuesByDescriptor.containsKey(propertyDescriptor)) { @SuppressWarnings("unchecked") T value = (T) propertyValuesByDescriptor.get(propertyDescriptor); result = value; } return result; }
@Override public Map<PropertyDescriptor<?>, Object> getPropertiesByPropertyDescriptor() { if (propertyDescriptors.isEmpty()) { return Collections.emptyMap(); } Map<PropertyDescriptor<?>, Object> propertiesByPropertyDescriptor = new HashMap<>(propertyDescriptors.size()); // Fill with existing explicitly values propertiesByPropertyDescriptor.putAll(this.propertyValuesByDescriptor); // Add default values for anything not yet set for (PropertyDescriptor<?> propertyDescriptor : this.propertyDescriptors) { if (!propertiesByPropertyDescriptor.containsKey(propertyDescriptor)) { propertiesByPropertyDescriptor.put(propertyDescriptor, propertyDescriptor.defaultValue()); } } return Collections.unmodifiableMap(propertiesByPropertyDescriptor); }
private void assignReportLevelsCompat() { int methodLevel = getProperty(METHOD_LEVEL_DESCRIPTOR); int classLevel = getProperty(CLASS_LEVEL_DESCRIPTOR); int commonLevel = getProperty(REPORT_LEVEL_DESCRIPTOR); if (methodLevel == METHOD_LEVEL_DESCRIPTOR.defaultValue() && classLevel == CLASS_LEVEL_DESCRIPTOR.defaultValue() && commonLevel != REPORT_LEVEL_DESCRIPTOR.defaultValue()) { LOG.warning("Rule CyclomaticComplexity uses deprecated property 'reportLevel'. " + "Future versions of PMD will remove support for this property. " + "Please use 'methodReportLevel' and 'classReportLevel' instead!"); methodLevel = commonLevel; classLevel = commonLevel * 8; } methodReportLevel = methodLevel; classReportLevel = classLevel; }
@Override @Deprecated public boolean usesDefaultValues() { Map<PropertyDescriptor<?>, Object> valuesByProperty = getPropertiesByPropertyDescriptor(); if (valuesByProperty.isEmpty()) { return true; } for (Entry<PropertyDescriptor<?>, Object> entry : valuesByProperty.entrySet()) { if (!CollectionUtil.areEqual(entry.getKey().defaultValue(), entry.getValue())) { return false; } } return true; }
private int getReportLevel() { double oldProp = getProperty(MINIMUM_DESCRIPTOR); if (oldProp != MINIMUM_DESCRIPTOR.defaultValue()) { LOG.warning("Rule NPathComplexity uses deprecated property 'minimum'. Future versions of PMD will remove support for this property. Please use 'reportLevel' instead!"); return (int) oldProp; } return getProperty(REPORT_LEVEL_DESCRIPTOR); }
private static String getReports() { StringBuilder buf = new StringBuilder(); for (String reportName : RendererFactory.REPORT_FORMAT_TO_RENDERER.keySet()) { Renderer renderer = RendererFactory.createRenderer(reportName, new Properties()); buf.append(" ").append(reportName).append(": "); if (!reportName.equals(renderer.getName())) { buf.append(" Deprecated alias for '" + renderer.getName()).append(PMD.EOL); continue; } buf.append(renderer.getDescription()).append(PMD.EOL); for (PropertyDescriptor<?> property : renderer.getPropertyDescriptors()) { buf.append(" ").append(property.name()).append(" - "); buf.append(property.description()); Object deflt = property.defaultValue(); if (deflt != null) { buf.append(" default: ").append(deflt); } buf.append(PMD.EOL); } } return buf.toString(); }
@Override @Deprecated public boolean usesDefaultValues() { List<PropertyDescriptor<?>> descriptors = getOverriddenPropertyDescriptors(); if (!descriptors.isEmpty()) { return false; } for (PropertyDescriptor<?> desc : descriptors) { if (!Objects.equals(desc.defaultValue(), getProperty(desc))) { return false; } } return getRule().usesDefaultValues(); }
private Element createPropertyDefinitionElementBR(PropertyDescriptor<?> propertyDescriptor) { final Element propertyElement = createPropertyValueElement(propertyDescriptor, propertyDescriptor.defaultValue()); propertyElement.setAttribute(PropertyDescriptorField.TYPE.attributeName(), PropertyTypeId.typeIdFor(propertyDescriptor.type(), propertyDescriptor.isMultiValue())); Map<PropertyDescriptorField, String> propertyValuesById = propertyDescriptor.attributeValuesById(); for (Map.Entry<PropertyDescriptorField, String> entry : propertyValuesById.entrySet()) { propertyElement.setAttribute(entry.getKey().attributeName(), entry.getValue()); } return propertyElement; }
if (propertiesByPropertyDescriptor != null) { Object defaultValue = propertyDescriptor.defaultValue(); Object value = propertiesByPropertyDescriptor.get(propertyDescriptor); if (value != defaultValue && (value == null || !value.equals(defaultValue))) { Object defaultValue = propertyDescriptor.defaultValue(); Object value = entry.getValue(); if (value != defaultValue && (value == null || !value.equals(defaultValue))) {
if (propertyDescriptor.defaultValue() != null) { if (propertyDescriptor.isMultiValue()) { @SuppressWarnings("unchecked") // multi valued properties are using a List " " + multiPropertyDescriptor.multiValueDelimiter() + " "); } else { defaultValue = String.valueOf(propertyDescriptor.defaultValue());
@Override public <T> T getProperty(PropertyDescriptor<T> propertyDescriptor) { checkValidPropertyDescriptor(propertyDescriptor); T result = propertyDescriptor.defaultValue(); if (propertyValuesByDescriptor.containsKey(propertyDescriptor)) { @SuppressWarnings("unchecked") T value = (T) propertyValuesByDescriptor.get(propertyDescriptor); result = value; } return result; }
@Override public Map<PropertyDescriptor<?>, Object> getPropertiesByPropertyDescriptor() { if (propertyDescriptors.isEmpty()) { return Collections.emptyMap(); } Map<PropertyDescriptor<?>, Object> propertiesByPropertyDescriptor = new HashMap<>(propertyDescriptors.size()); // Fill with existing explicitly values propertiesByPropertyDescriptor.putAll(this.propertyValuesByDescriptor); // Add default values for anything not yet set for (PropertyDescriptor<?> propertyDescriptor : this.propertyDescriptors) { if (!propertiesByPropertyDescriptor.containsKey(propertyDescriptor)) { propertiesByPropertyDescriptor.put(propertyDescriptor, propertyDescriptor.defaultValue()); } } return Collections.unmodifiableMap(propertiesByPropertyDescriptor); }
private void assignReportLevelsCompat() { int methodLevel = getProperty(METHOD_LEVEL_DESCRIPTOR); int classLevel = getProperty(CLASS_LEVEL_DESCRIPTOR); int commonLevel = getProperty(REPORT_LEVEL_DESCRIPTOR); if (methodLevel == METHOD_LEVEL_DESCRIPTOR.defaultValue() && classLevel == CLASS_LEVEL_DESCRIPTOR.defaultValue() && commonLevel != REPORT_LEVEL_DESCRIPTOR.defaultValue()) { LOG.warning("Rule CyclomaticComplexity uses deprecated property 'reportLevel'. " + "Future versions of PMD will remove support for this property. " + "Please use 'methodReportLevel' and 'classReportLevel' instead!"); methodLevel = commonLevel; classLevel = commonLevel * 8; } methodReportLevel = methodLevel; classReportLevel = classLevel; }
@Override @Deprecated public boolean usesDefaultValues() { Map<PropertyDescriptor<?>, Object> valuesByProperty = getPropertiesByPropertyDescriptor(); if (valuesByProperty.isEmpty()) { return true; } for (Entry<PropertyDescriptor<?>, Object> entry : valuesByProperty.entrySet()) { if (!CollectionUtil.areEqual(entry.getKey().defaultValue(), entry.getValue())) { return false; } } return true; }
private int getReportLevel() { double oldProp = getProperty(MINIMUM_DESCRIPTOR); if (oldProp != MINIMUM_DESCRIPTOR.defaultValue()) { LOG.warning("Rule NPathComplexity uses deprecated property 'minimum'. Future versions of PMD will remove support for this property. Please use 'reportLevel' instead!"); return (int) oldProp; } return getProperty(REPORT_LEVEL_DESCRIPTOR); }
private static String getReports() { StringBuilder buf = new StringBuilder(); for (String reportName : RendererFactory.REPORT_FORMAT_TO_RENDERER.keySet()) { Renderer renderer = RendererFactory.createRenderer(reportName, new Properties()); buf.append(" ").append(reportName).append(": "); if (!reportName.equals(renderer.getName())) { buf.append(" Deprecated alias for '" + renderer.getName()).append(PMD.EOL); continue; } buf.append(renderer.getDescription()).append(PMD.EOL); for (PropertyDescriptor<?> property : renderer.getPropertyDescriptors()) { buf.append(" ").append(property.name()).append(" - "); buf.append(property.description()); Object deflt = property.defaultValue(); if (deflt != null) { buf.append(" default: ").append(deflt); } buf.append(PMD.EOL); } } return buf.toString(); }
@Override @Deprecated public boolean usesDefaultValues() { List<PropertyDescriptor<?>> descriptors = getOverriddenPropertyDescriptors(); if (!descriptors.isEmpty()) { return false; } for (PropertyDescriptor<?> desc : descriptors) { if (!Objects.equals(desc.defaultValue(), getProperty(desc))) { return false; } } return getRule().usesDefaultValues(); }
private Element createPropertyDefinitionElementBR(PropertyDescriptor<?> propertyDescriptor) { final Element propertyElement = createPropertyValueElement(propertyDescriptor, propertyDescriptor.defaultValue()); propertyElement.setAttribute(PropertyDescriptorField.TYPE.attributeName(), PropertyTypeId.typeIdFor(propertyDescriptor.type(), propertyDescriptor.isMultiValue())); Map<PropertyDescriptorField, String> propertyValuesById = propertyDescriptor.attributeValuesById(); for (Map.Entry<PropertyDescriptorField, String> entry : propertyValuesById.entrySet()) { propertyElement.setAttribute(entry.getKey().attributeName(), entry.getValue()); } return propertyElement; }
if (propertiesByPropertyDescriptor != null) { Object defaultValue = propertyDescriptor.defaultValue(); Object value = propertiesByPropertyDescriptor.get(propertyDescriptor); if (value != defaultValue && (value == null || !value.equals(defaultValue))) { Object defaultValue = propertyDescriptor.defaultValue(); Object value = entry.getValue(); if (value != defaultValue && (value == null || !value.equals(defaultValue))) {