Skip to content

Commit 66bfd77

Browse files
committed
Bump SPDX Java library version
Also fixes some compiler warnings
1 parent 2f87b9b commit 66bfd77

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@
146146
<dependency>
147147
<groupId>org.spdx</groupId>
148148
<artifactId>java-spdx-library</artifactId>
149-
<version>2.0.0-RC1</version>
149+
<version>2.0.0-RC2</version>
150150
</dependency>
151151
<dependency>
152152
<groupId>com.google.code.gson</groupId>

src/main/java/org/spdx/v3jsonldstore/JsonLDDeserializer.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ private synchronized TypedValue deserializeCoreObject(JsonNode node, String defa
228228
PropertyDescriptor property;
229229
try {
230230
Optional<PropertyDescriptor> optDesc = jsonFieldNameToProperty(field.getKey(), tv.getSpecVersion());
231-
if (!optDesc.isPresent()) {
231+
if (optDesc.isEmpty()) {
232232
throw new InvalidSPDXAnalysisException("No property descriptor for field "+field.getKey());
233233
}
234234
property = optDesc.get();
@@ -286,7 +286,7 @@ private TypedValue getOrCreateCoreObject(JsonNode node,
286286
id = jsonNodeId;
287287
}
288288
type = typeNodeToType(node.get("type"));
289-
if (!type.isPresent()) {
289+
if (type.isEmpty()) {
290290
logger.error("Missing type for core object {}", node);
291291
throw new InvalidSPDXAnalysisException("Missing type for core object " + node);
292292
}
@@ -315,7 +315,7 @@ private Object toStoredObject(String propertyName, JsonNode value, String specVe
315315
case ARRAY:
316316
throw new InvalidSPDXAnalysisException("Can not convert a JSON array to a stored object");
317317
case BOOLEAN: {
318-
if (!propertyType.isPresent() || JsonLDSchema.BOOLEAN_TYPES.contains(propertyType.get())) {
318+
if (propertyType.isEmpty() || JsonLDSchema.BOOLEAN_TYPES.contains(propertyType.get())) {
319319
return value.asBoolean();
320320
} else if (JsonLDSchema.STRING_TYPES.contains(propertyType.get())) {
321321
return value.asText();
@@ -325,7 +325,7 @@ private Object toStoredObject(String propertyName, JsonNode value, String specVe
325325
}
326326
case NULL: throw new InvalidSPDXAnalysisException("Can not convert a JSON NULL to a stored object");
327327
case NUMBER: {
328-
if (!propertyType.isPresent() || JsonLDSchema.INTEGER_TYPES.contains(propertyType.get())) {
328+
if (propertyType.isEmpty() || JsonLDSchema.INTEGER_TYPES.contains(propertyType.get())) {
329329
return value.asInt();
330330
} else if (JsonLDSchema.DOUBLE_TYPES.contains(propertyType.get())) {
331331
return value.asDouble();
@@ -363,13 +363,13 @@ private Object jsonStringToStoredValue(String propertyName, JsonNode jsonValue,
363363
} else if (schema.isEnum(propertyName)) {
364364
// we can assume that the @vocab points to the prefix for the enumerations
365365
Optional<String> vocab = schema.getVocab(propertyName);
366-
if (!vocab.isPresent()) {
366+
if (vocab.isEmpty()) {
367367
throw new InvalidSPDXAnalysisException("Missing vocabulary for enum property "+propertyName);
368368
}
369369
return new SimpleUriValue(vocab.get() + jsonValue.asText());
370370
} else {
371371
Optional<String> propertyType = schema.getPropertyType(propertyName);
372-
if (!propertyType.isPresent()) {
372+
if (propertyType.isEmpty()) {
373373
logger.warn("Missing property type for value {}. Defaulting to a string type", jsonValue);
374374
return jsonValue.asText();
375375
} else if (JsonLDSchema.STRING_TYPES.contains(propertyType.get())) {
@@ -503,7 +503,7 @@ public TypedValue deserializeElement(JsonNode elementNode) throws GenerationExce
503503
throw new InvalidSPDXAnalysisException("Can not serialize an anonymous (blank) element");
504504
}
505505
Optional<String> type = typeNodeToType(elementNode.get("type"));
506-
if (!type.isPresent()) {
506+
if (type.isEmpty()) {
507507
throw new InvalidSPDXAnalysisException("Missing type for element "+id);
508508
}
509509
String specVersion = getSpecVersionFromNode(elementNode, creationInfoIdToSpecVersion,

src/main/java/org/spdx/v3jsonldstore/JsonLDSchema.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ public boolean isSpdxObject(String propertyName) {
460460
return false;
461461
}
462462
Optional<JsonNode> shacl = getPropertyShacl(propertyName);
463-
if (!shacl.isPresent()) {
463+
if (shacl.isEmpty()) {
464464
return false;
465465
}
466466
boolean objectType = false;
@@ -511,7 +511,7 @@ public boolean isIndividual(String propertyName, String propertyValue) {
511511
*/
512512
public boolean isEnum(String propertyName) {
513513
Optional<String> type = getPropertyType(propertyName);
514-
if (!type.isPresent()) {
514+
if (type.isEmpty()) {
515515
return false;
516516
}
517517
if (!"@vocab".equals(type.get())) {

src/main/java/org/spdx/v3jsonldstore/JsonLDSerializer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
* <p>
5555
* The <code>serialize()</code> method will serialize the <code>@graph</code> for all SPDX elements
5656
* stored in the model store.
57-
*
57+
* </p>
5858
* The <code>serialize(SpdxElement element)</code> will serialize a single element.
5959
*
6060
* @author Gary O'Neall
@@ -64,7 +64,7 @@ public class JsonLDSerializer {
6464

6565
static final Logger logger = LoggerFactory.getLogger(JsonLDSerializer.class);
6666

67-
static final Comparator<JsonNode> NODE_COMPARATOR = new Comparator<JsonNode>() {
67+
static final Comparator<JsonNode> NODE_COMPARATOR = new Comparator<>() {
6868

6969
@Override
7070
public int compare(JsonNode arg0, JsonNode arg1) {

0 commit comments

Comments
 (0)