in objectModel/Java/objectmodel/src/main/java/com/microsoft/commondatamodel/objectmodel/cdm/CdmAttributeResolutionGuidance.java [462:626]
public CdmAttributeResolutionGuidance combineResolutionGuidance(
final CdmAttributeResolutionGuidance addIn) {
final CdmAttributeResolutionGuidance startWith = this;
if (addIn == null) {
return startWith;
}
if (startWith == null) {
return addIn;
}
final CdmAttributeResolutionGuidance result = new CdmAttributeResolutionGuidance(getCtx());
// can remove and then un-remove later
if (startWith.removeAttribute != null && startWith.removeAttribute) {
if (addIn.removeAttribute == null || addIn.removeAttribute) {
result.removeAttribute = true;
}
} else {
if (addIn.removeAttribute != null && addIn.removeAttribute) {
result.removeAttribute = true;
}
}
// copy and combine if needed
if (addIn.imposedDirectives != null) {
if (startWith.imposedDirectives != null) {
result.imposedDirectives = new ArrayList<>(startWith.imposedDirectives);
} else {
result.imposedDirectives = new ArrayList<>();
}
result.imposedDirectives.addAll(addIn.imposedDirectives);
} else {
result.imposedDirectives = startWith.imposedDirectives;
}
if (addIn.removedDirectives != null) {
if (startWith.removedDirectives != null) {
result.removedDirectives = new ArrayList<>(startWith.removedDirectives);
} else {
result.removedDirectives = new ArrayList<>();
}
result.removedDirectives.addAll(addIn.removedDirectives);
} else {
result.removedDirectives = startWith.removedDirectives;
}
result.addSupportingAttribute = startWith.addSupportingAttribute;
if (addIn.addSupportingAttribute != null) {
result.addSupportingAttribute = addIn.addSupportingAttribute;
}
result.cardinality = startWith.cardinality;
if (addIn.cardinality != null) {
result.cardinality = addIn.cardinality;
}
result.renameFormat = startWith.renameFormat;
if (addIn.renameFormat != null) {
result.renameFormat = addIn.renameFormat;
}
// for these sub objects, ok to just use the same objects unless something is combined. assumption is that these are static during the resolution
if (addIn.expansion != null) {
if (startWith.expansion != null) {
result.expansion = new Expansion();
result.expansion.setStartingOrdinal(startWith.expansion.getStartingOrdinal());
if (addIn.expansion.getStartingOrdinal() != null) {
result.expansion.setStartingOrdinal(addIn.expansion.getStartingOrdinal());
}
result.expansion.setMaximumExpansion(startWith.expansion.getMaximumExpansion());
if (addIn.expansion.getMaximumExpansion() != null) {
result.expansion.setMaximumExpansion(addIn.expansion.getMaximumExpansion());
}
result.expansion.setCountAttribute(startWith.expansion.getCountAttribute());
if (addIn.expansion.getCountAttribute() != null) {
result.expansion.setCountAttribute(addIn.expansion.getCountAttribute());
}
} else {
result.expansion = addIn.expansion;
}
} else {
result.expansion = startWith.expansion;
}
if (addIn.entityByReference != null) {
if (startWith.entityByReference != null) {
result.entityByReference = new EntityByReference();
result.entityByReference
.setAlwaysIncludeForeignKey(startWith.entityByReference.doesAlwaysIncludeForeignKey());
if (addIn.entityByReference.doesAlwaysIncludeForeignKey() != null) {
result.entityByReference
.setAlwaysIncludeForeignKey(addIn.entityByReference.doesAlwaysIncludeForeignKey());
}
result.entityByReference
.setReferenceOnlyAfterDepth(startWith.entityByReference.getReferenceOnlyAfterDepth());
if (addIn.entityByReference.getReferenceOnlyAfterDepth() != null) {
result.entityByReference
.setReferenceOnlyAfterDepth(addIn.entityByReference.getReferenceOnlyAfterDepth());
}
result.entityByReference
.setForeignKeyAttribute(startWith.entityByReference.getForeignKeyAttribute());
if (addIn.entityByReference.getForeignKeyAttribute() != null) {
result.entityByReference
.setForeignKeyAttribute(addIn.entityByReference.getForeignKeyAttribute());
}
result.entityByReference
.setAllowReference(startWith.entityByReference.doesAllowReference());
if (addIn.entityByReference.doesAllowReference() != null) {
result.entityByReference.setAllowReference(addIn.entityByReference.doesAllowReference());
}
} else {
result.entityByReference = addIn.entityByReference;
}
} else {
result.entityByReference = startWith.entityByReference;
}
if (addIn.selectsSubAttribute != null) {
if (startWith.selectsSubAttribute != null) {
result.selectsSubAttribute = new SelectsSubAttribute();
result.selectsSubAttribute
.setSelectedTypeAttribute(startWith.selectsSubAttribute.getSelectedTypeAttribute());
if (addIn.selectsSubAttribute.getSelectedTypeAttribute() != null) {
result.selectsSubAttribute
.setSelectedTypeAttribute(addIn.selectsSubAttribute.getSelectedTypeAttribute());
}
result.selectsSubAttribute.setSelects(startWith.selectsSubAttribute.getSelects());
if (addIn.selectsSubAttribute.getSelects() != null) {
result.selectsSubAttribute.setSelects(addIn.selectsSubAttribute.getSelects());
}
if (addIn.selectsSubAttribute.getSelectsSomeTakeNames() != null) {
if (startWith.selectsSubAttribute.getSelectsSomeTakeNames() != null) {
result.selectsSubAttribute.setSelectsSomeTakeNames(
new ArrayList<>(startWith.selectsSubAttribute.getSelectsSomeTakeNames()));
} else {
result.selectsSubAttribute.setSelectsSomeTakeNames(new ArrayList<>());
}
result.selectsSubAttribute.getSelectsSomeTakeNames().addAll(addIn.selectsSubAttribute.getSelectsSomeTakeNames());
}
if (addIn.selectsSubAttribute.getSelectsSomeAvoidNames() != null) {
if (startWith.selectsSubAttribute.getSelectsSomeAvoidNames() != null) {
result.selectsSubAttribute.setSelectsSomeAvoidNames(
new ArrayList<>(startWith.selectsSubAttribute.getSelectsSomeAvoidNames()));
} else {
result.selectsSubAttribute.setSelectsSomeAvoidNames(new ArrayList<>());
}
result.selectsSubAttribute.getSelectsSomeAvoidNames().addAll(addIn.selectsSubAttribute.getSelectsSomeAvoidNames());
}
} else {
result.selectsSubAttribute = addIn.selectsSubAttribute;
}
} else {
result.selectsSubAttribute = startWith.selectsSubAttribute;
}
return result;
}