From f3e017312938efa00bb289cf633695af2846569c Mon Sep 17 00:00:00 2001 From: Xavi Aracil Date: Tue, 16 Apr 2024 14:46:20 +0200 Subject: [PATCH] Added constructors --- .../vc/W3CVerifiableCredentialDM2.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/W3CVerifiableCredentialDM2.java b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/W3CVerifiableCredentialDM2.java index cea520c..5f0ae74 100644 --- a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/W3CVerifiableCredentialDM2.java +++ b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/W3CVerifiableCredentialDM2.java @@ -2,20 +2,35 @@ package org.oneedtech.inspect.vc; import java.net.URI; import java.util.Date; +import java.util.Map; + +import com.fasterxml.jackson.annotation.JsonCreator; import foundation.identity.jsonld.JsonLDUtils; public class W3CVerifiableCredentialDM2 extends com.danubetech.verifiablecredentials.VerifiableCredential { public static final URI[] DEFAULT_JSONLD_CONTEXTS = { URI.create(VerifiableCredential.JSONLD_CONTEXT_W3C_CREDENTIALS_V2) }; - public Date getValidFrom() { + @JsonCreator + public W3CVerifiableCredentialDM2() { + super(); + } + + protected W3CVerifiableCredentialDM2(Map jsonObject) { + super(jsonObject); + } + + public static W3CVerifiableCredentialDM2 fromJson(String json) { + return new W3CVerifiableCredentialDM2(readJson(json)); + } + + public Date getValidFrom() { return JsonLDUtils.stringToDate(JsonLDUtils.jsonLdGetString(this.getJsonObject(), JSONLD_TERM_VALIDFROM)); } public Date getValidUntil() { return JsonLDUtils.stringToDate(JsonLDUtils.jsonLdGetString(this.getJsonObject(), JSONLD_TERM_VALIDUNTIL)); } - private static final String JSONLD_TERM_VALIDFROM = "validFrom"; private static final String JSONLD_TERM_VALIDUNTIL = "validUntil";