/** * 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 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); }
private void checkCollection(final PropertyMetaData.Builder builder, final Method method, final Size size) { final Class<?> type = builder.getType().getType(); if (Collection.class.isAssignableFrom(type)) { final PropertyElementType elementTypeAnnotation = method.getAnnotation(PropertyElementType.class); final Class<?> elementType = calcElementType(elementTypeAnnotation); final List<? extends PropertyConstraint<?>> elementConstraints = calcElementConstraints(method); Integer min = null; Integer max = null; if (size != null) { min = size.min(); max = size.max(); } final PropertyConstraint<?> propertyConstraint = new ListValueConstraint(elementType, min, max, elementConstraints); builder.add(propertyConstraint); } }
final Class<?> type = descriptor.getType().getType();