/** * Returns the hash code of the object. * * @return the hash code. * @see de.smartics.properties.api.config.domain.PropertyDefinition#hashCode() */ @Override public int hashCode() { return descriptor.getKey().hashCode(); }
private void checkValidPair(final PropertyDescriptor descriptor, final Property property) throws IllegalArgumentException { final String name = property.getName(); final String descriptorName = descriptor.getKey().toString(); if (!name.equals(descriptorName)) { throw new IllegalArgumentException("Property value with key '" + name + "' does not match the key '" + descriptorName + "' in the property descriptor."); } }
/** * Returns the missing mandatory properties as message text. * * @return the missing mandatory properties as message text. */ @MessageParam("mandatoryProperties") public final String getMandatoryPropertiesAsText() { final StringBuilder buffer = new StringBuilder(); if (mandatoryProperties != null && !mandatoryProperties.isEmpty()) { for (final PropertyDescriptor descriptor : mandatoryProperties) { buffer.append(" ").append(descriptor.getKey()).append('\n'); } } return StringUtils.chomp(buffer.toString()); }
/** * Returns the set of properties this property belongs to. * * @return the set of properties this property belongs to. */ public String getPropertySet() { final String descriptorValue = descriptor.getKey().getPropertySet(); if (StringUtils.isBlank(descriptorValue)) { return sourceInfo.getElementTypeName(); } return descriptorValue; }
for (final PropertyDescriptor descriptor : entry.getValue()) buffer.append("\n ").append(descriptor.getKey());
/** * Default constructor. * * @param code the error or exception code of the exception. * @param cause the cause to the problem. * @param propertyDescriptor the descriptor of the property raising the * exception. */ public PropertyDescriptorMessageBean(final PropertiesCode code, final Throwable cause, final PropertyDescriptor propertyDescriptor) { super(code, cause, provide(propertyDescriptor).getKey()); this.propertyDescriptor = provide(propertyDescriptor); }
final PropertyDescriptor descriptor, final Locale locale) final String target = descriptor.getKey().getPropertySet();
/** * Returns the unique title of the report within the space. * * @return the unique title of the report within the space. */ public String getTitle() { final String metadataValue = descriptor.getDocumentMetaData().getTitle(); if (StringUtils.isBlank(metadataValue)) { return descriptor.getKey().toString(); } return metadataValue; }
private void checkForUniqueness(final PropertyReportItem item, final String name) { keyUniquenessMap.put(name, item); final List<PropertyReportItem> items = keyUniquenessMap.get(name); if (items.size() > 1) { final StringBuilder buffer = new StringBuilder(1024); buffer.append("Duplicate key '" + name + "' found:"); for (final PropertyReportItem duplicate : items) { buffer.append("\n -> ") .append(duplicate.getSourceInfo().getElementId()).append('/') .append(duplicate.getDescriptor().getKey()); } final String message = buffer.toString(); final ReportProblem problem = new ReportProblem(message); addProblem(problem); } }
final String key = descriptor.getKey().toString(); try
boolean doReadUnlock = true; final String key = descriptor.getKey().toString(); try
/** * Returns <code>true</code> if the given object is semantically equal to the * given object, <code>false</code> otherwise. * <p> * It is assumed that a descriptor with its key is unique. Therefore two * definitions are equal, if their descriptor keys are equal, they share the * same value and source location of the value. * </p> * * @param object object the instance to compare to. * @return <code>true</code> if the given object is semantically equal to the * given object, <code>false</code> otherwise. */ @Override public boolean equals(final Object object) { if (this == object) { return true; } else if (object == null || getClass() != object.getClass()) { return false; } final PropertyDefinition other = (PropertyDefinition) object; return (descriptor.getKey().equals(other.descriptor.getKey()) && ObjectUtils.equals(property.getValue(), other.property.getValue()) && ObjectUtils.equals( property.getSource(), other.property.getSource())); }
private void addDescriptor(final Class<?> propertySetType, final PropertyDescriptor descriptor, final List<DuplicatePropertyDeclarationException> exceptions) { final String key = descriptor.getKey().toString(); writeLock.lock(); try { final PropertyDescriptor currentDescriptor = descriptorMap.get(key); if (currentDescriptor != null && currentDescriptor.getDeclaringType() != descriptor .getDeclaringType()) { exceptions.add(new DuplicatePropertyDeclarationException( new PropertyDescriptorClashingMessageBean( PropertyCode.DUPLICATE_DECLARATION, currentDescriptor, descriptor))); } descriptors.put(propertySetType, descriptor); descriptorMap.put(key, descriptor); if (descriptor.isMandatory()) { mandatoryProperties.add(descriptor); } } finally { writeLock.unlock(); } }
private DescribedProperty getPropertyInternal( final PropertyDescriptor descriptor) { final String name = descriptor.getKey().toString(); final Property property = getPropertyFromStore(name); // if (property == null || property.getValue() == null) // { // if alternative lookups have to be provided, the 'properties' have to // be updated on every change. // final Property alt = properties.getValue(name); // property = alt != null ? alt : property; // } final DescribedProperty describedProperty = new DescribedProperty(this.getKey(), descriptor, property); return describedProperty; }
private void addProperties( final Map<Class<?>, List<PropertyDescriptor>> descriptorMap, final MultiSourceProperties compositeProperties) { final Properties properties = new Properties(); for (final Entry<Class<?>, List<PropertyDescriptor>> entry : descriptorMap .entrySet()) { final List<PropertyDescriptor> descriptors = entry.getValue(); for (final PropertyDescriptor descriptor : descriptors) { final String propertyKey = descriptor.getKey().toString(); final Property property = compositeProperties.getValue(propertyKey, true); if (property != null && property.getValue() != null) { properties.put(propertyKey, property); } } } final ConfigurationKey<?> key = compositeProperties.getConfigurationKey(); final ConfigurationPropertiesManagement configuration = factoryCache.ensureManagement(key); final PropertyProvider provider = new PropertiesPropertyProvider(key, new PropertyLocation( "classpath-various"), properties); configuration.addDefinitions(provider); }
@Override public void handle(final PropertyReportItem item) throws ReportException { super.handle(item); final PropertyDescriptor descriptor = item.getDescriptor(); final String key = descriptor.getKey().toString(); final PropertyExpression expression = descriptor.getDefaultExpression(); final String value = expression != null && expression.getExpression() != null ? expression .getExpression() : ""; currentProperties.setProperty(key, value); }
private void addProperties(final MultiSourceProperties compositeProperties) { final Properties properties = new Properties(); final Class<?> type = BootProperties.class; final PropertiesContext context = configuration.getContext(type); final PropertyMetaDataParser propertyDescriptorParser = PropertyMetaDataParser.create(context); final List<PropertyDescriptor> descriptors = propertyDescriptorParser.readDescriptors(type); for (final PropertyDescriptor descriptor : descriptors) { final String propertyKey = descriptor.getKey().toString(); final Property property = compositeProperties.getValue(propertyKey); if (property != null && property.getValue() != null) { properties.put(propertyKey, property); } else { properties.remove(propertyKey); } } configuration.addDescriptors(type); final PropertyProvider provider = new PropertiesPropertyProvider(configuration.getKey(), new PropertyLocation("boot-various"), properties); configuration.addDefinitions(provider); }
if (descriptor != null) final PropertyKey key = descriptor.getKey(); addElement(rootElement, "name", key); final PropertyType type = descriptor.getType();