diff --git a/src/main/java/org/spdx/core/CoreModelObject.java b/src/main/java/org/spdx/core/CoreModelObject.java
index 113afc0..c9cdb28 100644
--- a/src/main/java/org/spdx/core/CoreModelObject.java
+++ b/src/main/java/org/spdx/core/CoreModelObject.java
@@ -1,14 +1,14 @@
/**
* Copyright (c) 2023 Source Auditor Inc.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -40,18 +40,18 @@
/**
*
* Superclass for all SPDX model objects
- *
+ *
* Provides the primary interface to the storage class that access and stores the data for
* the model objects.
- *
+ *
* This class includes several helper methods to manage the storage and retrieval of properties.
- *
+ *
* Each model object is in itself stateless. All state is maintained in the Model Store.
- *
- * The concrete classes are expected to implements getters for the model class properties which translate
+ *
+ * The concrete classes are expected to implement getters for the model class properties which translate
* into calls to the getTYPEPropertyValue where TYPE is the type of value to be returned and the property descriptor
* is passed as a parameter.
- *
+ *
* There are 2 methods of setting values:
* - call the setPropertyValue, clearValueCollection or addValueToCollection methods - this will call the modelStore and store the
* value immediately
@@ -60,18 +60,19 @@
* A convenience method Write.applyUpdatesInOneTransaction
will perform all updates within
* a single transaction. This method may result in higher performance updates for some Model Store implementations.
* Note that none of the updates will be applied until the storage manager update method is invoked.
- *
+ *
* Property values are restricted to the following types:
* - String - Java Strings
* - Booolean - Java Boolean or primitive boolean types
* - CoreModelObject - A concrete subclass of this type
* - {@literal Collection} - A Collection of type T where T is one of the supported non-collection types
- *
+ *
* This class also handles the conversion of a CoreModelObject to and from a TypeValue for storage in the ModelStore.
*
* @author Gary O'Neall
*
*/
+@SuppressWarnings({"OptionalUsedAsFieldOrParameterType", "LoggingSimilarMessage"})
public abstract class CoreModelObject {
static final Logger logger = LoggerFactory.getLogger(CoreModelObject.class);
@@ -85,10 +86,10 @@ public abstract class CoreModelObject {
protected String idPrefix; // Optional prefix to be used when generating new IDs
/**
- * If non null, a reference made to a model object stored in a different modelStore and/or
+ * If non-null, a reference made to a model object stored in a different modelStore and/or
* document will be copied to this modelStore and documentUri
*/
- protected IModelCopyManager copyManager = null;
+ protected IModelCopyManager copyManager;
/**
* if true, checks input values for setters to verify valid SPDX inputs
*/
@@ -99,7 +100,7 @@ public abstract class CoreModelObject {
/**
* Create a new Model Object using an Anonymous ID with the default store and default document URI
* @param specVersion - version of the SPDX spec the object complies with
- * @throws InvalidSPDXAnalysisException
+ * @throws InvalidSPDXAnalysisException on any SPDX related exception
*/
protected CoreModelObject(String specVersion) throws InvalidSPDXAnalysisException {
this(DefaultModelStore.getDefaultModelStore().getNextId(IdType.Anonymous), specVersion);
@@ -327,7 +328,7 @@ public Optional getObjectPropertyValue(PropertyDescriptor propertyDescri
Optional retval = ModelObjectHelper.getObjectPropertyValue(modelStore, objectUri,
propertyDescriptor, copyManager, specVersion, type, idPrefix);
if (retval.isPresent() && retval.get() instanceof CoreModelObject && !strict) {
- ((CoreModelObject)retval.get()).setStrict(strict);
+ ((CoreModelObject)retval.get()).setStrict(false);
}
return retval;
}
@@ -442,9 +443,9 @@ public Optional getBooleanPropertyValue(PropertyDescriptor propertyDesc
// try to convert
String sResult = ((String)result.get()).toLowerCase();
if ("true".equals(sResult)) {
- return Optional.of(Boolean.valueOf(true));
+ return Optional.of(Boolean.TRUE);
} else if ("false".equals(sResult)) {
- return Optional.of(Boolean.valueOf(false));
+ return Optional.of(Boolean.FALSE);
} else {
throw new SpdxInvalidTypeException(PROPERTY_MSG+propertyDescriptor+" is not of type Boolean");
}
@@ -569,7 +570,7 @@ public ModelSet> getObjectPropertyValueSet(PropertyDescriptor propertyDescript
* @return Collection of values associated with a property
*/
public ModelCollection> getObjectPropertyValueCollection(PropertyDescriptor propertyDescriptor, Class> type) throws InvalidSPDXAnalysisException {
- return new ModelCollection<>(this.modelStore, this.objectUri, propertyDescriptor,
+ return new ModelCollection<>(this.modelStore, this.objectUri, propertyDescriptor,
this.copyManager, type, specVersion, idPrefix);
}
@@ -716,8 +717,8 @@ private boolean propertyValuesEquivalent(PropertyDescriptor propertyDescriptor,
/**
* Compares 2 simple optional objects considering NONE and NOASSERTION values which are equivalent to their strings
- * @param valueA
- * @param valueB
+ * @param valueA value to compare
+ * @param valueB value to compare
* @return if the 2 values are equivalent
*/
private boolean optionalObjectsEquivalent(Optional valueA, Optional valueB) {
@@ -782,8 +783,9 @@ private boolean areEquivalent(List> firstList, List> secondList,
* @return true if the list contains an equal or equivalent item
* @throws InvalidSPDXAnalysisException on any SPDX related exception
*/
- private boolean containsEqualOrEquivalentItem(List> list, Object itemToFind,
- boolean ignoreRelatedElements) throws InvalidSPDXAnalysisException {
+ @SuppressWarnings("BooleanMethodIsAlwaysInverted")
+ private boolean containsEqualOrEquivalentItem(List> list, Object itemToFind,
+ boolean ignoreRelatedElements) throws InvalidSPDXAnalysisException {
if (list.contains(itemToFind)) {
return true;
} else if (itemToFind instanceof IndividualUriValue && list.contains(new SimpleUriValue((IndividualUriValue) itemToFind))) {
@@ -839,7 +841,8 @@ public boolean equals(Object o) {
* @param modelStore model store to store the copy in
* @return a copy of this model object
*/
- public CoreModelObject clone(IModelStore modelStore) {
+ @SuppressWarnings("unused")
+ public CoreModelObject clone(IModelStore modelStore) {
if (Objects.isNull(this.copyManager)) {
throw new IllegalStateException("A copy manager must be provided to clone");
}
diff --git a/src/main/java/org/spdx/core/DefaultModelStore.java b/src/main/java/org/spdx/core/DefaultModelStore.java
index 83ccf4c..288dbce 100644
--- a/src/main/java/org/spdx/core/DefaultModelStore.java
+++ b/src/main/java/org/spdx/core/DefaultModelStore.java
@@ -1,14 +1,14 @@
/**
* Copyright (c) 2019 Source Auditor Inc.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -25,7 +25,7 @@
/**
* Singleton class to hold a default model store used when no model store is provided
- *
+ *
* WARNING: The model store and copy manager are in memory and will continue to grow as they are utilized. There is NO garbage collection.
*
* @author Gary O'Neall
@@ -81,7 +81,7 @@ public static String getDefaultDocumentUri() throws DefaultStoreNotInitialized {
* @param newDefaultDocumentUri new SPDX 2.X document URI
* @param newDefaultCopyManager new default copy manager
*/
- public static final void initialize(IModelStore newModelStore, String newDefaultDocumentUri,
+ public static void initialize(IModelStore newModelStore, String newDefaultDocumentUri,
IModelCopyManager newDefaultCopyManager) {
Objects.requireNonNull(newModelStore, "Model store can not be null");
Objects.requireNonNull(newDefaultDocumentUri, "Document URI can not be null");
diff --git a/src/main/java/org/spdx/core/DefaultStoreNotInitialized.java b/src/main/java/org/spdx/core/DefaultStoreNotInitialized.java
index e496a5f..37fc28d 100644
--- a/src/main/java/org/spdx/core/DefaultStoreNotInitialized.java
+++ b/src/main/java/org/spdx/core/DefaultStoreNotInitialized.java
@@ -10,6 +10,7 @@
* @author Gary O'Neall
*
*/
+@SuppressWarnings("unused")
public class DefaultStoreNotInitialized extends InvalidSPDXAnalysisException {
private static final long serialVersionUID = 1L;
diff --git a/src/main/java/org/spdx/core/DuplicateSpdxIdException.java b/src/main/java/org/spdx/core/DuplicateSpdxIdException.java
index ba761db..5a5b831 100644
--- a/src/main/java/org/spdx/core/DuplicateSpdxIdException.java
+++ b/src/main/java/org/spdx/core/DuplicateSpdxIdException.java
@@ -1,14 +1,14 @@
/**
* Copyright (c) 2019 Source Auditor Inc.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -22,6 +22,7 @@
*
* @author Gary O'Neall
*/
+@SuppressWarnings("unused")
public class DuplicateSpdxIdException extends InvalidSPDXAnalysisException {
private static final long serialVersionUID = 1L;
diff --git a/src/main/java/org/spdx/core/IExternalElementInfo.java b/src/main/java/org/spdx/core/IExternalElementInfo.java
index 3a62618..123850c 100644
--- a/src/main/java/org/spdx/core/IExternalElementInfo.java
+++ b/src/main/java/org/spdx/core/IExternalElementInfo.java
@@ -6,7 +6,7 @@
/**
* Information about an Element which is external to the collection or store
- *
+ *
* The information stored is version dependent and implemented in the models
*
* @author Gary O'Neall
diff --git a/src/main/java/org/spdx/core/IModelCopyManager.java b/src/main/java/org/spdx/core/IModelCopyManager.java
index 3af7034..135f22b 100644
--- a/src/main/java/org/spdx/core/IModelCopyManager.java
+++ b/src/main/java/org/spdx/core/IModelCopyManager.java
@@ -10,10 +10,10 @@
/**
* Implementation classes of this interface helps facilitate copying objects from one model to another.
- *
+ *
* In addition to the copy functions (methods), these objects keeps track of
* what was copied where so that the same object is not copied twice.
- *
+ *
* These objects can be passed into the constructor for ModelObjects to allow the objects to be copied.
*
* @author Gary O'Neall
@@ -30,38 +30,38 @@ public interface IModelCopyManager {
* @return Object URI for the copied object
* @throws InvalidSPDXAnalysisException on any SPDX related error
*/
- public TypedValue copy(IModelStore toStore, IModelStore fromStore,
+ TypedValue copy(IModelStore toStore, IModelStore fromStore,
String sourceUri, String toSpecVersion, @Nullable String toNamespace) throws InvalidSPDXAnalysisException;
- /**
- * Copy an item from one Model Object Store to another
- * @param toStore Model Store to copy to
- * @param toObjectUri URI for the destination object
- * @param fromStore Model Store containing the source item
- * @param fromObjectUri Object URI for the source item
- * @param toSpecVersion version of the spec the to value should comply with
- * @param toNamespace optional namespace of the to property
- * @throws InvalidSPDXAnalysisException on any SPDX related error
- */
- public void copy(IModelStore toStore, String toObjectUri, IModelStore fromStore, String fromObjectUri,
- String toSpecVersion, @Nullable String toNamespace) throws InvalidSPDXAnalysisException;
-
- /**
- * @param fromStore Store copied from
- * @param fromObjectUri Object URI in the from tsotre
- * @param toStore store copied to
- * @return the objectId which has already been copied, or null if it has not been copied
- */
- public String getCopiedObjectUri(IModelStore fromStore, String fromObjectUri,
- IModelStore toStore);
-
- /**
- * Record a copied ID between model stores
- * @param fromStore Store copied from
- * @param fromObjectUri URI for the from Object
- * @param toObjectUri URI for the to Object
- * @return any copied to ID for the same stores, URI's, nameSpace and fromID
- */
- public String putCopiedId(IModelStore fromStore, String fromObjectUri, IModelStore toStore,
- String toObjectUri);
+ /**
+ * Copy an item from one Model Object Store to another
+ * @param toStore Model Store to copy to
+ * @param toObjectUri URI for the destination object
+ * @param fromStore Model Store containing the source item
+ * @param fromObjectUri Object URI for the source item
+ * @param toSpecVersion version of the spec the to value should comply with
+ * @param toNamespace optional namespace of the to property
+ * @throws InvalidSPDXAnalysisException on any SPDX related error
+ */
+ void copy(IModelStore toStore, String toObjectUri, IModelStore fromStore, String fromObjectUri,
+ String toSpecVersion, @Nullable String toNamespace) throws InvalidSPDXAnalysisException;
+
+ /**
+ * @param fromStore Store copied from
+ * @param fromObjectUri Object URI in the from tsotre
+ * @param toStore store copied to
+ * @return the objectId which has already been copied, or null if it has not been copied
+ */
+ String getCopiedObjectUri(IModelStore fromStore, String fromObjectUri,
+ IModelStore toStore);
+
+ /**
+ * Record a copied ID between model stores
+ * @param fromStore Store copied from
+ * @param fromObjectUri URI for the from Object
+ * @param toObjectUri URI for the to Object
+ * @return any copied to ID for the same stores, URI's, nameSpace and fromID
+ */
+ String putCopiedId(IModelStore fromStore, String fromObjectUri, IModelStore toStore,
+ String toObjectUri);
}
diff --git a/src/main/java/org/spdx/core/ISpdxModelInfo.java b/src/main/java/org/spdx/core/ISpdxModelInfo.java
index 417bf29..c087906 100644
--- a/src/main/java/org/spdx/core/ISpdxModelInfo.java
+++ b/src/main/java/org/spdx/core/ISpdxModelInfo.java
@@ -21,12 +21,12 @@ public interface ISpdxModelInfo {
/**
* @return a map of URIs to Enums which represents individual vocabularies in the SPDX model
*/
- public Map> getUriToEnumMap();
+ Map> getUriToEnumMap();
/**
* @return the spec versions this model supports
*/
- public List getSpecVersions();
+ List getSpecVersions();
/**
* @param store store to use for the inflated object
@@ -35,15 +35,15 @@ public interface ISpdxModelInfo {
* @param specVersion version of the SPDX specification used by the external element
* @return model object of type type
*/
- public CoreModelObject createExternalElement(IModelStore store, String uri,
- @Nullable IModelCopyManager copyManager,Class> type, String specVersion) throws InvalidSPDXAnalysisException;
+ CoreModelObject createExternalElement(IModelStore store, String uri,
+ @Nullable IModelCopyManager copyManager, Class> type, String specVersion) throws InvalidSPDXAnalysisException;
/**
* @param uri URI for the individual
* @param type optional type hint - used for individuals where the type may be ambiguous
* @return a matching individual for a given URI or null if no individual exists
*/
- public @Nullable Object uriToIndividual(String uri, Class> type);
+ @Nullable Object uriToIndividual(String uri, Class> type);
/**
* @param modelStore store to use for the inflated object
@@ -55,19 +55,19 @@ public CoreModelObject createExternalElement(IModelStore store, String uri,
* @param idPrefix optional prefix used for any new object URI's created in support of this model object
* @return fully inflated model object of type type
*/
- public CoreModelObject createModelObject(IModelStore modelStore,
- String objectUri, String type, IModelCopyManager copyManager,
- String specVersion, boolean create, @Nullable String idPrefix) throws InvalidSPDXAnalysisException;
+ CoreModelObject createModelObject(IModelStore modelStore,
+ String objectUri, String type, IModelCopyManager copyManager,
+ String specVersion, boolean create, @Nullable String idPrefix) throws InvalidSPDXAnalysisException;
/**
* @return a map of string representation of types to classes which implement those types
*/
- public Map> getTypeToClassMap();
+ Map> getTypeToClassMap();
/**
* @param clazz model class
* @return true if clazz can be represented as external to the store
*/
- public boolean canBeExternal(Class> clazz);
+ boolean canBeExternal(Class> clazz);
}
diff --git a/src/main/java/org/spdx/core/IndividualUriValue.java b/src/main/java/org/spdx/core/IndividualUriValue.java
index 3be98c9..02f9330 100644
--- a/src/main/java/org/spdx/core/IndividualUriValue.java
+++ b/src/main/java/org/spdx/core/IndividualUriValue.java
@@ -1,14 +1,14 @@
/**
* Copyright (c) 2019 Source Auditor Inc.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -29,5 +29,5 @@ public interface IndividualUriValue {
/**
* @return a unique identifier for this value. Typically the namespace + the long name
*/
- public String getIndividualURI();
+ String getIndividualURI();
}
diff --git a/src/main/java/org/spdx/core/InvalidSPDXAnalysisException.java b/src/main/java/org/spdx/core/InvalidSPDXAnalysisException.java
index 1712587..45c2463 100644
--- a/src/main/java/org/spdx/core/InvalidSPDXAnalysisException.java
+++ b/src/main/java/org/spdx/core/InvalidSPDXAnalysisException.java
@@ -1,14 +1,14 @@
/**
* Copyright (c) 2019 Source Auditor Inc.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/main/java/org/spdx/core/InvalidSpdxPropertyException.java b/src/main/java/org/spdx/core/InvalidSpdxPropertyException.java
index 5e7c83c..9d9ecdc 100644
--- a/src/main/java/org/spdx/core/InvalidSpdxPropertyException.java
+++ b/src/main/java/org/spdx/core/InvalidSpdxPropertyException.java
@@ -1,14 +1,15 @@
/**
* Copyright (c) 2019 Source Auditor Inc.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
- *
+ *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -23,6 +24,7 @@
* @author Gary O'Neall
*
*/
+@SuppressWarnings("unused")
public class InvalidSpdxPropertyException extends InvalidSPDXAnalysisException {
private static final long serialVersionUID = 1L;
diff --git a/src/main/java/org/spdx/core/ModelCollection.java b/src/main/java/org/spdx/core/ModelCollection.java
index 75dcdf0..08a8fee 100644
--- a/src/main/java/org/spdx/core/ModelCollection.java
+++ b/src/main/java/org/spdx/core/ModelCollection.java
@@ -1,14 +1,14 @@
/**
* Copyright (c) 2023 Source Auditor Inc.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -40,19 +40,21 @@
* @author Gary O'Neall
*
*/
+@SuppressWarnings({"TypeParameterExplicitlyExtendsObject", "unused"})
public class ModelCollection implements Collection {
- private IModelStore modelStore;
- private String objectUri;
- private PropertyDescriptor propertyDescriptor;
- private IModelCopyManager copyManager;
- private String specVersion;
- private String idPrefix;
+ private final IModelStore modelStore;
+ private final String objectUri;
+ private final PropertyDescriptor propertyDescriptor;
+ private final IModelCopyManager copyManager;
+ private final String specVersion;
+ private final String idPrefix;
/**
* Map of URI's of elements referenced but not present in the store
*/
- protected Map externalMap;
+ @SuppressWarnings("unused")
+ protected Map externalMap;
private Class> type;
/**
@@ -63,7 +65,7 @@ public class ModelCollection implements Collection {
*/
class ModelCollectionIterator implements Iterator {
- private Iterator storageIterator;
+ private final Iterator storageIterator;
public ModelCollectionIterator(Iterator storageIterator) {
this.storageIterator = storageIterator;
@@ -110,7 +112,7 @@ public ModelCollection(IModelStore modelStore, String objectUri, PropertyDescrip
if (Objects.nonNull(type)) {
this.type = type;
if (!modelStore.isCollectionMembersAssignableTo(objectUri, propertyDescriptor, type)) {
- throw new SpdxInvalidTypeException("Incompatible type for property "+propertyDescriptor+": "+type.toString());
+ throw new SpdxInvalidTypeException("Incompatible type for property "+propertyDescriptor+": "+ type);
}
}
}
@@ -136,7 +138,7 @@ public boolean isEmpty() {
@Override
public boolean contains(Object o) {
try {
- Object storedObject = null;
+ Object storedObject;
try {
storedObject = ModelObjectHelper.modelObjectToStoredObject(o, modelStore, copyManager, idPrefix);
} catch (SpdxObjectNotInStoreException e1) {
@@ -163,8 +165,8 @@ private Object checkConvertTypedValue(Object value) {
throw new SpdxInvalidTypeException("No enumeration, external or individual of the proper type was found for URI "+((IndividualUriValue)retval).getIndividualURI()+
" for type "+type.toString());
} else {
- throw new SpdxInvalidTypeException("A collection element of type "+retval.getClass().toString()+
- " was found in a collection of type "+type.toString());
+ throw new SpdxInvalidTypeException("A collection element of type "+ retval.getClass() +
+ " was found in a collection of type "+ type);
}
}
return retval;
@@ -177,7 +179,7 @@ private Object checkConvertTypedValue(Object value) {
* Converts any typed or individual value objects to a ModelObject
*/
- private UnaryOperator checkConvertTypedValue = ModelCollection.this::checkConvertTypedValue;
+ private final UnaryOperator checkConvertTypedValue = ModelCollection.this::checkConvertTypedValue;
/**
* @return a list of objects for the model collection
@@ -199,12 +201,12 @@ public Iterator iterator() {
}
@Override
- public Object[] toArray() {
+ public Object [] toArray() {
return toImmutableList().toArray();
}
@Override
- public T1[] toArray(T1[] a) {
+ public T1 [] toArray(T1 [] a) {
return toImmutableList().toArray(a);
}
@@ -229,7 +231,8 @@ public boolean remove(Object element) {
}
}
- @Override
+ @SuppressWarnings("SlowListContainsAll")
+ @Override
public boolean containsAll(Collection> c) {
return toImmutableList().containsAll(c);
}
@@ -237,24 +240,22 @@ public boolean containsAll(Collection> c) {
@Override
public boolean addAll(Collection extends Object> c) {
boolean retval = false;
- Iterator extends Object> iter = c.iterator();
- while (iter.hasNext()) {
- if (add(iter.next())) {
- retval = true;
- }
- }
+ for (Object o : c) {
+ if (add(o)) {
+ retval = true;
+ }
+ }
return retval;
}
@Override
public boolean removeAll(Collection> c) {
boolean retval = false;
- Iterator extends Object> iter = c.iterator();
- while (iter.hasNext()) {
- if (remove(iter.next())) {
- retval = true;
- }
- }
+ for (Object o : c) {
+ if (remove(o)) {
+ retval = true;
+ }
+ }
return retval;
}
diff --git a/src/main/java/org/spdx/core/ModelObjectHelper.java b/src/main/java/org/spdx/core/ModelObjectHelper.java
index 67cf598..7738511 100644
--- a/src/main/java/org/spdx/core/ModelObjectHelper.java
+++ b/src/main/java/org/spdx/core/ModelObjectHelper.java
@@ -1,14 +1,14 @@
/**
* Copyright (c) 2023 Source Auditor Inc.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -63,8 +63,8 @@ public static Optional getObjectPropertyValue(IModelStore modelStore, St
if (!modelStore.exists(objectUri)) {
return Optional.empty();
} else if (modelStore.isCollectionProperty(objectUri, propertyDescriptor)) {
- return Optional.of(new ModelCollection<>(modelStore, objectUri, propertyDescriptor, copyManager,
- null, specVersion, idPrefix));
+ return Optional.of(new ModelCollection<>(modelStore, objectUri, propertyDescriptor, copyManager,
+ null, specVersion, idPrefix));
} else {
return optionalStoredObjectToModelObject(modelStore.getValue(objectUri,
propertyDescriptor), modelStore, copyManager, specVersion, type, idPrefix);
@@ -191,9 +191,10 @@ public static void removePropertyValueFromCollection(IModelStore modelStore, Str
* ModelObject is returned
* @throws InvalidSPDXAnalysisException on any SPDX related error
*/
- public static Optional optionalStoredObjectToModelObject(Optional value,
- IModelStore modelStore, IModelCopyManager copyManager, String specVersion,
- @Nullable Class> type, String idPrefix) throws InvalidSPDXAnalysisException {
+ @SuppressWarnings("OptionalUsedAsFieldOrParameterType")
+ public static Optional optionalStoredObjectToModelObject(Optional value,
+ IModelStore modelStore, IModelCopyManager copyManager, String specVersion,
+ @Nullable Class> type, String idPrefix) throws InvalidSPDXAnalysisException {
if (value.isPresent() && value.get() instanceof IndividualUriValue) {
return Optional.ofNullable(new SimpleUriValue((IndividualUriValue)value.get()).toModelObject(modelStore, copyManager,
specVersion, type));
@@ -232,7 +233,7 @@ public static Object modelObjectToStoredObject(Object value, IModelStore modelSt
} else {
return mValue.toTypedValue();
}
- } else if (value instanceof Integer || value instanceof String || value instanceof Boolean || value instanceof IndividualUriValue) {
+ } else if (value instanceof Integer || value instanceof String || value instanceof Boolean) {
return value;
} else if (Objects.isNull(value)) {
throw new SpdxInvalidTypeException("Property value is null");
diff --git a/src/main/java/org/spdx/core/ModelRegistry.java b/src/main/java/org/spdx/core/ModelRegistry.java
index 3f30ad2..f1ba58e 100644
--- a/src/main/java/org/spdx/core/ModelRegistry.java
+++ b/src/main/java/org/spdx/core/ModelRegistry.java
@@ -20,7 +20,7 @@
/**
* Singleton class which contains a registry of SPDX model versions
- *
+ *
* Each model version implements a model interface ISpdxModelInfo
which
* supports inflating an SPDX type specific to that version
*
@@ -37,7 +37,7 @@ public class ModelRegistry {
private static final ModelRegistry _instance = new ModelRegistry();
private static final ReadWriteLock lock = new ReentrantReadWriteLock();
- private Map registeredModels = new HashMap<>();
+ private final Map registeredModels = new HashMap<>();
/**
* Private constructor - singleton class
diff --git a/src/main/java/org/spdx/core/ModelRegistryException.java b/src/main/java/org/spdx/core/ModelRegistryException.java
index 1a82c51..527ad87 100644
--- a/src/main/java/org/spdx/core/ModelRegistryException.java
+++ b/src/main/java/org/spdx/core/ModelRegistryException.java
@@ -9,11 +9,12 @@
*
* @author Gary O'Neall
*/
+@SuppressWarnings("unused")
public class ModelRegistryException extends InvalidSPDXAnalysisException {
private static final long serialVersionUID = 1L;
- public ModelRegistryException() {
+ public ModelRegistryException() {
super();
}
diff --git a/src/main/java/org/spdx/core/ModelSet.java b/src/main/java/org/spdx/core/ModelSet.java
index 1952925..711db09 100644
--- a/src/main/java/org/spdx/core/ModelSet.java
+++ b/src/main/java/org/spdx/core/ModelSet.java
@@ -1,14 +1,14 @@
/**
* Copyright (c) 2019 Source Auditor Inc.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,7 +18,6 @@
package org.spdx.core;
import java.util.Collection;
-import java.util.Iterator;
import java.util.Set;
import javax.annotation.Nullable;
@@ -36,9 +35,11 @@
* @author Gary O'Neall
*
*/
+@SuppressWarnings({"TypeParameterExplicitlyExtendsObject", "unused"})
public class ModelSet extends ModelCollection implements Set {
- static final Logger logger = LoggerFactory.getLogger(ModelSet.class);
+ @SuppressWarnings("unused")
+ static final Logger logger = LoggerFactory.getLogger(ModelSet.class);
/**
* @param modelStore Storage for the model collection
@@ -74,8 +75,7 @@ public boolean add(Object element) {
this.getModelStore().leaveCriticalSection(lock);
}
}
-
- @SuppressWarnings("rawtypes")
+
@Override
public boolean addAll(Collection c) {
IModelStoreLock lock;
@@ -86,13 +86,11 @@ public boolean addAll(Collection c) {
}
try {
boolean retval = false;
- Iterator iter = c.iterator();
- while (iter.hasNext()) {
- Object item = iter.next();
- if (!super.contains(item) && super.add(item)) {
- retval = true;
- }
- }
+ for (Object item : c) {
+ if (!super.contains(item) && super.add(item)) {
+ retval = true;
+ }
+ }
return retval;
} finally {
this.getModelStore().leaveCriticalSection(lock);
diff --git a/src/main/java/org/spdx/core/NotEquivalentReason.java b/src/main/java/org/spdx/core/NotEquivalentReason.java
index 47a7267..4ef6ad7 100644
--- a/src/main/java/org/spdx/core/NotEquivalentReason.java
+++ b/src/main/java/org/spdx/core/NotEquivalentReason.java
@@ -1,14 +1,14 @@
/**
* Copyright (c) 2023 Source Auditor Inc.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/main/java/org/spdx/core/RuntimeSpdxException.java b/src/main/java/org/spdx/core/RuntimeSpdxException.java
index bd9ef56..aa5ca8e 100644
--- a/src/main/java/org/spdx/core/RuntimeSpdxException.java
+++ b/src/main/java/org/spdx/core/RuntimeSpdxException.java
@@ -10,6 +10,7 @@
* @author Gary O'Neall
*
*/
+@SuppressWarnings("unused")
public class RuntimeSpdxException extends RuntimeException {
@@ -21,7 +22,8 @@ public class RuntimeSpdxException extends RuntimeException {
/**
* @param message exception message
*/
- public RuntimeSpdxException(String message) {
+ @SuppressWarnings("unused")
+ public RuntimeSpdxException(String message) {
super(message);
}
@@ -43,8 +45,8 @@ public RuntimeSpdxException(String message, InvalidSPDXAnalysisException cause)
/**
* @param message exception message
* @param cause SPDX analysis cause
- * @param enableSuppression
- * @param writableStackTrace
+ * @param enableSuppression to suppress message
+ * @param writableStackTrace stack trace
*/
public RuntimeSpdxException(String message, Throwable cause,
boolean enableSuppression, boolean writableStackTrace) {
diff --git a/src/main/java/org/spdx/core/SimpleUriValue.java b/src/main/java/org/spdx/core/SimpleUriValue.java
index e4686ec..2f595db 100644
--- a/src/main/java/org/spdx/core/SimpleUriValue.java
+++ b/src/main/java/org/spdx/core/SimpleUriValue.java
@@ -1,14 +1,14 @@
/**
* Copyright (c) 2019 Source Auditor Inc.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -38,7 +38,7 @@ public class SimpleUriValue implements IndividualUriValue {
static final Logger logger = LoggerFactory.getLogger(SimpleUriValue.class);
- private String uri;
+ private final String uri;
/**
* returns hash based on URI of the IndividualUriValue
@@ -120,7 +120,8 @@ public Object toModelObject(IModelStore store, IModelCopyManager copyManager,
return retval;
}
- @Override
+ @SuppressWarnings("EqualsDoesntCheckParameterClass")
+ @Override
public boolean equals(Object comp) {
return isIndividualUriValueEquals(this, comp);
}
diff --git a/src/main/java/org/spdx/core/SpdxCoreConstants.java b/src/main/java/org/spdx/core/SpdxCoreConstants.java
index f04ff2f..850b318 100644
--- a/src/main/java/org/spdx/core/SpdxCoreConstants.java
+++ b/src/main/java/org/spdx/core/SpdxCoreConstants.java
@@ -11,7 +11,8 @@
*/
public class SpdxCoreConstants {
- public enum SpdxMajorVersion {
+ @SuppressWarnings("unused")
+ public enum SpdxMajorVersion {
VERSION_1("SPDX-1."),
VERSION_2("SPDX-2."),
VERSION_3("3.");
diff --git a/src/main/java/org/spdx/core/SpdxIdInUseException.java b/src/main/java/org/spdx/core/SpdxIdInUseException.java
index 29a2307..9fa8d09 100644
--- a/src/main/java/org/spdx/core/SpdxIdInUseException.java
+++ b/src/main/java/org/spdx/core/SpdxIdInUseException.java
@@ -1,14 +1,14 @@
/**
* Copyright (c) 2020 Source Auditor Inc.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -23,6 +23,7 @@
* @author Gary O'Neall
*
*/
+@SuppressWarnings("unused")
public class SpdxIdInUseException extends InvalidSPDXAnalysisException {
private static final long serialVersionUID = 1L;
diff --git a/src/main/java/org/spdx/core/SpdxIdNotFoundException.java b/src/main/java/org/spdx/core/SpdxIdNotFoundException.java
index 7446787..b55410d 100644
--- a/src/main/java/org/spdx/core/SpdxIdNotFoundException.java
+++ b/src/main/java/org/spdx/core/SpdxIdNotFoundException.java
@@ -1,14 +1,14 @@
/**
* Copyright (c) 2019 Source Auditor Inc.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -23,6 +23,7 @@
* @author Gary O'Neall
*
*/
+@SuppressWarnings("unused")
public class SpdxIdNotFoundException extends InvalidSPDXAnalysisException {
private static final long serialVersionUID = 1L;
diff --git a/src/main/java/org/spdx/core/SpdxInvalidIdException.java b/src/main/java/org/spdx/core/SpdxInvalidIdException.java
index a482235..ee176ca 100644
--- a/src/main/java/org/spdx/core/SpdxInvalidIdException.java
+++ b/src/main/java/org/spdx/core/SpdxInvalidIdException.java
@@ -1,14 +1,14 @@
/**
* Copyright (c) 2019 Source Auditor Inc.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -23,6 +23,7 @@
* @author Gary O'Neall
*
*/
+@SuppressWarnings("unused")
public class SpdxInvalidIdException extends InvalidSPDXAnalysisException {
/**
@@ -45,15 +46,15 @@ public SpdxInvalidIdException(String message) {
}
/**
- * @param cause
+ * @param cause Cause
*/
public SpdxInvalidIdException(Throwable cause) {
super(cause);
}
/**
- * @param message
- * @param cause
+ * @param message Message
+ * @param cause Cause
*/
public SpdxInvalidIdException(String message, Throwable cause) {
super(message, cause);
diff --git a/src/main/java/org/spdx/core/SpdxInvalidTypeException.java b/src/main/java/org/spdx/core/SpdxInvalidTypeException.java
index de3739d..5159168 100644
--- a/src/main/java/org/spdx/core/SpdxInvalidTypeException.java
+++ b/src/main/java/org/spdx/core/SpdxInvalidTypeException.java
@@ -1,14 +1,14 @@
/**
* Copyright (c) 2019 Source Auditor Inc.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/main/java/org/spdx/core/SpdxObjectNotInStoreException.java b/src/main/java/org/spdx/core/SpdxObjectNotInStoreException.java
index 1358c49..6e3ae2b 100644
--- a/src/main/java/org/spdx/core/SpdxObjectNotInStoreException.java
+++ b/src/main/java/org/spdx/core/SpdxObjectNotInStoreException.java
@@ -1,14 +1,14 @@
/**
* Copyright (c) 2019 Source Auditor Inc.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -23,6 +23,7 @@
* @author Gary O'Neall
*
*/
+@SuppressWarnings("unused")
public class SpdxObjectNotInStoreException extends InvalidSPDXAnalysisException {
/**
diff --git a/src/main/java/org/spdx/licenseTemplate/HtmlTemplateOutputHandler.java b/src/main/java/org/spdx/licenseTemplate/HtmlTemplateOutputHandler.java
index e4e3eba..f4bc814 100644
--- a/src/main/java/org/spdx/licenseTemplate/HtmlTemplateOutputHandler.java
+++ b/src/main/java/org/spdx/licenseTemplate/HtmlTemplateOutputHandler.java
@@ -1,12 +1,12 @@
/**
* Copyright (c) 2013 Source Auditor Inc.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -150,7 +150,7 @@ private static boolean validIdChar(char c) {
}
/**
- * @return
+ * @return HTML result
*/
public String getHtml() {
return this.htmlString.toString();
diff --git a/src/main/java/org/spdx/licenseTemplate/ILicenseTemplateOutputHandler.java b/src/main/java/org/spdx/licenseTemplate/ILicenseTemplateOutputHandler.java
index f1d2964..e52a454 100644
--- a/src/main/java/org/spdx/licenseTemplate/ILicenseTemplateOutputHandler.java
+++ b/src/main/java/org/spdx/licenseTemplate/ILicenseTemplateOutputHandler.java
@@ -1,12 +1,12 @@
/**
* Copyright (c) 2013 Source Auditor Inc.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/main/java/org/spdx/licenseTemplate/InvalidLicenseTemplateException.java b/src/main/java/org/spdx/licenseTemplate/InvalidLicenseTemplateException.java
index 4033e34..469ee79 100644
--- a/src/main/java/org/spdx/licenseTemplate/InvalidLicenseTemplateException.java
+++ b/src/main/java/org/spdx/licenseTemplate/InvalidLicenseTemplateException.java
@@ -1,12 +1,12 @@
/**
* Copyright (c) 2016 Source Auditor Inc.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -21,6 +21,7 @@
* @author Gary O'Neall
*
*/
+@SuppressWarnings("unused")
public class InvalidLicenseTemplateException extends Exception {
private static final long serialVersionUID = 1L;
diff --git a/src/main/java/org/spdx/licenseTemplate/LicenseParserException.java b/src/main/java/org/spdx/licenseTemplate/LicenseParserException.java
index cb86ca5..88d3ce7 100644
--- a/src/main/java/org/spdx/licenseTemplate/LicenseParserException.java
+++ b/src/main/java/org/spdx/licenseTemplate/LicenseParserException.java
@@ -1,12 +1,12 @@
/**
* Copyright (c) 2015 Source Auditor Inc.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/main/java/org/spdx/licenseTemplate/LicenseTemplateRule.java b/src/main/java/org/spdx/licenseTemplate/LicenseTemplateRule.java
index ef7adef..c6323e6 100644
--- a/src/main/java/org/spdx/licenseTemplate/LicenseTemplateRule.java
+++ b/src/main/java/org/spdx/licenseTemplate/LicenseTemplateRule.java
@@ -1,12 +1,12 @@
/**
* Copyright (c) 2013 Source Auditor Inc.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -136,7 +136,7 @@ public void parseLicenseTemplateRule(String parseableLicenseTemplateRule) throws
Matcher rulePartMatcher = SPLIT_REGEX.matcher(parseableLicenseTemplateRule);
int start = 0;
// parse out the first field - should be the rule type
- String typeStr = null;
+ String typeStr;
if (rulePartMatcher.find()) {
typeStr = parseableLicenseTemplateRule.substring(start, rulePartMatcher.start()+1).trim();
start = rulePartMatcher.end();
@@ -161,19 +161,20 @@ public void parseLicenseTemplateRule(String parseableLicenseTemplateRule) throws
/**
* @param typeStr string representing the type of rule
- * @return reule type
+ * @return rule type
* @throws LicenseTemplateRuleException if the license template could not be parsed
*/
private RuleType typeStringToType(String typeStr) throws LicenseTemplateRuleException {
- if (typeStr.equals(VARIABLE_RULE_TYPE_STR)) {
- return RuleType.VARIABLE;
- } else if (typeStr.equals(BEGIN_OPTIONAL_TYPE_STR)) {
- return RuleType.BEGIN_OPTIONAL;
- } else if (typeStr.equals(END_OPTIONAL_TYPE_STR)) {
- return RuleType.END_OPTIONAL;
- } else {
- throw new LicenseTemplateRuleException("Unknown rule type: "+typeStr);
- }
+ switch (typeStr) {
+ case VARIABLE_RULE_TYPE_STR:
+ return RuleType.VARIABLE;
+ case BEGIN_OPTIONAL_TYPE_STR:
+ return RuleType.BEGIN_OPTIONAL;
+ case END_OPTIONAL_TYPE_STR:
+ return RuleType.END_OPTIONAL;
+ default:
+ throw new LicenseTemplateRuleException("Unknown rule type: " + typeStr);
+ }
}
/**
diff --git a/src/main/java/org/spdx/licenseTemplate/LicenseTemplateRuleException.java b/src/main/java/org/spdx/licenseTemplate/LicenseTemplateRuleException.java
index 6b735a4..b4202fc 100644
--- a/src/main/java/org/spdx/licenseTemplate/LicenseTemplateRuleException.java
+++ b/src/main/java/org/spdx/licenseTemplate/LicenseTemplateRuleException.java
@@ -1,12 +1,12 @@
/**
* Copyright (c) 2013 Source Auditor Inc.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/main/java/org/spdx/licenseTemplate/LicenseTextHelper.java b/src/main/java/org/spdx/licenseTemplate/LicenseTextHelper.java
index ca25971..db94b25 100644
--- a/src/main/java/org/spdx/licenseTemplate/LicenseTextHelper.java
+++ b/src/main/java/org/spdx/licenseTemplate/LicenseTextHelper.java
@@ -26,12 +26,12 @@
*/
public class LicenseTextHelper {
- protected static final String TOKEN_SPLIT_REGEX = "(^|[^\\s\\.,?'();:\"/\\[\\]]{1,100})((\\s|\\.|,|\\?|'|\"|\\(|\\)|;|:|/|\\[|\\]|$){1,100})";
+ protected static final String TOKEN_SPLIT_REGEX = "(^|[^\\s.,?'();:\"/\\[\\]]{1,100})((\\s|\\.|,|\\?|'|\"|\\(|\\)|;|:|/|\\[|]|$){1,100})";
public static final Pattern TOKEN_SPLIT_PATTERN = Pattern.compile(TOKEN_SPLIT_REGEX);
- protected static final Set PUNCTUATION = Collections.unmodifiableSet(new HashSet(
+ protected static final Set PUNCTUATION = Collections.unmodifiableSet(new HashSet<>(
Arrays.asList(".",",","?","\"","'","(",")",";",":","/","[", "]")));
// most of these are comments for common programming languages (C style, Java, Ruby, Python)
- protected static final Set SKIPPABLE_TOKENS = Collections.unmodifiableSet(new HashSet(
+ protected static final Set SKIPPABLE_TOKENS = Collections.unmodifiableSet(new HashSet<>(
Arrays.asList("//","/*","*/","/**","#","##","*","**","\"\"\"","/","=begin","=end")));
static final String DASHES_REGEX = "[\\u2012\\u2013\\u2014\\u2015]";
static final Pattern SPACE_PATTERN = Pattern.compile("[\\u202F\\u2007\\u2060\\u2009]");
@@ -41,7 +41,8 @@ public class LicenseTextHelper {
static final Pattern COPYRIGHT_HOLDERS_PATTERN = Pattern.compile("copyright holders", Pattern.CASE_INSENSITIVE);
static final Pattern COPYRIGHT_OWNERS_PATTERN = Pattern.compile("copyright owners", Pattern.CASE_INSENSITIVE);
static final Pattern COPYRIGHT_OWNER_PATTERN = Pattern.compile("copyright owner", Pattern.CASE_INSENSITIVE);
- static final Pattern PER_CENT_PATTERN_LF = Pattern.compile("per\\s{0,100}\\n{1,10}\\s{0,100}cent", Pattern.CASE_INSENSITIVE);
+ @SuppressWarnings("unused")
+ static final Pattern PER_CENT_PATTERN_LF = Pattern.compile("per\\s{0,100}\\n{1,10}\\s{0,100}cent", Pattern.CASE_INSENSITIVE);
static final Pattern COPYRIGHT_HOLDERS_PATTERN_LF = Pattern.compile("copyright\\s{0,100}\\n{1,10}\\s{0,100}holders", Pattern.CASE_INSENSITIVE);
static final Pattern COPYRIGHT_HOLDER_PATTERN_LF = Pattern.compile("copyright\\s{0,100}\\n{1,10}\\s{0,100}holder", Pattern.CASE_INSENSITIVE);
static final Pattern COPYRIGHT_OWNERS_PATTERN_LF = Pattern.compile("copyright\\s{0,100}\\n{1,10}\\s{0,100}owners", Pattern.CASE_INSENSITIVE);
@@ -104,13 +105,13 @@ private LicenseTextHelper() {
}
/**
- * Returns true if two sets of license text is considered a match per
- * the SPDX License matching guidelines documented at spdx.org (currently http://spdx.org/wiki/spdx-license-list-match-guidelines)
- * There are 2 unimplemented features - bullets/numbering is not considered and comments with no whitespace between text is not skipped
- * @param licenseTextA text to compare
- * @param licenseTextB text to compare
- * @return true if the license text is equivalent
- */
+ * Returns true if two sets of license text is considered a match per
+ * the SPDX License matching guidelines documented at spdx.org (currently license matching guidelines )
+ * There are 2 unimplemented features - bullets/numbering is not considered and comments with no whitespace between text is not skipped
+ * @param licenseTextA text to compare
+ * @param licenseTextB text to compare
+ * @return true if the license text is equivalent
+ */
public static boolean isLicenseTextEquivalent(String licenseTextA, String licenseTextB) {
//TODO: Handle comment characters without white space before text
//TODO: Handle bullets and numbering
@@ -126,8 +127,8 @@ public static boolean isLicenseTextEquivalent(String licenseTextA, String licens
if (licenseTextA.equals(licenseTextB)) {
return true;
}
- Map tokenToLocationA = new HashMap();
- Map tokenToLocationB = new HashMap();
+ Map tokenToLocationA = new HashMap<>();
+ Map tokenToLocationB = new HashMap<>();
String[] licenseATokens = tokenizeLicenseText(licenseTextA,tokenToLocationA);
String[] licenseBTokens = tokenizeLicenseText(licenseTextB,tokenToLocationB);
int bTokenCounter = 0;
@@ -137,7 +138,7 @@ public static boolean isLicenseTextEquivalent(String licenseTextA, String licens
while (nextAToken != null) {
if (nextBToken == null) {
// end of b stream
- while (nextAToken != null && canSkip(nextAToken)) {
+ while (canSkip(nextAToken)) {
nextAToken = getTokenAt(licenseATokens, aTokenCounter++);
}
if (nextAToken != null) {
@@ -149,11 +150,11 @@ public static boolean isLicenseTextEquivalent(String licenseTextA, String licens
nextBToken = getTokenAt(licenseBTokens, bTokenCounter++);
} else {
// see if we can skip through some B tokens to find a match
- while (nextBToken != null && canSkip(nextBToken)) {
+ while (canSkip(nextBToken)) {
nextBToken = getTokenAt(licenseBTokens, bTokenCounter++);
}
// just to be sure, skip forward on the A license
- while (nextAToken != null && canSkip(nextAToken)) {
+ while (canSkip(nextAToken)) {
nextAToken = getTokenAt(licenseATokens, aTokenCounter++);
}
if (!tokensEquivalent(nextAToken, nextBToken)) {
@@ -165,7 +166,7 @@ public static boolean isLicenseTextEquivalent(String licenseTextA, String licens
}
}
// need to make sure B is at the end
- while (nextBToken != null && canSkip(nextBToken)) {
+ while (canSkip(nextBToken)) {
nextBToken = getTokenAt(licenseBTokens, bTokenCounter++);
}
return (nextBToken == null);
@@ -181,57 +182,48 @@ public static boolean isLicenseTextEquivalent(String licenseTextA, String licens
*/
public static String[] tokenizeLicenseText(String licenseText, Map tokenToLocation) {
String textToTokenize = normalizeText(replaceMultWord(replaceSpaceComma(licenseText))).toLowerCase();
- List tokens = new ArrayList();
- BufferedReader reader = null;
- try {
- reader = new BufferedReader(new StringReader(textToTokenize));
- int currentLine = 1;
- int currentToken = 0;
- String line = reader.readLine();
- while (line != null) {
- line = removeLineSeparators(line);
- Matcher lineMatcher = TOKEN_SPLIT_PATTERN.matcher(line);
- while (lineMatcher.find()) {
- String token = lineMatcher.group(1).trim();
- if (!token.isEmpty()) {
- tokens.add(token);
- tokenToLocation.put(currentToken, new LineColumn(currentLine, lineMatcher.start(), token.length()));
- currentToken++;
- }
- String fullMatch = lineMatcher.group(0);
- for (int i = lineMatcher.group(1).length(); i < fullMatch.length(); i++) {
- String possiblePunctuation = fullMatch.substring(i, i+1);
- if (PUNCTUATION.contains(possiblePunctuation)) {
- tokens.add(possiblePunctuation);
- tokenToLocation.put(currentToken, new LineColumn(currentLine, lineMatcher.start()+i, 1));
- currentToken++;
- }
- }
- }
- currentLine++;
- line = reader.readLine();
- }
- } catch (IOException e) {
- // Don't fill in the lines, take a simpler approach
- Matcher m = TOKEN_SPLIT_PATTERN.matcher(textToTokenize);
- while (m.find()) {
- String word = m.group(1).trim();
- String seperator = m.group(2).trim();
- tokens.add(word);
- if (PUNCTUATION.contains(seperator)) {
- tokens.add(seperator);
- }
- }
- } finally {
- if (reader != null) {
- try {
- reader.close();
- } catch (IOException e) {
- // ignore
- }
- }
- }
- return tokens.toArray(new String[tokens.size()]);
+ List tokens = new ArrayList<>();
+ try (BufferedReader reader = new BufferedReader(new StringReader(textToTokenize))) {
+ int currentLine = 1;
+ int currentToken = 0;
+ String line = reader.readLine();
+ while (line != null) {
+ line = removeLineSeparators(line);
+ Matcher lineMatcher = TOKEN_SPLIT_PATTERN.matcher(line);
+ while (lineMatcher.find()) {
+ String token = lineMatcher.group(1).trim();
+ if (!token.isEmpty()) {
+ tokens.add(token);
+ tokenToLocation.put(currentToken, new LineColumn(currentLine, lineMatcher.start(), token.length()));
+ currentToken++;
+ }
+ String fullMatch = lineMatcher.group(0);
+ for (int i = lineMatcher.group(1).length(); i < fullMatch.length(); i++) {
+ String possiblePunctuation = fullMatch.substring(i, i + 1);
+ if (PUNCTUATION.contains(possiblePunctuation)) {
+ tokens.add(possiblePunctuation);
+ tokenToLocation.put(currentToken, new LineColumn(currentLine, lineMatcher.start() + i, 1));
+ currentToken++;
+ }
+ }
+ }
+ currentLine++;
+ line = reader.readLine();
+ }
+ } catch (IOException e) {
+ // Don't fill in the lines, take a simpler approach
+ Matcher m = TOKEN_SPLIT_PATTERN.matcher(textToTokenize);
+ while (m.find()) {
+ String word = m.group(1).trim();
+ String seperator = m.group(2).trim();
+ tokens.add(word);
+ if (PUNCTUATION.contains(seperator)) {
+ tokens.add(seperator);
+ }
+ }
+ }
+ // ignore
+ return tokens.toArray(new String[0]);
}
/**
diff --git a/src/main/java/org/spdx/licenseTemplate/LineColumn.java b/src/main/java/org/spdx/licenseTemplate/LineColumn.java
index a08a9ba..3c299d0 100644
--- a/src/main/java/org/spdx/licenseTemplate/LineColumn.java
+++ b/src/main/java/org/spdx/licenseTemplate/LineColumn.java
@@ -1,14 +1,14 @@
/**
* Copyright (c) 2019 Source Auditor Inc.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -57,7 +57,8 @@ public int getColumn() {
/**
* @param column column
*/
- public void setColumn(int column) {
+ @SuppressWarnings("unused")
+ public void setColumn(int column) {
this.column = column;
}
@@ -68,7 +69,8 @@ public int getLen() {
return len;
}
- public void setLen(int len) {
+ @SuppressWarnings("unused")
+ public void setLen(int len) {
this.len = len;
}
}
diff --git a/src/main/java/org/spdx/licenseTemplate/SpdxLicenseTemplateHelper.java b/src/main/java/org/spdx/licenseTemplate/SpdxLicenseTemplateHelper.java
index bfa5f7e..9b4eade 100644
--- a/src/main/java/org/spdx/licenseTemplate/SpdxLicenseTemplateHelper.java
+++ b/src/main/java/org/spdx/licenseTemplate/SpdxLicenseTemplateHelper.java
@@ -1,12 +1,12 @@
/**
* Copyright (c) 2013 Source Auditor Inc.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -107,7 +107,7 @@ public static void parseTemplate(String licenseTemplate, ILicenseTemplateOutputH
* rules or tags
* @param licenseTemplate standard license template
* @return an HTML representation of the license template
- * @throws LicenseTemplateRuleException on an rule parsing errors
+ * @throws LicenseTemplateRuleException on a rule parsing errors
*/
public static String templateTextToHtml(String licenseTemplate) throws LicenseTemplateRuleException {
HtmlTemplateOutputHandler htmlOutput = new HtmlTemplateOutputHandler();
@@ -152,7 +152,7 @@ public static String formatEscapeHTML(String text) {
*
* @param text unformatted text
* @param inParagraph true if inside a paragraph tag
- * @return text escapted and formatted for inclusion in HTML
+ * @return text escaped and formatted for inclusion in HTML
*/
public static String formatEscapeHTML(String text, boolean inParagraph) {
String retval = StringEscapeUtils.escapeXml11(text);
@@ -223,7 +223,7 @@ public static String addHtmlFormatting(String text, boolean inParagraph) {
* spaces or tabs
*
* @param line line of license text
- * @return text incluing any paragraph tags
+ * @return text including any paragraph tags
*/
private static String getParagraphTagConsideringTags(String line) {
int numSpaces = countLeadingSpaces(line);
@@ -236,7 +236,7 @@ private static String getParagraphTagConsideringTags(String line) {
int pixels = PIXELS_PER_TAB[numTabs - 1];
result.append("
");
} else {
result.append("
");
diff --git a/src/main/java/org/spdx/licenseTemplate/TextTemplateOutputHandler.java b/src/main/java/org/spdx/licenseTemplate/TextTemplateOutputHandler.java
index 3c1b7d3..8d93cad 100644
--- a/src/main/java/org/spdx/licenseTemplate/TextTemplateOutputHandler.java
+++ b/src/main/java/org/spdx/licenseTemplate/TextTemplateOutputHandler.java
@@ -1,12 +1,12 @@
/**
* Copyright (c) 2013 Source Auditor Inc.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/main/java/org/spdx/storage/IModelStore.java b/src/main/java/org/spdx/storage/IModelStore.java
index cfe8452..464c25d 100644
--- a/src/main/java/org/spdx/storage/IModelStore.java
+++ b/src/main/java/org/spdx/storage/IModelStore.java
@@ -1,14 +1,14 @@
/**
* Copyright (c) 2019 Source Auditor Inc.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -29,14 +29,14 @@
/**
* Service Provider Interface for storing and retrieving SPDX properties from the underlying store.
- *
+ *
* The interface uses the URI to identify specific objects stored.
- *
+ *
* Each object can have property values and property value lists associated with them.
- *
+ *
* A property value is an object of a primitive type (e.g. String or Boolean) or is another
- * object which includes it's own ID and must also have a type described in the SPDX model.
- *
+ * object which includes its own ID and must also have a type described in the SPDX model.
+ *
* A property list is just a list of values.
*
* @author Gary O'Neall
@@ -44,19 +44,19 @@
*/
public interface IModelStore extends AutoCloseable {
- public interface IModelStoreLock {
- public void unlock();
+ interface IModelStoreLock {
+ void unlock();
}
@FunctionalInterface
- public static interface ModelUpdate {
+ interface ModelUpdate {
void apply() throws InvalidSPDXAnalysisException;
}
/**
* Different types of ID's
*/
- public enum IdType {
+ enum IdType {
LicenseRef, // ID's that start with LicenseRef-
DocumentRef, // ID's that start with DocumentRef- - for compatibility in SPDX 2.X versions
SpdxId, // ID's that start with SpdxRef-
@@ -68,21 +68,21 @@ public enum IdType {
* @param objectUri unique URI within the SPDX model store for the objects
* @return true if the objectUri already exists for the document
*/
- public boolean exists(String objectUri);
+ boolean exists(String objectUri);
/**
* Create a new object with objectUri, type and version from the typedValue
* @param typedValue TypedValue of the item to create
* @throws InvalidSPDXAnalysisException on model store errors
*/
- public void create(TypedValue typedValue) throws InvalidSPDXAnalysisException;
+ void create(TypedValue typedValue) throws InvalidSPDXAnalysisException;
/**
* @param objectUri unique URI within the SPDX model store for the objects
* @return Property descriptors for all properties having a value for a given objectUri within a document
* @throws InvalidSPDXAnalysisException on model store errors
*/
- public List getPropertyValueDescriptors(String objectUri) throws InvalidSPDXAnalysisException;
+ List getPropertyValueDescriptors(String objectUri) throws InvalidSPDXAnalysisException;
/**
* Sets a property value for a String or Boolean type of value creating the propertyDescriptor if it does not exist
@@ -91,7 +91,7 @@ public enum IdType {
* @param value value to set
* @throws InvalidSPDXAnalysisException on model store errors
*/
- public void setValue(String objectUri, PropertyDescriptor propertyDescriptor, Object value) throws InvalidSPDXAnalysisException;
+ void setValue(String objectUri, PropertyDescriptor propertyDescriptor, Object value) throws InvalidSPDXAnalysisException;
/**
* @param objectUri unique URI within the SPDX model store for the objects
@@ -99,7 +99,7 @@ public enum IdType {
* @return the single value associated with the objectUri, propertyDescriptor and document
* @throws InvalidSPDXAnalysisException on model store errors
*/
- public Optional getValue(String objectUri, PropertyDescriptor propertyDescriptor) throws InvalidSPDXAnalysisException;
+ Optional getValue(String objectUri, PropertyDescriptor propertyDescriptor) throws InvalidSPDXAnalysisException;
/**
* Generate a unique ID within the model store - Note: for a full URI, the id should be prepended with a URI prefix
@@ -107,7 +107,7 @@ public enum IdType {
* @return next available unique ID for the specific idType - Note: for a full URI, the id should be prepended with a URI prefix
* @throws InvalidSPDXAnalysisException on model store errors
*/
- public String getNextId(IdType idType) throws InvalidSPDXAnalysisException;
+ String getNextId(IdType idType) throws InvalidSPDXAnalysisException;
/**
* Removes a property from the document for the given ID if the property exists. Does not raise any exception if the propertyDescriptor does not exist
@@ -115,7 +115,7 @@ public enum IdType {
* @param propertyDescriptor descriptor for the property
* @throws InvalidSPDXAnalysisException on model store errors
*/
- public void removeProperty(String objectUri, PropertyDescriptor propertyDescriptor) throws InvalidSPDXAnalysisException;
+ void removeProperty(String objectUri, PropertyDescriptor propertyDescriptor) throws InvalidSPDXAnalysisException;
/**
* @param nameSpace Optional SPDX namespace to filter items by
@@ -123,19 +123,19 @@ public enum IdType {
* @return Stream of all items store within the document
* @throws InvalidSPDXAnalysisException on model store errors
*/
- public Stream getAllItems(@Nullable String nameSpace, @Nullable String typeFilter) throws InvalidSPDXAnalysisException;
+ Stream getAllItems(@Nullable String nameSpace, @Nullable String typeFilter) throws InvalidSPDXAnalysisException;
/**
- * Enter a critical section. leaveCriticialSection must be called.
+ * Enter a critical section. leaveCriticalSection must be called.
* @param readLockRequested true implies a read lock, false implies write lock.
* @throws InvalidSPDXAnalysisException on model store errors
*/
- public IModelStoreLock enterCriticalSection(boolean readLockRequested) throws InvalidSPDXAnalysisException;
+ IModelStoreLock enterCriticalSection(boolean readLockRequested) throws InvalidSPDXAnalysisException;
/**
* Leave a critical section. Releases the lock form the matching enterCriticalSection
*/
- public void leaveCriticalSection(IModelStoreLock lock);
+ void leaveCriticalSection(IModelStoreLock lock);
/**
* Removes a value from a collection of values associated with a property
@@ -144,14 +144,14 @@ public enum IdType {
* @param value Value to be removed
* @return true if the value was removed
*/
- public boolean removeValueFromCollection(String objectUri, PropertyDescriptor propertyDescriptor, Object value) throws InvalidSPDXAnalysisException;
+ boolean removeValueFromCollection(String objectUri, PropertyDescriptor propertyDescriptor, Object value) throws InvalidSPDXAnalysisException;
/**
* @param objectUri unique URI within the SPDX model store for the objects
* @param propertyDescriptor descriptor for the property
* @return size of a collection associated with a property. 0 if the property does not exist.
*/
- public int collectionSize(String objectUri, PropertyDescriptor propertyDescriptor) throws InvalidSPDXAnalysisException;
+ int collectionSize(String objectUri, PropertyDescriptor propertyDescriptor) throws InvalidSPDXAnalysisException;
/**
* @param objectUri unique URI within the SPDX model store for the objects
@@ -159,7 +159,7 @@ public enum IdType {
* @param value value to check for contains
* @return true if the collection associated with a property contains the value
*/
- public boolean collectionContains(String objectUri, PropertyDescriptor propertyDescriptor, Object value) throws InvalidSPDXAnalysisException;
+ boolean collectionContains(String objectUri, PropertyDescriptor propertyDescriptor, Object value) throws InvalidSPDXAnalysisException;
/**
* Sets the value collection for the property to an empty collection creating the propertyDescriptor if it does not exist
@@ -177,7 +177,7 @@ public enum IdType {
* @return true if the collection was modified
* @throws InvalidSPDXAnalysisException on model store errors
*/
- public boolean addValueToCollection(String objectUri, PropertyDescriptor propertyDescriptor, Object value) throws InvalidSPDXAnalysisException;
+ boolean addValueToCollection(String objectUri, PropertyDescriptor propertyDescriptor, Object value) throws InvalidSPDXAnalysisException;
/**
* @param objectUri unique URI within the SPDX model store for the objects
@@ -185,7 +185,7 @@ public enum IdType {
* @return Iterator over the list of values associated with the objectUri, propertyDescriptor and document
* @throws InvalidSPDXAnalysisException on model store errors
*/
- public Iterator listValues(String objectUri, PropertyDescriptor propertyDescriptor) throws InvalidSPDXAnalysisException;
+ Iterator listValues(String objectUri, PropertyDescriptor propertyDescriptor) throws InvalidSPDXAnalysisException;
/**
* @param objectUri unique URI within the SPDX model store for the objects
@@ -194,7 +194,7 @@ public enum IdType {
* @return true if all members of a collection associated with the objectUri and propertyDescriptor can be assigned to the clazz
* @throws InvalidSPDXAnalysisException on model store errors
*/
- public boolean isCollectionMembersAssignableTo(String objectUri, PropertyDescriptor propertyDescriptor, Class> clazz) throws InvalidSPDXAnalysisException;
+ boolean isCollectionMembersAssignableTo(String objectUri, PropertyDescriptor propertyDescriptor, Class> clazz) throws InvalidSPDXAnalysisException;
/**
* @param objectUri unique URI within the SPDX model store for the objects
@@ -204,42 +204,42 @@ public enum IdType {
* @return true if the value associated with the objectUri and propertyDescriptor can be assigned to the clazz
* @throws InvalidSPDXAnalysisException on model store errors
*/
- public boolean isPropertyValueAssignableTo(String objectUri, PropertyDescriptor propertyDescriptor,
- Class> clazz, String specVersion) throws InvalidSPDXAnalysisException;
+ boolean isPropertyValueAssignableTo(String objectUri, PropertyDescriptor propertyDescriptor,
+ Class> clazz, String specVersion) throws InvalidSPDXAnalysisException;
/**
* @param objectUri unique URI within the SPDX model store for the objects
* @param propertyDescriptor descriptor for the property
* @return true if the propertyDescriptor represents multiple values
*/
- public boolean isCollectionProperty(String objectUri, PropertyDescriptor propertyDescriptor) throws InvalidSPDXAnalysisException;
+ boolean isCollectionProperty(String objectUri, PropertyDescriptor propertyDescriptor) throws InvalidSPDXAnalysisException;
/**
* @param objectUri URI for the object or the anon. ID
* @return The type of ID based on the string format
*/
- public IdType getIdType(String objectUri);
+ IdType getIdType(String objectUri);
/**
- * In SPDX 2.2 license refs are allowed to be matched case insensitive. This function will return
- * the case sensitivie ID (e.g. if you have LicenseRef-ABC, calling this function with licenseref-abc will return LicenseRef-ABC
+ * In SPDX 2.2 license refs are allowed to be matched case-insensitive. This function will return
+ * the case-sensitive ID (e.g. if you have LicenseRef-ABC, calling this function with licenseref-abc will return LicenseRef-ABC
* @param nameSpace the nameSpace used for the ID - the URI is formed by the nameSpace + "#" + caseInsensisitiveId
* @param caseInsensisitiveId ID - case will be ignored
- * @return the case sensitive ID if it exists
+ * @return the case-sensitive ID if it exists
*/
- public Optional getCaseSensisitiveId(String nameSpace, String caseInsensisitiveId);
+ Optional getCaseSensisitiveId(String nameSpace, String caseInsensisitiveId);
/**
* @param objectUri unique URI within the SPDX model store for the objects
* @return type TypedValue containing the type of the ModelObject related to the ID
*/
- public Optional getTypedValue(String objectUri) throws InvalidSPDXAnalysisException;
+ Optional getTypedValue(String objectUri) throws InvalidSPDXAnalysisException;
/**
* Deletes an item from the document
* @param objectUri unique URI within the SPDX model store for the objects
* @throws InvalidSPDXAnalysisException on model store errors
*/
- public void delete(String objectUri) throws InvalidSPDXAnalysisException;
+ void delete(String objectUri) throws InvalidSPDXAnalysisException;
/**
* @param objectUri ID or URI for an item
diff --git a/src/main/java/org/spdx/storage/ISerializableModelStore.java b/src/main/java/org/spdx/storage/ISerializableModelStore.java
index e4ddfc1..c0bafa6 100644
--- a/src/main/java/org/spdx/storage/ISerializableModelStore.java
+++ b/src/main/java/org/spdx/storage/ISerializableModelStore.java
@@ -1,14 +1,14 @@
/**
* Copyright (c) 2019 Source Auditor Inc.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -31,6 +31,7 @@
* @author Gary O'Neall
*
*/
+@SuppressWarnings("unused")
public interface ISerializableModelStore extends IModelStore {
/**
@@ -39,7 +40,7 @@ public interface ISerializableModelStore extends IModelStore {
* @throws InvalidSPDXAnalysisException on any SPDX error
* @throws IOException on IO error
*/
- public void serialize(OutputStream stream) throws InvalidSPDXAnalysisException, IOException;
+ void serialize(OutputStream stream) throws InvalidSPDXAnalysisException, IOException;
/**
* Serialize the items stored in the model store. The specific format for serialization depends on the document store.
@@ -49,7 +50,7 @@ public interface ISerializableModelStore extends IModelStore {
* @throws InvalidSPDXAnalysisException on any SPDX error
* @throws IOException on IO error
*/
- public void serialize(OutputStream stream, @Nullable CoreModelObject objectToSerialize) throws InvalidSPDXAnalysisException, IOException;
+ void serialize(OutputStream stream, @Nullable CoreModelObject objectToSerialize) throws InvalidSPDXAnalysisException, IOException;
/**
* Deserialize / read an SPDX document from a stream
@@ -59,5 +60,5 @@ public interface ISerializableModelStore extends IModelStore {
* @throws InvalidSPDXAnalysisException on any SPDX error
* @throws IOException on IO error
*/
- public CoreModelObject deSerialize(InputStream stream, boolean overwrite) throws InvalidSPDXAnalysisException, IOException;
+ CoreModelObject deSerialize(InputStream stream, boolean overwrite) throws InvalidSPDXAnalysisException, IOException;
}
diff --git a/src/main/java/org/spdx/storage/NullModelStore.java b/src/main/java/org/spdx/storage/NullModelStore.java
index 6fff00c..bc5f467 100644
--- a/src/main/java/org/spdx/storage/NullModelStore.java
+++ b/src/main/java/org/spdx/storage/NullModelStore.java
@@ -4,10 +4,7 @@
*/
package org.spdx.storage;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Optional;
+import java.util.*;
import java.util.stream.Stream;
import org.spdx.core.InvalidSPDXAnalysisException;
@@ -80,14 +77,9 @@ public Stream getAllItems(String nameSpace, String typeFilter)
@Override
public IModelStoreLock enterCriticalSection(boolean readLockRequested)
throws InvalidSPDXAnalysisException {
- return new IModelStoreLock() {
-
- @Override
- public void unlock() {
- // no need to do anything
- }
-
- };
+ return () -> {
+ // no need to do anything
+ };
}
@Override
@@ -134,7 +126,7 @@ public boolean addValueToCollection(String objectUri,
public Iterator listValues(String objectUri,
PropertyDescriptor propertyDescriptor)
throws InvalidSPDXAnalysisException {
- return new ArrayList().iterator();
+ return Collections.emptyIterator();
}
@Override
diff --git a/src/main/java/org/spdx/storage/PropertyDescriptor.java b/src/main/java/org/spdx/storage/PropertyDescriptor.java
index 06dbf84..7ec5aab 100644
--- a/src/main/java/org/spdx/storage/PropertyDescriptor.java
+++ b/src/main/java/org/spdx/storage/PropertyDescriptor.java
@@ -1,14 +1,14 @@
/**
* Copyright (c) 2023 Source Auditor Inc.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.