You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

NestedPropertyDescriptor.java 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. @VaadinApache2LicenseForJavaFiles@
  3. */
  4. package com.vaadin.data.util;
  5. import com.vaadin.data.Property;
  6. /**
  7. * Property descriptor that is able to create nested property instances for a
  8. * bean.
  9. *
  10. * The property is specified in the dotted notation, e.g. "address.street", and
  11. * can contain multiple levels of nesting.
  12. *
  13. * @param <BT>
  14. * bean type
  15. *
  16. * @since 6.6
  17. */
  18. public class NestedPropertyDescriptor<BT> implements
  19. VaadinPropertyDescriptor<BT> {
  20. private final String name;
  21. private final Class<?> propertyType;
  22. /**
  23. * Creates a property descriptor that can create MethodProperty instances to
  24. * access the underlying bean property.
  25. *
  26. * @param name
  27. * of the property in a dotted path format, e.g. "address.street"
  28. * @param beanType
  29. * type (class) of the top-level bean
  30. * @throws IllegalArgumentException
  31. * if the property name is invalid
  32. */
  33. public NestedPropertyDescriptor(String name, Class<BT> beanType)
  34. throws IllegalArgumentException {
  35. this.name = name;
  36. NestedMethodProperty<?> property = new NestedMethodProperty<Object>(
  37. beanType, name);
  38. this.propertyType = property.getType();
  39. }
  40. @Override
  41. public String getName() {
  42. return name;
  43. }
  44. @Override
  45. public Class<?> getPropertyType() {
  46. return propertyType;
  47. }
  48. @Override
  49. public Property<?> createProperty(BT bean) {
  50. return new NestedMethodProperty<Object>(bean, name);
  51. }
  52. }