From 45516aa3495f057b618416d70aa2ab22df3c7c12 Mon Sep 17 00:00:00 2001 From: Arthit Suriyawongkul Date: Tue, 6 May 2025 21:06:17 +0100 Subject: [PATCH] Add Javadoc to CrossRefJson and ExceptionJsonTOC Signed-off-by: Arthit Suriyawongkul --- .../storage/listedlicense/CrossRefJson.java | 62 +++++++++++++++---- .../listedlicense/ExceptionJsonTOC.java | 62 +++++++++++++++++-- .../compare/CompareTemplateOutputHandler.java | 2 +- 3 files changed, 108 insertions(+), 18 deletions(-) diff --git a/src/main/java/org/spdx/storage/listedlicense/CrossRefJson.java b/src/main/java/org/spdx/storage/listedlicense/CrossRefJson.java index 8f103c36..9231a753 100644 --- a/src/main/java/org/spdx/storage/listedlicense/CrossRefJson.java +++ b/src/main/java/org/spdx/storage/listedlicense/CrossRefJson.java @@ -47,12 +47,18 @@ public class CrossRefJson { public Integer order; private transient String id; // The ID is always transient and of anonymous type + /** + * Default constructor for GSON compatibility + */ public CrossRefJson() { // empty constructor so GSON will work } /** - * @param crossRef cross ref to copy values from + * Construct a {@code CrossRefJson} object by copying values + * from a {@link CrossRef} object + * + * @param crossRef The {@link CrossRef} object to copy values from. * @throws InvalidSPDXAnalysisException on SPDX parsing errors */ public CrossRefJson(CrossRef crossRef) throws InvalidSPDXAnalysisException { @@ -65,8 +71,10 @@ public CrossRefJson(CrossRef crossRef) throws InvalidSPDXAnalysisException { crossRef.getTimestamp().ifPresent(s -> timestamp = s); crossRef.getOrder().ifPresent(integer -> order = integer); } - + /** + * Retrieve all valid property descriptors for this object + * * @return all valid property descriptors */ public List getPropertyValueDescriptors() { @@ -96,7 +104,8 @@ public List getPropertyValueDescriptors() { } /** - * Sets the value to the property name + * Set the value to the property name + * * @param propertyDescriptor descriptor for the property to set * @param value Value to set * @throws InvalidSpdxPropertyException on SPDX parsing errors @@ -154,10 +163,20 @@ public boolean removePrimitiveValueToList(PropertyDescriptor propertyDescriptor, throw new InvalidSpdxPropertyException(propertyDescriptor + " is not a list type."); } + /** + * Get the crossRefId + * + * @return The crossRefId + */ public @Nullable String getId() { return this.id; } + /** + * Set the crossRefId + * + * @param crossRefId + */ public void setId(String crossRefId) { this.id = crossRefId; } @@ -172,6 +191,8 @@ public List getValueList(PropertyDescriptor propertyDescriptor) throws Invali } /** + * Retrieve the value associated with the given property descriptor + * * @param propertyDescriptor descriptor for the property to set * @return the value associated with the property - null if not assigned or not present * @throws InvalidSpdxPropertyException on SPDX parsing errors @@ -190,8 +211,9 @@ public List getValueList(PropertyDescriptor propertyDescriptor) throws Invali } /** - * sets the property to null (no way to remove in this store) - * @param propertyDescriptor descriptor for the property to set + * Set the property to null (no way to remove in this store) + * + * @param propertyDescriptor Descriptor for the property to set * @throws InvalidSpdxPropertyException on SPDX parsing errors */ public void removeProperty(PropertyDescriptor propertyDescriptor) throws InvalidSpdxPropertyException { @@ -203,11 +225,16 @@ public void removeProperty(PropertyDescriptor propertyDescriptor) throws Invalid case "timestamp": this.timestamp = null; break; case "isWayBackLink": this.isWayBackLink = null; break; case "order": this.order = null; break; - default: throw new InvalidSpdxPropertyException("Invalid property for CrossRef:"+propertyDescriptor); + default: + throw new InvalidSpdxPropertyException("Invalid property for CrossRef:" + propertyDescriptor); } } /** + * Check whether the members of the collection can be assigned to the given class + *

+ * Note: This is not implemented for this class and always returns false. + * * @param propertyDescriptor descriptor for the property to set * @param clazz target class * @return true if the members can be assigned from clazz @@ -217,6 +244,8 @@ public boolean isCollectionMembersAssignableTo(PropertyDescriptor propertyDescri } /** + * Check whether the property value can be assigned to the given class + * * @param propertyDescriptor descriptor for the property to set * @param clazz target class * @return true if the property can be assigned from clazz @@ -226,21 +255,28 @@ public boolean isPropertyValueAssignableTo(PropertyDescriptor propertyDescriptor switch (propertyDescriptor.getName()) { case "match": case "url": - case "timestamp": return String.class.isAssignableFrom(clazz); + case "timestamp": + return String.class.isAssignableFrom(clazz); case "isValid": case "isLive": - case "isWayBackLink": return Boolean.class.isAssignableFrom(clazz); - case "order": return Integer.class.isAssignableFrom(clazz); - default: throw new InvalidSpdxPropertyException("Invalid property for CrossRef:"+propertyDescriptor); - } - + case "isWayBackLink": + return Boolean.class.isAssignableFrom(clazz); + case "order": + return Integer.class.isAssignableFrom(clazz); + default: + throw new InvalidSpdxPropertyException("Invalid property for CrossRef:" + propertyDescriptor); + } } /** + * Check whether the property is a collection + *

+ * Note: This is not implemented for this class and always returns false. + * * @param propertyName Name of the property * @return if the property is a collection */ public boolean isCollectionProperty(String propertyName) { return false; } -} \ No newline at end of file +} diff --git a/src/main/java/org/spdx/storage/listedlicense/ExceptionJsonTOC.java b/src/main/java/org/spdx/storage/listedlicense/ExceptionJsonTOC.java index 356fbd72..c94e3b60 100644 --- a/src/main/java/org/spdx/storage/listedlicense/ExceptionJsonTOC.java +++ b/src/main/java/org/spdx/storage/listedlicense/ExceptionJsonTOC.java @@ -43,92 +43,133 @@ public static class ExceptionJson { private String name; private String licenseExceptionId; private List seeAlso; + /** + * Retrieve the license exception ID + * * @return the licenseExceptionId */ public String getLicenseExceptionId() { return licenseExceptionId; } + /** + * Retrieve the reference + * * @return the reference */ public String getReference() { return reference; } + /** + * Check whether this is a deprecated license ID + * * @return the isDeprecatedLicenseId */ public boolean isDeprecatedLicenseId() { return isDeprecatedLicenseId; } + /** + * Retrieve the details URL + * * @return the detailsUrl */ public String getDetailsUrl() { return detailsUrl; } + /** + * Retrieve the reference number + * * @return the referenceNumber */ public int getReferenceNumber() { return referenceNumber; } + /** + * Retrieve the name + * * @return the name */ public String getName() { return name; } + /** + * Retrieve the see-also list + * * @return the seeAlso */ public List getSeeAlso() { return seeAlso; } + /** + * Set the reference + * * @param reference the reference to set */ public void setReference(String reference) { this.reference = reference; } + /** + * Set whether this is a deprecated license ID + * * @param isDeprecatedLicenseId the isDeprecatedLicenseId to set */ public void setDeprecatedLicenseId(boolean isDeprecatedLicenseId) { this.isDeprecatedLicenseId = isDeprecatedLicenseId; } + /** + * Set the details URL + * * @param detailsUrl the detailsUrl to set */ public void setDetailsUrl(String detailsUrl) { this.detailsUrl = detailsUrl; } + /** + * Set the reference number + * * @param referenceNumber the referenceNumber to set */ public void setReferenceNumber(int referenceNumber) { this.referenceNumber = referenceNumber; } + /** + * Set the name + * * @param name the name to set */ public void setName(String name) { this.name = name; } + /** + * Set the license exception ID + * * @param licenseExceptionId the licenseExceptionId to set */ public void setLicenseExceptionId(String licenseExceptionId) { this.licenseExceptionId = licenseExceptionId; } + /** + * Set the see-also list + * * @param seeAlso the seeAlso to set */ public void setSeeAlso(List seeAlso) { this.seeAlso = seeAlso; } } - private String licenseListVersion; private final List exceptions; @@ -136,6 +177,7 @@ public void setSeeAlso(List seeAlso) { /** * Create an ExceptionJsonTOC + * * @param version license list version * @param releaseDate release date of the license list */ @@ -155,6 +197,8 @@ public ExceptionJsonTOC() { } /** + * Retrieve the license list version + * * @return the licenseListVersion */ public @Nullable String getLicenseListVersion() { @@ -162,6 +206,8 @@ public ExceptionJsonTOC() { } /** + * Retrieve the list of exceptions + * * @return the exceptions */ public List getExceptions() { @@ -169,7 +215,9 @@ public List getExceptions() { } /** - * @return map of lower case to correct case exception IDs + * Retrieve a map of lower case to correct case exception IDs + * + * @return A map of lower case to correct case exception IDs */ public Map getExceptionIds() { Map retval = new HashMap<>(); @@ -180,6 +228,8 @@ public Map getExceptionIds() { } /** + * Retrieve the release date + * * @return the releaseDate */ public @Nullable String getReleaseDate() { @@ -188,6 +238,7 @@ public Map getExceptionIds() { /** * Add a new exception to the list of exceptions + * * @param exception exception to be added * @param exceptionHTMLReference URL of the exception HTML * @param exceptionJSONReference URL of the JSON @@ -215,6 +266,8 @@ public void addException(ListedLicenseException exception, String exceptionHTMLR } /** + * Set the license list version + * * @param licenseListVersion the licenseListVersion to set */ public void setLicenseListVersion(String licenseListVersion) { @@ -222,11 +275,12 @@ public void setLicenseListVersion(String licenseListVersion) { } /** + * Set the release date + * * @param releaseDate the releaseDate to set */ public void setReleaseDate(String releaseDate) { this.releaseDate = releaseDate; } - - + } diff --git a/src/main/java/org/spdx/utility/compare/CompareTemplateOutputHandler.java b/src/main/java/org/spdx/utility/compare/CompareTemplateOutputHandler.java index 1bd0ac53..a0191c85 100644 --- a/src/main/java/org/spdx/utility/compare/CompareTemplateOutputHandler.java +++ b/src/main/java/org/spdx/utility/compare/CompareTemplateOutputHandler.java @@ -640,7 +640,7 @@ public boolean isSkipFirstTextToken() { } /** - * Information obout any difference found + * Information about any difference found */ public static class DifferenceDescription { private static final int MAX_DIFF_TEXT_LENGTH = 100;