/**
   * Adds descriptor fields from the <code>ManagedAttribute</code> attribute to the attribute
   * descriptor. Specifically, adds the <code>currencyTimeLimit</code>, <code>default</code>, <code>
   * persistPolicy</code> and <code>persistPeriod</code> descriptor fields if they are present in
   * the metadata.
   */
  protected void populateAttributeDescriptor(
      Descriptor desc, Method getter, Method setter, String beanKey) {
    ManagedAttribute gma =
        (getter == null)
            ? ManagedAttribute.EMPTY
            : this.attributeSource.getManagedAttribute(getter);
    ManagedAttribute sma =
        (setter == null)
            ? ManagedAttribute.EMPTY
            : this.attributeSource.getManagedAttribute(setter);

    applyCurrencyTimeLimit(
        desc, resolveIntDescriptor(gma.getCurrencyTimeLimit(), sma.getCurrencyTimeLimit()));

    Object defaultValue = resolveObjectDescriptor(gma.getDefaultValue(), sma.getDefaultValue());
    desc.setField(FIELD_DEFAULT, defaultValue);

    String persistPolicy = resolveStringDescriptor(gma.getPersistPolicy(), sma.getPersistPolicy());
    if (StringUtils.hasLength(persistPolicy)) {
      desc.setField(FIELD_PERSIST_POLICY, persistPolicy);
    }
    int persistPeriod = resolveIntDescriptor(gma.getPersistPeriod(), sma.getPersistPeriod());
    if (persistPeriod >= 0) {
      desc.setField(FIELD_PERSIST_PERIOD, Integer.toString(persistPeriod));
    }
  }