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.

Property.java 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. @VaadinApache2LicenseForJavaFiles@
  3. */
  4. package com.vaadin.client.metadata;
  5. import com.vaadin.shared.annotations.DelegateToWidget;
  6. public class Property {
  7. private final Type bean;
  8. private final String name;
  9. public Property(Type bean, String name) {
  10. this.bean = bean;
  11. this.name = name;
  12. }
  13. public Object getValue(Object bean) throws NoDataException {
  14. return TypeDataStore.getGetter(this).invoke(bean);
  15. }
  16. public void setValue(Object bean, Object value) throws NoDataException {
  17. TypeDataStore.getSetter(this).invoke(bean, value);
  18. }
  19. public String getDelegateToWidgetMethodName() {
  20. String value = TypeDataStore.getDelegateToWidget(this);
  21. if (value == null) {
  22. return null;
  23. } else {
  24. return DelegateToWidget.Helper.getDelegateTarget(getName(), value);
  25. }
  26. }
  27. public Type getType() throws NoDataException {
  28. return TypeDataStore.getType(this);
  29. }
  30. public String getSignature() {
  31. return bean.toString() + "." + name;
  32. }
  33. @Override
  34. public boolean equals(Object obj) {
  35. if (this == obj) {
  36. return true;
  37. } else if (obj instanceof Property) {
  38. Property other = (Property) obj;
  39. return getSignature().equals(other.getSignature());
  40. } else {
  41. return false;
  42. }
  43. }
  44. @Override
  45. public int hashCode() {
  46. return getSignature().hashCode();
  47. }
  48. public String getName() {
  49. return name;
  50. }
  51. @Override
  52. public String toString() {
  53. return getSignature();
  54. }
  55. }