001package org.schemastore.json.sarif.x210; 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.BoundField; 008import gov.nist.secauto.metaschema.databind.model.annotations.GroupAs; 009import gov.nist.secauto.metaschema.databind.model.annotations.MetaschemaAssembly; 010import java.lang.Override; 011import java.lang.String; 012import java.util.LinkedList; 013import java.util.List; 014import org.apache.commons.lang3.builder.ReflectionToStringBuilder; 015import org.apache.commons.lang3.builder.ToStringStyle; 016 017/** 018 * Key/value pairs that provide additional information about the object. 019 */ 020@MetaschemaAssembly( 021 formalName = "Property Bag", 022 description = "Key/value pairs that provide additional information about the object.", 023 name = "propertyBag", 024 moduleClass = SarifModule.class 025) 026public class PropertyBag implements IBoundObject { 027 private final IMetaschemaData __metaschemaData; 028 029 @BoundField( 030 formalName = "Tag", 031 description = "A set of distinct strings that provide additional information.", 032 useName = "tag", 033 maxOccurs = -1, 034 groupAs = @GroupAs(name = "tags", inJson = JsonGroupAsBehavior.LIST) 035 ) 036 private List<String> _tags; 037 038 public PropertyBag() { 039 this(null); 040 } 041 042 public PropertyBag(IMetaschemaData data) { 043 this.__metaschemaData = data; 044 } 045 046 @Override 047 public IMetaschemaData getMetaschemaData() { 048 return __metaschemaData; 049 } 050 051 public List<String> getTags() { 052 return _tags; 053 } 054 055 public void setTags(List<String> value) { 056 _tags = value; 057 } 058 059 /** 060 * Add a new {@link String} item to the underlying collection. 061 * @param item the item to add 062 * @return {@code true} 063 */ 064 public boolean addTag(String item) { 065 String value = ObjectUtils.requireNonNull(item,"item cannot be null"); 066 if (_tags == null) { 067 _tags = new LinkedList<>(); 068 } 069 return _tags.add(value); 070 } 071 072 /** 073 * Remove the first matching {@link String} item from the underlying collection. 074 * @param item the item to remove 075 * @return {@code true} if the item was removed or {@code false} otherwise 076 */ 077 public boolean removeTag(String item) { 078 String value = ObjectUtils.requireNonNull(item,"item cannot be null"); 079 return _tags != null && _tags.remove(value); 080 } 081 082 @Override 083 public String toString() { 084 return new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString(); 085 } 086}