001package com.example.metaschema;
002
003import gov.nist.secauto.metaschema.core.model.IBoundObject;
004import gov.nist.secauto.metaschema.core.model.IMetaschemaData;
005import gov.nist.secauto.metaschema.core.model.JsonGroupAsBehavior;
006import gov.nist.secauto.metaschema.core.util.ObjectUtils;
007import gov.nist.secauto.metaschema.databind.model.annotations.BoundAssembly;
008import gov.nist.secauto.metaschema.databind.model.annotations.BoundField;
009import gov.nist.secauto.metaschema.databind.model.annotations.GroupAs;
010import gov.nist.secauto.metaschema.databind.model.annotations.MetaschemaAssembly;
011import java.lang.Override;
012import java.lang.String;
013import java.util.LinkedList;
014import java.util.List;
015import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
016import org.apache.commons.lang3.builder.ToStringStyle;
017
018@MetaschemaAssembly(
019    name = "metapath-context",
020    moduleClass = MetaschemaModelModule.class
021)
022public class MetapathContext implements IBoundObject {
023  private final IMetaschemaData __metaschemaData;
024
025  @BoundAssembly(
026      description = "A Metapath expression identifying the model node that the constraints will be applied to.",
027      useName = "metapath",
028      minOccurs = 1,
029      maxOccurs = -1,
030      groupAs = @GroupAs(name = "metapaths", inJson = JsonGroupAsBehavior.LIST)
031  )
032  private List<MetaschemaMetapath> _metapaths;
033
034  @BoundAssembly(
035      useName = "constraints"
036  )
037  private AssemblyConstraints _constraints;
038
039  @BoundAssembly(
040      useName = "context",
041      maxOccurs = -1,
042      groupAs = @GroupAs(name = "contexts", inJson = JsonGroupAsBehavior.LIST)
043  )
044  private List<MetapathContext> _contexts;
045
046  @BoundField(
047      formalName = "Remarks",
048      description = "Any explanatory or helpful information to be provided about the remarks parent.",
049      useName = "remarks"
050  )
051  private Remarks _remarks;
052
053  public MetapathContext() {
054    this(null);
055  }
056
057  public MetapathContext(IMetaschemaData data) {
058    this.__metaschemaData = data;
059  }
060
061  @Override
062  public IMetaschemaData getMetaschemaData() {
063    return __metaschemaData;
064  }
065
066  public List<MetaschemaMetapath> getMetapaths() {
067    return _metapaths;
068  }
069
070  public void setMetapaths(List<MetaschemaMetapath> value) {
071    _metapaths = value;
072  }
073
074  /**
075   * Add a new {@link MetaschemaMetapath} item to the underlying collection.
076   * @param item the item to add
077   * @return {@code true}
078   */
079  public boolean addMetapath(MetaschemaMetapath item) {
080    MetaschemaMetapath value = ObjectUtils.requireNonNull(item,"item cannot be null");
081    if (_metapaths == null) {
082      _metapaths = new LinkedList<>();
083    }
084    return _metapaths.add(value);
085  }
086
087  /**
088   * Remove the first matching {@link MetaschemaMetapath} item from the underlying collection.
089   * @param item the item to remove
090   * @return {@code true} if the item was removed or {@code false} otherwise
091   */
092  public boolean removeMetapath(MetaschemaMetapath item) {
093    MetaschemaMetapath value = ObjectUtils.requireNonNull(item,"item cannot be null");
094    return _metapaths != null && _metapaths.remove(value);
095  }
096
097  public AssemblyConstraints getConstraints() {
098    return _constraints;
099  }
100
101  public void setConstraints(AssemblyConstraints value) {
102    _constraints = value;
103  }
104
105  public List<MetapathContext> getContexts() {
106    return _contexts;
107  }
108
109  public void setContexts(List<MetapathContext> value) {
110    _contexts = value;
111  }
112
113  /**
114   * Add a new {@link MetapathContext} item to the underlying collection.
115   * @param item the item to add
116   * @return {@code true}
117   */
118  public boolean addContext(MetapathContext item) {
119    MetapathContext value = ObjectUtils.requireNonNull(item,"item cannot be null");
120    if (_contexts == null) {
121      _contexts = new LinkedList<>();
122    }
123    return _contexts.add(value);
124  }
125
126  /**
127   * Remove the first matching {@link MetapathContext} item from the underlying collection.
128   * @param item the item to remove
129   * @return {@code true} if the item was removed or {@code false} otherwise
130   */
131  public boolean removeContext(MetapathContext item) {
132    MetapathContext value = ObjectUtils.requireNonNull(item,"item cannot be null");
133    return _contexts != null && _contexts.remove(value);
134  }
135
136  public Remarks getRemarks() {
137    return _remarks;
138  }
139
140  public void setRemarks(Remarks value) {
141    _remarks = value;
142  }
143
144  @Override
145  public String toString() {
146    return new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString();
147  }
148}