4545 */
4646public class ExceptionJson {
4747
48+ /**
49+ * All property descriptors for Exceptions
50+ */
4851 public static final List <PropertyDescriptor > ALL_PROPERTY_DESCRIPTORS ;
52+
53+ /**
54+ * Map of property descriptors to the value name
55+ */
4956 public static final Map <PropertyDescriptor , String > PROPERTY_DESCRIPTOR_TO_VALUE_NAME ;
57+
58+ /**
59+ * Properties which are collections
60+ */
5061 static final Set <PropertyDescriptor > COLLECTION_PROPERTIES ;
5162
5263 static {
@@ -110,18 +121,36 @@ public class ExceptionJson {
110121 String obsoletedBy ;
111122 String listVersionAdded ;
112123
124+ /**
125+ * Create an ExceptionJson
126+ * @param id license exception ID
127+ */
113128 public ExceptionJson (String id ) {
114129 this .licenseExceptionId = id ;
115130 }
116131
132+ /**
133+ * Create an ExceptionJson
134+ */
117135 public ExceptionJson () {
118136
119137 }
120138
139+ /**
140+ * @param propertyName property name
141+ * @param valueId ID for the value
142+ * @param type SPDX type
143+ * @throws InvalidSpdxPropertyException on invalid type for the SPDX property
144+ */
121145 public void setTypedProperty (String propertyName , String valueId , String type ) throws InvalidSpdxPropertyException {
122146 throw new InvalidSpdxPropertyException ("Invalid type for Listed License SPDX Property: " +type );
123147 }
124148
149+ /**
150+ * @param propertyDescriptor descriptor for the property to be set
151+ * @param value value to set
152+ * @throws InvalidSpdxPropertyException on invalid property
153+ */
125154 public void setPrimativeValue (PropertyDescriptor propertyDescriptor , Object value ) throws InvalidSpdxPropertyException {
126155 String propertyName = PROPERTY_DESCRIPTOR_TO_VALUE_NAME .get (propertyDescriptor );
127156 if (Objects .isNull (propertyName )) {
@@ -206,17 +235,34 @@ public void setPrimativeValue(PropertyDescriptor propertyDescriptor, Object valu
206235 }
207236 }
208237
238+ /**
239+ * Clears a list of values for a property
240+ * @param propertyDescriptor descriptor for the property
241+ * @throws InvalidSpdxPropertyException if it is not a list type
242+ */
209243 public void clearPropertyValueList (PropertyDescriptor propertyDescriptor ) throws InvalidSpdxPropertyException {
210244 if (!"seeAlso" .equals (PROPERTY_DESCRIPTOR_TO_VALUE_NAME .get (propertyDescriptor ))) {
211245 throw new InvalidSpdxPropertyException (propertyDescriptor + "is not a list type" );
212246 }
213247 seeAlso .clear ();
214248 }
215249
250+ /**
251+ * @param propertyName Name of the property
252+ * @param valueId ID for the value
253+ * @param type SPDX type
254+ * @throws InvalidSpdxPropertyException on invalid type to add a value
255+ */
216256 public void addValueToList (String propertyName , String valueId , String type ) throws InvalidSpdxPropertyException {
217257 throw new InvalidSpdxPropertyException ("Invalid type for Listed License SPDX Property: " +type );
218258 }
219259
260+ /**
261+ * @param propertyDescriptor descriptor for the property
262+ * @param value Value to set
263+ * @return true if the value was added
264+ * @throws InvalidSpdxPropertyException
265+ */
220266 public boolean addPrimitiveValueToList (PropertyDescriptor propertyDescriptor , Object value ) throws InvalidSpdxPropertyException {
221267 if (!"seeAlso" .equals (PROPERTY_DESCRIPTOR_TO_VALUE_NAME .get (propertyDescriptor ))) {
222268 throw new InvalidSpdxPropertyException (propertyDescriptor + "is not a list type" );
@@ -227,6 +273,11 @@ public boolean addPrimitiveValueToList(PropertyDescriptor propertyDescriptor, Ob
227273 return seeAlso .add ((String )value );
228274 }
229275
276+ /**
277+ * @param propertyDescriptor descriptor for the property
278+ * @return list of values associated with the property
279+ * @throws InvalidSpdxPropertyException if the propertyDescriptor is not for a list type
280+ */
230281 public List <?> getValueList (PropertyDescriptor propertyDescriptor ) throws InvalidSpdxPropertyException {
231282 if ("seeAlso" .equals (PROPERTY_DESCRIPTOR_TO_VALUE_NAME .get (propertyDescriptor ))) {
232283 return seeAlso ;
@@ -237,6 +288,11 @@ public List<?> getValueList(PropertyDescriptor propertyDescriptor) throws Invali
237288 }
238289 }
239290
291+ /**
292+ * @param propertyDescriptor descriptor for the property
293+ * @return Value associated with the property or null if no value was set
294+ * @throws InvalidSpdxPropertyException if the property descriptor is not valid
295+ */
240296 public Object getValue (PropertyDescriptor propertyDescriptor ) throws InvalidSpdxPropertyException {
241297 String propertyName = PROPERTY_DESCRIPTOR_TO_VALUE_NAME .get (propertyDescriptor );
242298 if (Objects .isNull (propertyName )) {
@@ -262,6 +318,11 @@ public Object getValue(PropertyDescriptor propertyDescriptor) throws InvalidSpdx
262318 }
263319 }
264320
321+ /**
322+ * Removes the property
323+ * @param propertyDescriptor descriptor for the property
324+ * @throws InvalidSpdxPropertyException if the property descriptor is not valid
325+ */
265326 public void removeProperty (PropertyDescriptor propertyDescriptor ) throws InvalidSpdxPropertyException {
266327 String propertyName = PROPERTY_DESCRIPTOR_TO_VALUE_NAME .get (propertyDescriptor );
267328 if (Objects .isNull (propertyName )) {
@@ -288,6 +349,11 @@ public void removeProperty(PropertyDescriptor propertyDescriptor) throws Invalid
288349
289350 }
290351
352+ /**
353+ * Copies all properties from an exception
354+ * @param fromException exception to copy from
355+ * @throws InvalidSPDXAnalysisException on error getting values from the exception
356+ */
291357 public void copyFrom (ListedLicenseException fromException ) throws InvalidSPDXAnalysisException {
292358 Optional <String > comment = fromException .getComment ();
293359 this .comment = comment .orElse (null );
@@ -303,6 +369,11 @@ public void copyFrom(ListedLicenseException fromException) throws InvalidSPDXAna
303369 this .licenseXml = fromException .getLicenseXml ().orElse (null );
304370 }
305371
372+ /**
373+ * Copies from an SPDX version 2 exception
374+ * @param fromException exception to copy from
375+ * @throws InvalidSPDXAnalysisException on error getting values from the exception
376+ */
306377 @ SuppressWarnings ("deprecation" )
307378 public void copyFrom (org .spdx .library .model .v2 .license .ListedLicenseException fromException ) throws InvalidSPDXAnalysisException {
308379 this .comment = null ;
@@ -339,13 +410,25 @@ public void copyFrom(org.spdx.library.model.v2.license.ListedLicenseException fr
339410 }
340411 }
341412
413+ /**
414+ * @param propertyDescriptor descriptor for the property
415+ * @param value value to remove
416+ * @return true if the collection was modified
417+ * @throws InvalidSpdxPropertyException if the propertyDescriptor is not valid
418+ */
342419 public boolean removePrimitiveValueToList (PropertyDescriptor propertyDescriptor , Object value ) throws InvalidSpdxPropertyException {
343420 if (!"seeAlso" .equals (PROPERTY_DESCRIPTOR_TO_VALUE_NAME .get (propertyDescriptor ))) {
344421 throw new InvalidSpdxPropertyException (propertyDescriptor + "is not a list type" );
345422 }
346423 return seeAlso .remove (value );
347424 }
348425
426+ /**
427+ * @param propertyDescriptor descriptor for the property
428+ * @param clazz class to test assignability
429+ * @return true if the propertyDescriptor can be assigned a value of type clazz
430+ * @throws InvalidSpdxPropertyException if the propertyDescriptor is not valid
431+ */
349432 public boolean isPropertyValueAssignableTo (PropertyDescriptor propertyDescriptor , Class <?> clazz ) throws InvalidSpdxPropertyException {
350433 String propertyName = PROPERTY_DESCRIPTOR_TO_VALUE_NAME .get (propertyDescriptor );
351434 if (Objects .isNull (propertyName )) {
@@ -369,6 +452,11 @@ public boolean isPropertyValueAssignableTo(PropertyDescriptor propertyDescriptor
369452 }
370453 }
371454
455+ /**
456+ * @param propertyDescriptor descriptor for the property
457+ * @param clazz class to test assignability
458+ * @return true if the list associated with the propertyDescriptor have a value added of type clazz
459+ */
372460 public boolean isCollectionMembersAssignableTo (PropertyDescriptor propertyDescriptor , Class <?> clazz ) {
373461 if (SpdxConstantsCompatV2 .RDFS_PROP_SEE_ALSO .equals (propertyDescriptor ) ||
374462 SpdxConstantsV3 .PROP_SEE_ALSO .equals (propertyDescriptor )) {
@@ -388,6 +476,10 @@ public boolean isCollectionMembersAssignableTo(PropertyDescriptor propertyDescri
388476 }
389477 }
390478
479+ /**
480+ * @param propertyDescriptor descriptor for the property
481+ * @return true if the property represents a collection
482+ */
391483 public boolean isCollectionProperty (PropertyDescriptor propertyDescriptor ) {
392484 return COLLECTION_PROPERTIES .contains (propertyDescriptor );
393485 }
0 commit comments