001package org.schemastore.json.sarif.x210; 002 003import gov.nist.secauto.metaschema.core.datatype.adapter.IntegerAdapter; 004import gov.nist.secauto.metaschema.core.model.IBoundObject; 005import gov.nist.secauto.metaschema.core.model.IMetaschemaData; 006import gov.nist.secauto.metaschema.core.model.JsonGroupAsBehavior; 007import gov.nist.secauto.metaschema.core.model.constraint.IConstraint; 008import gov.nist.secauto.metaschema.core.util.ObjectUtils; 009import gov.nist.secauto.metaschema.databind.model.annotations.BoundAssembly; 010import gov.nist.secauto.metaschema.databind.model.annotations.BoundFlag; 011import gov.nist.secauto.metaschema.databind.model.annotations.Expect; 012import gov.nist.secauto.metaschema.databind.model.annotations.GroupAs; 013import gov.nist.secauto.metaschema.databind.model.annotations.MetaschemaAssembly; 014import gov.nist.secauto.metaschema.databind.model.annotations.ValueConstraints; 015import java.lang.Override; 016import java.lang.String; 017import java.math.BigInteger; 018import java.util.LinkedList; 019import java.util.List; 020import org.apache.commons.lang3.builder.ReflectionToStringBuilder; 021import org.apache.commons.lang3.builder.ToStringStyle; 022 023/** 024 * A location within a programming artifact. 025 */ 026@MetaschemaAssembly( 027 formalName = "Location", 028 description = "A location within a programming artifact.", 029 name = "location", 030 moduleClass = SarifModule.class, 031 valueConstraints = @ValueConstraints(expect = @Expect(level = IConstraint.Level.ERROR, test = "@id >= -1", message = "The id '{ . }' is not greater than or equal to '-1'.")) 032) 033public class Location implements IBoundObject { 034 private final IMetaschemaData __metaschemaData; 035 036 /** 037 * "A value that distinguishes this location from all other locations within a single result object." 038 */ 039 @BoundFlag( 040 formalName = "Location Identifier", 041 description = "A value that distinguishes this location from all other locations within a single result object.", 042 name = "id", 043 defaultValue = "-1", 044 typeAdapter = IntegerAdapter.class 045 ) 046 private BigInteger _id; 047 048 @BoundAssembly( 049 formalName = "Physical Location", 050 description = "A physical location relevant to a result. Specifies a reference to a programming artifact together with a range of bytes or characters within that artifact.", 051 useName = "physicalLocation" 052 ) 053 private PhysicalLocation _physicalLocation; 054 055 @BoundAssembly( 056 formalName = "Logical Location", 057 description = "The logical locations associated with the result.", 058 useName = "logicalLocation", 059 maxOccurs = -1, 060 groupAs = @GroupAs(name = "logicalLocations", inJson = JsonGroupAsBehavior.LIST) 061 ) 062 private List<LogicalLocation> _logicalLocations; 063 064 @BoundAssembly( 065 formalName = "Location Message", 066 description = "A message relevant to the location.", 067 useName = "message" 068 ) 069 private Message _message; 070 071 public Location() { 072 this(null); 073 } 074 075 public Location(IMetaschemaData data) { 076 this.__metaschemaData = data; 077 } 078 079 @Override 080 public IMetaschemaData getMetaschemaData() { 081 return __metaschemaData; 082 } 083 084 public BigInteger getId() { 085 return _id; 086 } 087 088 public void setId(BigInteger value) { 089 _id = value; 090 } 091 092 public PhysicalLocation getPhysicalLocation() { 093 return _physicalLocation; 094 } 095 096 public void setPhysicalLocation(PhysicalLocation value) { 097 _physicalLocation = value; 098 } 099 100 public List<LogicalLocation> getLogicalLocations() { 101 return _logicalLocations; 102 } 103 104 public void setLogicalLocations(List<LogicalLocation> value) { 105 _logicalLocations = value; 106 } 107 108 /** 109 * Add a new {@link LogicalLocation} item to the underlying collection. 110 * @param item the item to add 111 * @return {@code true} 112 */ 113 public boolean addLogicalLocation(LogicalLocation item) { 114 LogicalLocation value = ObjectUtils.requireNonNull(item,"item cannot be null"); 115 if (_logicalLocations == null) { 116 _logicalLocations = new LinkedList<>(); 117 } 118 return _logicalLocations.add(value); 119 } 120 121 /** 122 * Remove the first matching {@link LogicalLocation} item from the underlying collection. 123 * @param item the item to remove 124 * @return {@code true} if the item was removed or {@code false} otherwise 125 */ 126 public boolean removeLogicalLocation(LogicalLocation item) { 127 LogicalLocation value = ObjectUtils.requireNonNull(item,"item cannot be null"); 128 return _logicalLocations != null && _logicalLocations.remove(value); 129 } 130 131 public Message getMessage() { 132 return _message; 133 } 134 135 public void setMessage(Message value) { 136 _message = value; 137 } 138 139 @Override 140 public String toString() { 141 return new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString(); 142 } 143}