Message.java
package org.schemastore.json.sarif.x210;
import gov.nist.secauto.metaschema.core.datatype.adapter.StringAdapter;
import gov.nist.secauto.metaschema.core.model.IBoundObject;
import gov.nist.secauto.metaschema.core.model.IMetaschemaData;
import gov.nist.secauto.metaschema.core.model.JsonGroupAsBehavior;
import gov.nist.secauto.metaschema.core.model.constraint.IConstraint;
import gov.nist.secauto.metaschema.core.util.ObjectUtils;
import gov.nist.secauto.metaschema.databind.model.annotations.BoundField;
import gov.nist.secauto.metaschema.databind.model.annotations.BoundFlag;
import gov.nist.secauto.metaschema.databind.model.annotations.Expect;
import gov.nist.secauto.metaschema.databind.model.annotations.GroupAs;
import gov.nist.secauto.metaschema.databind.model.annotations.MetaschemaAssembly;
import gov.nist.secauto.metaschema.databind.model.annotations.ValueConstraints;
import java.lang.Override;
import java.lang.String;
import java.util.LinkedList;
import java.util.List;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* Encapsulates a message intended to be read by the end user.
*/
@MetaschemaAssembly(
formalName = "Message",
description = "Encapsulates a message intended to be read by the end user.",
name = "message",
moduleClass = SarifModule.class,
valueConstraints = @ValueConstraints(expect = @Expect(level = IConstraint.Level.ERROR, test = "exists(@id|text)", message = "At least one id or text must be provided."))
)
public class Message implements IBoundObject {
private final IMetaschemaData __metaschemaData;
/**
* "The id of the message."
*/
@BoundFlag(
formalName = "Message Identifier",
description = "The id of the message.",
name = "id",
required = true,
typeAdapter = StringAdapter.class
)
private String _id;
@BoundField(
formalName = "Text",
description = "A plain text message string.",
useName = "text"
)
private String _text;
@BoundField(
formalName = "Markdown",
description = "A Markdown message string.",
useName = "markdown"
)
private String _markdown;
@BoundField(
formalName = "Argument",
description = "A sequence of strings to substitute into the message string.",
useName = "argument",
maxOccurs = -1,
groupAs = @GroupAs(name = "arguments", inJson = JsonGroupAsBehavior.LIST)
)
private List<String> _arguments;
public Message() {
this(null);
}
public Message(IMetaschemaData data) {
this.__metaschemaData = data;
}
@Override
public IMetaschemaData getMetaschemaData() {
return __metaschemaData;
}
public String getId() {
return _id;
}
public void setId(String value) {
_id = value;
}
public String getText() {
return _text;
}
public void setText(String value) {
_text = value;
}
public String getMarkdown() {
return _markdown;
}
public void setMarkdown(String value) {
_markdown = value;
}
public List<String> getArguments() {
return _arguments;
}
public void setArguments(List<String> value) {
_arguments = value;
}
/**
* Add a new {@link String} item to the underlying collection.
* @param item the item to add
* @return {@code true}
*/
public boolean addArgument(String item) {
String value = ObjectUtils.requireNonNull(item,"item cannot be null");
if (_arguments == null) {
_arguments = new LinkedList<>();
}
return _arguments.add(value);
}
/**
* Remove the first matching {@link String} item from the underlying collection.
* @param item the item to remove
* @return {@code true} if the item was removed or {@code false} otherwise
*/
public boolean removeArgument(String item) {
String value = ObjectUtils.requireNonNull(item,"item cannot be null");
return _arguments != null && _arguments.remove(value);
}
@Override
public String toString() {
return new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString();
}
}