protected FieldMetadataOverride constructAdornedTargetCollectionMetadataOverride(
     AdminPresentationAdornedTargetCollection adornedTargetCollection) {
   if (adornedTargetCollection != null) {
     FieldMetadataOverride override = new FieldMetadataOverride();
     override.setGridVisibleFields(adornedTargetCollection.gridVisibleFields());
     override.setIgnoreAdornedProperties(adornedTargetCollection.ignoreAdornedProperties());
     override.setMaintainedAdornedTargetFields(
         adornedTargetCollection.maintainedAdornedTargetFields());
     override.setParentObjectIdProperty(adornedTargetCollection.parentObjectIdProperty());
     override.setParentObjectProperty(adornedTargetCollection.parentObjectProperty());
     override.setSortAscending(adornedTargetCollection.sortAscending());
     override.setSortProperty(adornedTargetCollection.sortProperty());
     override.setTargetObjectIdProperty(adornedTargetCollection.targetObjectIdProperty());
     override.setTargetObjectProperty(adornedTargetCollection.targetObjectProperty());
     override.setJoinEntityClass(adornedTargetCollection.joinEntityClass());
     override.setCustomCriteria(adornedTargetCollection.customCriteria());
     override.setUseServerSideInspectionCache(
         adornedTargetCollection.useServerSideInspectionCache());
     override.setExcluded(adornedTargetCollection.excluded());
     override.setFriendlyName(adornedTargetCollection.friendlyName());
     override.setReadOnly(adornedTargetCollection.readOnly());
     override.setOrder(adornedTargetCollection.order());
     override.setTab(adornedTargetCollection.tab());
     override.setTabOrder(adornedTargetCollection.tabOrder());
     override.setSecurityLevel(adornedTargetCollection.securityLevel());
     override.setAddType(adornedTargetCollection.operationTypes().addType());
     override.setFetchType(adornedTargetCollection.operationTypes().fetchType());
     override.setRemoveType(adornedTargetCollection.operationTypes().removeType());
     override.setUpdateType(adornedTargetCollection.operationTypes().updateType());
     override.setInspectType(adornedTargetCollection.operationTypes().inspectType());
     override.setShowIfProperty(adornedTargetCollection.showIfProperty());
     override.setCurrencyCodeField(adornedTargetCollection.currencyCodeField());
     return override;
   }
   throw new IllegalArgumentException(
       "AdminPresentationAdornedTargetCollection annotation not found on field.");
 }
  protected FieldMetadataOverride overrideAdornedTargetMergeMetadata(
      AdminPresentationMergeOverride merge) {
    FieldMetadataOverride fieldMetadataOverride = new FieldMetadataOverride();
    Map<String, AdminPresentationMergeEntry> overrideValues =
        getAdminPresentationEntries(merge.mergeEntries());
    for (Map.Entry<String, AdminPresentationMergeEntry> entry : overrideValues.entrySet()) {
      String stringValue = entry.getValue().overrideValue();
      if (entry
          .getKey()
          .equals(PropertyType.AdminPresentationAdornedTargetCollection.CURRENCYCODEFIELD)) {
        fieldMetadataOverride.setCurrencyCodeField(stringValue);
      } else if (entry
          .getKey()
          .equals(PropertyType.AdminPresentationAdornedTargetCollection.CUSTOMCRITERIA)) {
        fieldMetadataOverride.setCustomCriteria(entry.getValue().stringArrayOverrideValue());
      } else if (entry
          .getKey()
          .equals(PropertyType.AdminPresentationAdornedTargetCollection.EXCLUDED)) {
        fieldMetadataOverride.setExcluded(
            StringUtils.isEmpty(stringValue)
                ? entry.getValue().booleanOverrideValue()
                : Boolean.parseBoolean(stringValue));
      } else if (entry
          .getKey()
          .equals(PropertyType.AdminPresentationAdornedTargetCollection.FRIENDLYNAME)) {
        fieldMetadataOverride.setFriendlyName(stringValue);
      } else if (entry
          .getKey()
          .equals(PropertyType.AdminPresentationAdornedTargetCollection.GRIDVISIBLEFIELDS)) {
        fieldMetadataOverride.setGridVisibleFields(entry.getValue().stringArrayOverrideValue());
      } else if (entry
          .getKey()
          .equals(PropertyType.AdminPresentationAdornedTargetCollection.IGNOREADORNEDPROPERTIES)) {
        fieldMetadataOverride.setIgnoreAdornedProperties(
            StringUtils.isEmpty(stringValue)
                ? entry.getValue().booleanOverrideValue()
                : Boolean.parseBoolean(stringValue));
      } else if (entry
          .getKey()
          .equals(PropertyType.AdminPresentationAdornedTargetCollection.JOINENTITYCLASS)) {
        fieldMetadataOverride.setJoinEntityClass(stringValue);
      } else if (entry
          .getKey()
          .equals(
              PropertyType.AdminPresentationAdornedTargetCollection
                  .MAINTAINEDADORNEDTARGETFIELDS)) {
        fieldMetadataOverride.setMaintainedAdornedTargetFields(
            entry.getValue().stringArrayOverrideValue());
      } else if (entry
          .getKey()
          .equals(PropertyType.AdminPresentationAdornedTargetCollection.OPERATIONTYPES)) {
        AdminPresentationOperationTypes operationType = entry.getValue().operationTypes();
        fieldMetadataOverride.setAddType(operationType.addType());
        fieldMetadataOverride.setRemoveType(operationType.removeType());
        fieldMetadataOverride.setUpdateType(operationType.updateType());
        fieldMetadataOverride.setFetchType(operationType.fetchType());
        fieldMetadataOverride.setInspectType(operationType.inspectType());
      } else if (entry
          .getKey()
          .equals(PropertyType.AdminPresentationAdornedTargetCollection.ORDER)) {
        fieldMetadataOverride.setOrder(
            StringUtils.isEmpty(stringValue)
                ? entry.getValue().intOverrideValue()
                : Integer.parseInt(stringValue));
      } else if (entry
          .getKey()
          .equals(PropertyType.AdminPresentationAdornedTargetCollection.PARENTOBJECTIDPROPERTY)) {
        fieldMetadataOverride.setParentObjectIdProperty(stringValue);
      } else if (entry
          .getKey()
          .equals(PropertyType.AdminPresentationAdornedTargetCollection.PARENTOBJECTPROPERTY)) {
        fieldMetadataOverride.setParentObjectProperty(stringValue);
      } else if (entry
          .getKey()
          .equals(PropertyType.AdminPresentationAdornedTargetCollection.READONLY)) {
        fieldMetadataOverride.setReadOnly(
            StringUtils.isEmpty(stringValue)
                ? entry.getValue().booleanOverrideValue()
                : Boolean.parseBoolean(stringValue));
      } else if (entry
          .getKey()
          .equals(PropertyType.AdminPresentationAdornedTargetCollection.SECURITYLEVEL)) {
        fieldMetadataOverride.setSecurityLevel(stringValue);
      } else if (entry
          .getKey()
          .equals(PropertyType.AdminPresentationAdornedTargetCollection.SHOWIFPROPERTY)) {
        fieldMetadataOverride.setShowIfProperty(stringValue);
      } else if (entry
          .getKey()
          .equals(PropertyType.AdminPresentationAdornedTargetCollection.SORTASCENDING)) {
        fieldMetadataOverride.setSortAscending(
            StringUtils.isEmpty(stringValue)
                ? entry.getValue().booleanOverrideValue()
                : Boolean.parseBoolean(stringValue));
      } else if (entry
          .getKey()
          .equals(PropertyType.AdminPresentationAdornedTargetCollection.SORTPROPERTY)) {
        fieldMetadataOverride.setSortProperty(stringValue);
      } else if (entry.getKey().equals(PropertyType.AdminPresentationAdornedTargetCollection.TAB)) {
        fieldMetadataOverride.setTab(stringValue);
      } else if (entry
          .getKey()
          .equals(PropertyType.AdminPresentationAdornedTargetCollection.TABORDER)) {
        fieldMetadataOverride.setTabOrder(
            StringUtils.isEmpty(stringValue)
                ? entry.getValue().intOverrideValue()
                : Integer.parseInt(stringValue));
      } else if (entry
          .getKey()
          .equals(PropertyType.AdminPresentationAdornedTargetCollection.TARGETOBJECTIDPROPERTY)) {
        fieldMetadataOverride.setTargetObjectIdProperty(stringValue);
      } else if (entry
          .getKey()
          .equals(PropertyType.AdminPresentationAdornedTargetCollection.TARGETOBJECTPROPERTY)) {
        fieldMetadataOverride.setTargetObjectProperty(stringValue);
      } else if (entry
          .getKey()
          .equals(
              PropertyType.AdminPresentationAdornedTargetCollection.USESERVERSIDEINSPECTIONCACHE)) {
        fieldMetadataOverride.setUseServerSideInspectionCache(
            StringUtils.isEmpty(stringValue)
                ? entry.getValue().booleanOverrideValue()
                : Boolean.parseBoolean(stringValue));
      } else {
        if (LOG.isDebugEnabled()) {
          LOG.debug(
              "Unrecognized type: " + entry.getKey() + ". Not setting on adorned target field.");
        }
      }
    }

    return fieldMetadataOverride;
  }