private static ListValueConstraint fetchListValueConstraint( final PropertyDescriptor descriptor) throws IllegalArgumentException { for (final PropertyConstraint<?> constraint : descriptor.getConstraints()) { if (ListValueConstraint.class == constraint.getClass()) { return (ListValueConstraint) constraint; } } throw new IllegalArgumentException( "Property list value descriptor lacks list constraint."); }
/** * 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 static String getExpression(final PropertyDescriptor descriptor) { final PropertyExpression expression = descriptor.getDefaultExpression(); return expression != null ? expression.getExpression() : null; }
/** * 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; }
/** * Returns the name that uniquely identifies the property report within the * report set. * * @return the name that uniquely identifies the property report within the * report set. */ public String getLocalName() { final String metadataValue = descriptor.getDocumentMetaData().getName(); if (StringUtils.isBlank(metadataValue)) { return descriptor.getDocumentName().getName(); } return metadataValue; }
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(); } }
if (descriptor != null) final PropertyKey key = descriptor.getKey(); addElement(rootElement, "name", key); final PropertyType type = descriptor.getType(); addElement(rootElement, "type", type.toString()); // NOPMD final UseType useType = descriptor.getUseType(); addElement(rootElement, "useType", useType); addCategories(descriptor); descriptor.getDefaultExpression().getExpression(); if (expression != null)
if (plainValue == null && defaultValue == null && descriptor.isMandatory() && !isInAdminMode()) descriptor.getConstraints(), plainValue); throw new PropertyValidationException(message);
@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); }
if (currentValue == null) currentValue = descriptor.getDefaultExpression(); if (currentValue == null) if (descriptor.isSecured() && currentValue instanceof String)
/** * Default constructor. * * @param descriptor the list descriptor to analyze. * @throws NullArgumentException if {@code descriptor} is <code>null</code>. * @throws IllegalArgumentException if the descriptor does not describe a list * property or lacks the required {@link ListValueConstraint}. */ public ListPropertyHelper(final PropertyDescriptor descriptor) throws NullArgumentException, IllegalArgumentException { this.descriptor = Arg.checkNotNull("descriptor", descriptor); final Class<?> propertyType = descriptor.getType().getType(); if (!List.class.isAssignableFrom(propertyType)) { throw new IllegalArgumentException( "The descriptor suppossed to describe a list property" + " actually describes a property of type '" + propertyType + "'."); } listValueConstraint = fetchListValueConstraint(descriptor); }
private void addRanges(final PropertyDescriptor descriptor) { final PropertyValueRange<?> range = descriptor.getValueRange(); if (range != null) { final Element valueRangeElement = new Element("valueRange", ns); final PropertyValueComment valueComment = reportItem.getValueComment(); if (valueComment == null) { return; } final String summary = htmlUtils.cleanHtmlAndJavadoc(valueComment.getSummary()); addElement(valueRangeElement, "summary", summary); final List<?> values = range.getValues(); for (final Object value : values) { final String description = htmlUtils.cleanHtmlAndJavadoc(valueComment.getValueComment(value)); final Element element = new Element("element", ns); addElement(element, "value", value); addElement(element, "description", description); valueRangeElement.addContent(element); } rootElement.addContent(valueRangeElement); } }
private static String resolve(final PropertyDescriptor descriptor) { final DocumentName name = descriptor.getDocumentName(); final String target = name.getName(); // final String target = descriptor.getKey().toString(); return target; }
/** * Returns the properties context for the given descriptor. * * @param descriptor the descriptor whose properties context is requested. * @return the context for the property provided by the descriptor. May return * <code>null</code> if the {@code descriptor} is unknown. * @throws NullPointerException if {@code descriptor} is <code>null</code>. */ @CheckForNull public PropertiesContext get(final PropertyDescriptor descriptor) throws NullPointerException { Arg.checkNotNull("descriptor", descriptor); final Class<?> declaringType = descriptor.getDeclaringType(); return get(declaringType); }
private void addCategories(final PropertyDescriptor descriptor) { final PropertyCategories categories = descriptor.getCategories(); final Element categoriesElement = new Element("propertyCategories", ns); for (final Class<?> category : categories.getCategories()) { final String categoryType = category.getName(); addElement(categoriesElement, "propertyCategory", categoryType); } rootElement.addContent(categoriesElement); }
if (plainValue == null && defaultValue == null && descriptor.isMandatory()) descriptor.getConstraints(), plainValue); throw new PropertyValidationException(message);
private PropertyValueComment loadValueComment(final PropertyReport report, final PropertyDescriptor descriptor) { final Class<?> type = descriptor.getType().getType(); if (type.isEnum()) // TODO: Constant class? { final String typeName = type.getName(); final JavaClass javaClass = javaProjectBuilder.getClassByName(typeName); if (javaClass != null) { return loadValueComment(report, javaClass); } else { report.addProblem(new ReportProblem("Cannot find type class '" + typeName + "'.")); } } return new PropertyValueComment(null); }
/** * Usually the type is the type of the property of the descriptor. Only in the * case of a list, the type is the type of the list members. */ static void ensureConverter(final PropertyDescriptor descriptor, final Class<?> type) { final Converter converter = ConvertUtils.lookup(type); if (converter != null) { return; } final PropertyValueRange<?> range = descriptor.getValueRange(); if (range != null) { ConvertUtils.register(new PropertyValueRangeConverter(range, type), type); } else { ConvertUtils.register(new FromStringTypeConverter(type), type); } }
final ClassLoader loader = descriptor.getDeclaringType().getClassLoader(); // NOPMD
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."); } }