/** * 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 static PropertyType readType(final Method method) { final Class<?> type = method.getReturnType(); final Class<?> subType = determineSubType(method); return new PropertyType(type, subType); }
/** * Default constructor. * * @param type the Java type of the property. * @param elementType the Java type of the elements of the property if the * {@link #getType() type} is a collection type. * @throws NullArgumentException if {@code type} is <code>null</code>. */ public PropertyType(final Class<?> type, final Class<?> elementType) throws NullArgumentException { this.type = Arg.checkNotNull("type", type); this.elementType = calcDefaultElementType(type, elementType); }
addElement(rootElement, "name", key); final PropertyType type = descriptor.getType(); addElement(rootElement, "type", type.toString()); // NOPMD final UseType useType = descriptor.getUseType(); addElement(rootElement, "useType", useType);
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();