Beispiel #1
0
  public EventBeanWriter getWriter(String[] properties) {
    if (writableProperties == null) {
      initializeWriters();
    }

    boolean isOnlyMap = true;
    for (int i = 0; i < properties.length; i++) {
      if (!writers.containsKey(properties[i])) {
        return null;
      }
      if (underlyingMapType.getWritableProperty(properties[i]) == null) {
        isOnlyMap = false;
      }
    }

    boolean isOnlyUnderlying = true;
    if (!isOnlyMap) {
      EventTypeSPI spi = (EventTypeSPI) underlyingEventType;
      for (int i = 0; i < properties.length; i++) {
        if (spi.getWritableProperty(properties[i]) == null) {
          isOnlyUnderlying = false;
        }
      }
    }

    if (isOnlyMap) {
      return new WrapperEventBeanMapWriter(properties);
    }
    if (isOnlyUnderlying) {
      EventTypeSPI spi = (EventTypeSPI) underlyingEventType;
      EventBeanWriter undWriter = spi.getWriter(properties);
      if (undWriter == null) {
        return undWriter;
      }
      return new WrapperEventBeanUndWriter(undWriter);
    }

    EventPropertyWriter writerArr[] = new EventPropertyWriter[properties.length];
    for (int i = 0; i < properties.length; i++) {
      writerArr[i] = writers.get(properties[i]).getSecond();
    }
    return new WrapperEventBeanPropertyWriter(writerArr);
  }
Beispiel #2
0
  public EventBeanCopyMethod getCopyMethod(String[] properties) {
    if (writableProperties == null) {
      initializeWriters();
    }

    boolean isOnlyMap = true;
    for (int i = 0; i < properties.length; i++) {
      if (underlyingMapType.getWritableProperty(properties[i]) == null) {
        isOnlyMap = false;
      }
    }

    boolean isOnlyUnderlying = true;
    if (!isOnlyMap) {
      if (!(underlyingEventType instanceof EventTypeSPI)) {
        return null;
      }
      EventTypeSPI spi = (EventTypeSPI) underlyingEventType;
      for (int i = 0; i < properties.length; i++) {
        if (spi.getWritableProperty(properties[i]) == null) {
          isOnlyUnderlying = false;
        }
      }
    }

    if (isOnlyMap) {
      return new WrapperEventBeanMapCopyMethod(this, eventAdapterService);
    }

    EventBeanCopyMethod undCopyMethod =
        ((EventTypeSPI) underlyingEventType).getCopyMethod(properties);
    if (undCopyMethod == null) {
      return null;
    }
    if (isOnlyUnderlying) {
      return new WrapperEventBeanUndCopyMethod(this, eventAdapterService, undCopyMethod);
    } else {
      return new WrapperEventBeanCopyMethod(this, eventAdapterService, undCopyMethod);
    }
  }