Beispiel #1
0
 public Class getPropertyType(String property) {
   if (underlyingEventType.isProperty(property)) {
     return underlyingEventType.getPropertyType(property);
   } else if (underlyingMapType.isProperty(property)) {
     return underlyingMapType.getPropertyType(property);
   } else {
     return null;
   }
 }
Beispiel #2
0
 public boolean isProperty(String property) {
   return underlyingEventType.isProperty(property) || underlyingMapType.isProperty(property);
 }
Beispiel #3
0
  public EventPropertyGetter getGetter(final String property) {
    EventPropertyGetter cachedGetter = propertyGetterCache.get(property);
    if (cachedGetter != null) {
      return cachedGetter;
    }

    if (underlyingMapType.isProperty(property) && (property.indexOf('?') == -1)) {
      final EventPropertyGetter mapGetter = underlyingMapType.getGetter(property);
      EventPropertyGetter getter =
          new EventPropertyGetter() {
            public Object get(EventBean theEvent) {
              if (!(theEvent instanceof DecoratingEventBean)) {
                throw new PropertyAccessException("Mismatched property getter to EventBean type");
              }
              DecoratingEventBean wrapperEvent = (DecoratingEventBean) theEvent;
              Map map = wrapperEvent.getDecoratingProperties();
              return mapGetter.get(eventAdapterService.adapterForTypedMap(map, underlyingMapType));
            }

            public boolean isExistsProperty(EventBean eventBean) {
              return true; // Property exists as the property is not dynamic (unchecked)
            }

            public Object getFragment(EventBean theEvent) {
              if (!(theEvent instanceof DecoratingEventBean)) {
                throw new PropertyAccessException("Mismatched property getter to EventBean type");
              }
              DecoratingEventBean wrapperEvent = (DecoratingEventBean) theEvent;
              Map map = wrapperEvent.getDecoratingProperties();
              return mapGetter.getFragment(
                  eventAdapterService.adapterForTypedMap(map, underlyingMapType));
            }
          };
      propertyGetterCache.put(property, getter);
      return getter;
    } else if (underlyingEventType.isProperty(property)) {
      EventPropertyGetter getter =
          new EventPropertyGetter() {
            public Object get(EventBean theEvent) {
              if (!(theEvent instanceof DecoratingEventBean)) {
                throw new PropertyAccessException("Mismatched property getter to EventBean type");
              }
              DecoratingEventBean wrapperEvent = (DecoratingEventBean) theEvent;
              EventBean wrappedEvent = wrapperEvent.getUnderlyingEvent();
              if (wrappedEvent == null) {
                return null;
              }

              EventPropertyGetter underlyingGetter = underlyingEventType.getGetter(property);
              return underlyingGetter.get(wrappedEvent);
            }

            public boolean isExistsProperty(EventBean eventBean) {
              return true; // Property exists as the property is not dynamic (unchecked)
            }

            public Object getFragment(EventBean theEvent) {
              if (!(theEvent instanceof DecoratingEventBean)) {
                throw new PropertyAccessException("Mismatched property getter to EventBean type");
              }
              DecoratingEventBean wrapperEvent = (DecoratingEventBean) theEvent;
              EventBean wrappedEvent = wrapperEvent.getUnderlyingEvent();
              if (wrappedEvent == null) {
                return null;
              }

              EventPropertyGetter underlyingGetter = underlyingEventType.getGetter(property);
              return underlyingGetter.getFragment(wrappedEvent);
            }
          };
      propertyGetterCache.put(property, getter);
      return getter;
    } else {
      return null;
    }
  }