Check for null value with the appropriate assertion method

This commit is contained in:
Valeriy Vyrva 2023-10-03 10:40:50 +03:00 committed by Josh Cummings
parent 823bc971f5
commit 0e30b923f8
2 changed files with 7 additions and 7 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -107,7 +107,7 @@ public interface ClaimAccessor {
}
Object claimValue = getClaims().get(claim);
Instant convertedValue = ClaimConversionService.getSharedInstance().convert(claimValue, Instant.class);
Assert.isTrue(convertedValue != null,
Assert.notNull(convertedValue,
() -> "Unable to convert claim '" + claim + "' of type '" + claimValue.getClass() + "' to Instant.");
return convertedValue;
}
@ -123,7 +123,7 @@ public interface ClaimAccessor {
}
Object claimValue = getClaims().get(claim);
URL convertedValue = ClaimConversionService.getSharedInstance().convert(claimValue, URL.class);
Assert.isTrue(convertedValue != null,
Assert.notNull(convertedValue,
() -> "Unable to convert claim '" + claim + "' of type '" + claimValue.getClass() + "' to URL.");
return convertedValue;
}
@ -148,7 +148,7 @@ public interface ClaimAccessor {
Object claimValue = getClaims().get(claim);
Map<String, Object> convertedValue = (Map<String, Object>) ClaimConversionService.getSharedInstance()
.convert(claimValue, sourceDescriptor, targetDescriptor);
Assert.isTrue(convertedValue != null,
Assert.notNull(convertedValue,
() -> "Unable to convert claim '" + claim + "' of type '" + claimValue.getClass() + "' to Map.");
return convertedValue;
}
@ -173,7 +173,7 @@ public interface ClaimAccessor {
Object claimValue = getClaims().get(claim);
List<String> convertedValue = (List<String>) ClaimConversionService.getSharedInstance()
.convert(claimValue, sourceDescriptor, targetDescriptor);
Assert.isTrue(convertedValue != null,
Assert.notNull(convertedValue,
() -> "Unable to convert claim '" + claim + "' of type '" + claimValue.getClass() + "' to List.");
return convertedValue;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -353,7 +353,7 @@ class JoseHeader {
private static URL convertAsURL(String header, String value) {
URL convertedValue = ClaimConversionService.getSharedInstance().convert(value, URL.class);
Assert.isTrue(convertedValue != null,
Assert.notNull(convertedValue,
() -> "Unable to convert header '" + header + "' of type '" + value.getClass() + "' to URL.");
return convertedValue;
}