Пример #1
0
  /**
   * Returns all additional {@link BeanInfo} instances appropriate for the class represented by the
   * given {@code type}.
   *
   * @param type If {@code null}, returns global {@link BeanInfo} instances.
   * @return May be {@code null}.
   */
  @SuppressWarnings("unchecked")
  public BeanInfo[] getAdditionalBeanInfoByType(ObjectType type) {
    List<BeanInfo> beanInfos = null;

    for (DynamicProperty property : dynamicProperties.get()) {
      boolean add = false;

      if (type != null
          && type.getModificationClassNames().contains(property.type.getObjectClassName())) {
        add = true;

      } else {
        Class<?> modClass = property.type.getObjectClass();

        if (modClass != null
            && Modification.class.isAssignableFrom(modClass)
            && Modification.Static.getModifiedClasses((Class<? extends Modification<?>>) modClass)
                .contains(Object.class)) {
          add = true;
        }
      }

      if (add) {
        if (beanInfos == null) {
          beanInfos = new ArrayList<BeanInfo>();
        }

        beanInfos.add(property);
      }
    }

    return beanInfos != null ? beanInfos.toArray(new BeanInfo[beanInfos.size()]) : null;
  }