XmlGroupedFieldInstance.java
/*
* SPDX-FileCopyrightText: none
* SPDX-License-Identifier: CC0-1.0
*/
package gov.nist.secauto.metaschema.core.model.xml.impl;
import gov.nist.secauto.metaschema.core.datatype.markup.MarkupLine;
import gov.nist.secauto.metaschema.core.datatype.markup.MarkupMultiline;
import gov.nist.secauto.metaschema.core.model.AbstractFieldInstance;
import gov.nist.secauto.metaschema.core.model.IAssemblyDefinition;
import gov.nist.secauto.metaschema.core.model.IAttributable;
import gov.nist.secauto.metaschema.core.model.IChoiceGroupInstance;
import gov.nist.secauto.metaschema.core.model.IFieldDefinition;
import gov.nist.secauto.metaschema.core.model.IFieldInstanceGrouped;
import gov.nist.secauto.metaschema.core.model.xml.xmlbeans.GroupedFieldReferenceType;
import gov.nist.secauto.metaschema.core.model.xml.xmlbeans.UseNameType;
import gov.nist.secauto.metaschema.core.util.CollectionUtil;
import gov.nist.secauto.metaschema.core.util.ObjectUtils;
import java.util.Map;
import java.util.Set;
import edu.umd.cs.findbugs.annotations.NonNull;
public class XmlGroupedFieldInstance
extends AbstractFieldInstance<IChoiceGroupInstance, IFieldDefinition, IFieldInstanceGrouped, IAssemblyDefinition>
implements IFieldInstanceGrouped {
@NonNull
private final GroupedFieldReferenceType xmlObject;
/**
* Constructs a new Metaschema field definition from an XML representation bound
* to Java objects.
*
* @param xmlObject
* the XML representation bound to Java objects
* @param parent
* the parent container, either a choice or assembly
*/
@SuppressWarnings("PMD.NullAssignment")
public XmlGroupedFieldInstance(
@NonNull GroupedFieldReferenceType xmlObject,
@NonNull IChoiceGroupInstance parent) {
super(parent);
this.xmlObject = xmlObject;
}
// ----------------------------------------
// - Start XmlBeans driven code - CPD-OFF -
// ----------------------------------------
/**
* Get the underlying XML data.
*
* @return the underlying XML data
*/
@NonNull
protected GroupedFieldReferenceType getXmlObject() {
return xmlObject;
}
@Override
public String getFormalName() {
return getXmlObject().isSetFormalName() ? getXmlObject().getFormalName() : null;
}
@Override
public MarkupLine getDescription() {
return getXmlObject().isSetDescription()
? MarkupStringConverter.toMarkupString(ObjectUtils.notNull(getXmlObject().getDescription()))
: null;
}
@Override
public Map<IAttributable.Key, Set<String>> getProperties() {
return ModelFactory.toProperties(CollectionUtil.listOrEmpty(getXmlObject().getPropList()));
}
@Override
public String getName() {
return ObjectUtils.requireNonNull(getXmlObject().getRef());
}
@Override
public String getUseName() {
return getXmlObject().isSetUseName() ? getXmlObject().getUseName().getStringValue() : null;
}
@Override
public Integer getUseIndex() {
Integer retval = null;
if (getXmlObject().isSetUseName()) {
UseNameType useName = getXmlObject().getUseName();
if (useName.isSetIndex()) {
retval = useName.getIndex().intValue();
}
}
return retval;
}
@Override
public MarkupMultiline getRemarks() {
return getXmlObject().isSetRemarks()
? MarkupStringConverter.toMarkupString(ObjectUtils.notNull(getXmlObject().getRemarks()))
: null;
}
@Override
public String getDiscriminatorValue() {
return getXmlObject().getDiscriminatorValue();
}
// -------------------------------------
// - End XmlBeans driven code - CPD-ON -
// -------------------------------------
}