/** * Returns the claim value as a {@code Boolean} or {@code null} if it does not exist. * * @param claim the name of the claim * @return the claim value or {@code null} if it does not exist */ default Boolean getClaimAsBoolean(String claim) { return (this.containsClaim(claim) ? Boolean.valueOf(this.getClaimAsString(claim)) : null); }
/** * Returns the claim value as an {@code URL} or {@code null} if it does not exist. * * @param claim the name of the claim * @return the claim value or {@code null} if it does not exist */ default URL getClaimAsURL(String claim) { if (!this.containsClaim(claim)) { return null; } try { return new URL(this.getClaimAsString(claim)); } catch (MalformedURLException ex) { throw new IllegalArgumentException("Unable to convert claim '" + claim + "' to URL: " + ex.getMessage(), ex); } }
@Test public void getClaimAsStringWhenValueIsNullThenReturnNull() { String claimName = "claim-with-null-value"; this.claims.put(claimName, null); assertThat(this.claimAccessor.getClaimAsString(claimName)).isNull(); } }
/** * Returns the claim value as a {@code Boolean} or {@code null} if it does not exist. * * @param claim the name of the claim * @return the claim value or {@code null} if it does not exist */ default Boolean getClaimAsBoolean(String claim) { return (this.containsClaim(claim) ? Boolean.valueOf(this.getClaimAsString(claim)) : null); }
/** * Returns the claim value as a {@code Boolean} or {@code null} if it does not exist. * * @param claim the name of the claim * @return the claim value or {@code null} if it does not exist */ default Boolean getClaimAsBoolean(String claim) { return (this.containsClaim(claim) ? Boolean.valueOf(this.getClaimAsString(claim)) : null); }
/** * Returns the claim value as an {@code URL} or {@code null} if it does not exist. * * @param claim the name of the claim * @return the claim value or {@code null} if it does not exist */ default URL getClaimAsURL(String claim) { if (!this.containsClaim(claim)) { return null; } try { return new URL(this.getClaimAsString(claim)); } catch (MalformedURLException ex) { throw new IllegalArgumentException("Unable to convert claim '" + claim + "' to URL: " + ex.getMessage(), ex); } }
/** * Returns the claim value as an {@code URL} or {@code null} if it does not exist. * * @param claim the name of the claim * @return the claim value or {@code null} if it does not exist */ default URL getClaimAsURL(String claim) { if (!this.containsClaim(claim)) { return null; } try { return new URL(this.getClaimAsString(claim)); } catch (MalformedURLException ex) { throw new IllegalArgumentException("Unable to convert claim '" + claim + "' to URL: " + ex.getMessage(), ex); } }