private void addUseType(final Builder builder, final Method method) { final Class<?> type = method.getDeclaringClass(); final de.smartics.properties.api.core.annotations.PropertyUse typeAnnotation = type.getAnnotation(de.smartics.properties.api.core.annotations.PropertyUse.class); if (typeAnnotation != null) { final UseType useType = typeAnnotation.value(); if (useType != null) { builder.with(useType); } } }
private static void addExpression(final Builder builder, final Method method) { final de.smartics.properties.api.core.annotations.PropertyExpression annotation = method .getAnnotation(de.smartics.properties.api.core.annotations.PropertyExpression.class); if (annotation != null) { final String expressionString = annotation.value(); final PropertyExpression expression = PropertyExpression.create(expressionString); builder.with(expression); } }
private void addCategories(final Builder builder, final Method method) { final List<Class<?>> categories = readCategories(method); if (!categories.isEmpty()) { final PropertyCategories.Builder catBuilder = new PropertyCategories.Builder(); for (final Class<?> category : categories) { catBuilder.with(category); } final PropertyCategories propertyCategories = catBuilder.build(); builder.with(propertyCategories); } }
/** * Reads the property descriptor information from the method. * * @param method the method to read the property descriptor. * @return the property descriptor provided by this method. * @throws NullPointerException if {@code method} is <code>null</code>. */ public PropertyDescriptor readDescriptor(final Method method) throws NullPointerException { Arg.checkNotNull("method", method); final PropertyMetaData.Builder builder = new PropertyMetaData.Builder(); final Class<?> declaringType = method.getDeclaringClass(); final PropertyKey key = readKey(method); final PropertyType type = readType(method); builder.with(new PropertyContextProxy(context)) .withDeclaringType(declaringType).with(key).with(type); addValueRange(builder, method); addExpression(builder, method); addLifecycle(builder, method); addConstraints(builder, method); addDocumentProxy(builder, method, key); addComments(builder); addSecured(builder, method); addCategories(builder, method); addUseType(builder, method); return builder.build(); }
private void addLifecycle(final Builder builder, final Method method) { final de.smartics.properties.api.core.annotations.PropertyLifecycle annotation = method .getAnnotation(de.smartics.properties.api.core.annotations.PropertyLifecycle.class); if (annotation != null) { final PropertyDefinitionTime configurationTime = annotation.definitionTime(); if (configurationTime != null) { builder.with(configurationTime); } final AccessType accessType = annotation.access(); if (accessType != null) { builder.with(accessType); } final long updateInterval = annotation.updateInterval(); builder.withUpdateIntervalInMs(updateInterval); } }
@SuppressWarnings({ RAWTYPES, UNCHECKED }) private static void addValueRange(final Builder builder, final Method method) { final PropertyValueRange<?> valueRange = calculateValueRange(method); if (valueRange != null) { builder.with(valueRange); final PropertyRangeConstraint<?> constraint = new PropertyRangeConstraint(valueRange); builder.add(constraint); } }
private void addComments(final Builder builder) { final PropertyCommentProxy commentProxy = new PropertyCommentProxy(context); builder.with(commentProxy); }
private void addDocumentProxy(final Builder builder, final Method method, final PropertyKey key) { final DocumentMetaDataProxy proxy = new MetaInfDocumentMetaDataProxy(key, context, method); builder.with(proxy); }