Skip to content

Commit 4e0844a

Browse files
committed
refactor: Rename member variable.
1 parent c39de06 commit 4e0844a

File tree

8 files changed

+58
-42
lines changed

8 files changed

+58
-42
lines changed

src/main/java/com/danubetech/verifiablecredentials/CredentialSubject.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ public static class Builder<B extends Builder<B>> extends JsonLDObject.Builder<B
3838

3939
private Map<String, Object> claims;
4040

41-
public Builder(CredentialSubject jsonLDObject) {
42-
super(jsonLDObject);
41+
public Builder(CredentialSubject jsonLdObject) {
42+
super(jsonLdObject);
4343
}
4444

4545
@Override
@@ -48,9 +48,9 @@ public CredentialSubject build() {
4848
super.build();
4949

5050
// add JSON-LD properties
51-
if (this.claims != null) JsonLDUtils.jsonLdAddAll(this.jsonLDObject, this.claims);
51+
if (this.claims != null) JsonLDUtils.jsonLdAddAll(this.jsonLdObject, this.claims);
5252

53-
return (CredentialSubject) this.jsonLDObject;
53+
return (CredentialSubject) this.jsonLdObject;
5454
}
5555

5656
public B claims(Map<String, Object> claims) {
@@ -75,6 +75,10 @@ public static CredentialSubject fromJson(String json) {
7575
return new CredentialSubject(readJson(json));
7676
}
7777

78+
public static CredentialSubject fromMap(Map<String, Object> jsonObject) {
79+
return new CredentialSubject(jsonObject);
80+
}
81+
7882
/*
7983
* Adding, getting, and removing the JSON-LD object
8084
*/

src/main/java/com/danubetech/verifiablecredentials/VerifiableCredential.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ public static class Builder<B extends Builder<B>> extends JsonLDObject.Builder<B
4343
private CredentialStatus credentialStatus;
4444
private LdProof ldProof;
4545

46-
public Builder(VerifiableCredential jsonLDObject) {
47-
super(jsonLDObject);
46+
public Builder(VerifiableCredential jsonLdObject) {
47+
super(jsonLdObject);
4848
this.forceContextsArray(true);
4949
this.forceTypesArray(true);
5050
this.defaultContexts(true);
@@ -57,14 +57,14 @@ public VerifiableCredential build() {
5757
super.build();
5858

5959
// add JSON-LD properties
60-
if (this.issuer != null) JsonLDUtils.jsonLdAdd(this.jsonLDObject, VerifiableCredentialKeywords.JSONLD_TERM_ISSUER, JsonLDUtils.uriToString(this.issuer));
61-
if (this.issuanceDate != null) JsonLDUtils.jsonLdAdd(this.jsonLDObject, VerifiableCredentialKeywords.JSONLD_TERM_ISSUANCEDATE, JsonLDUtils.dateToString(this.issuanceDate));
62-
if (this.expirationDate != null) JsonLDUtils.jsonLdAdd(this.jsonLDObject, VerifiableCredentialKeywords.JSONLD_TERM_EXPIRATIONDATE, JsonLDUtils.dateToString(this.expirationDate));
63-
if (this.credentialSubject != null) this.credentialSubject.addToJsonLDObject(this.jsonLDObject);
64-
if (this.credentialStatus != null) this.credentialStatus.addToJsonLDObject(this.jsonLDObject);
65-
if (this.ldProof != null) this.ldProof.addToJsonLDObject(this.jsonLDObject);
66-
67-
return (VerifiableCredential) this.jsonLDObject;
60+
if (this.issuer != null) JsonLDUtils.jsonLdAdd(this.jsonLdObject, VerifiableCredentialKeywords.JSONLD_TERM_ISSUER, JsonLDUtils.uriToString(this.issuer));
61+
if (this.issuanceDate != null) JsonLDUtils.jsonLdAdd(this.jsonLdObject, VerifiableCredentialKeywords.JSONLD_TERM_ISSUANCEDATE, JsonLDUtils.dateToString(this.issuanceDate));
62+
if (this.expirationDate != null) JsonLDUtils.jsonLdAdd(this.jsonLdObject, VerifiableCredentialKeywords.JSONLD_TERM_EXPIRATIONDATE, JsonLDUtils.dateToString(this.expirationDate));
63+
if (this.credentialSubject != null) this.credentialSubject.addToJsonLDObject(this.jsonLdObject);
64+
if (this.credentialStatus != null) this.credentialStatus.addToJsonLDObject(this.jsonLdObject);
65+
if (this.ldProof != null) this.ldProof.addToJsonLDObject(this.jsonLdObject);
66+
67+
return (VerifiableCredential) this.jsonLdObject;
6868
}
6969

7070
public B issuer(URI issuer) {
@@ -114,6 +114,10 @@ public static VerifiableCredential fromJson(String json) {
114114
return new VerifiableCredential(readJson(json));
115115
}
116116

117+
public static VerifiableCredential fromMap(Map<String, Object> map) {
118+
return new VerifiableCredential(map);
119+
}
120+
117121
/*
118122
* Adding, getting, and removing the JSON-LD object
119123
*/

src/main/java/com/danubetech/verifiablecredentials/VerifiablePresentation.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ public static class Builder<B extends Builder<B>> extends JsonLDObject.Builder<B
3636
private VerifiableCredential verifiableCredential;
3737
private LdProof ldProof;
3838

39-
public Builder(VerifiablePresentation jsonLDObject) {
40-
super(jsonLDObject);
39+
public Builder(VerifiablePresentation jsonLdObject) {
40+
super(jsonLdObject);
4141
this.forceContextsArray(true);
4242
this.forceTypesArray(true);
4343
this.defaultContexts(true);
@@ -50,10 +50,10 @@ public VerifiablePresentation build() {
5050
super.build();
5151

5252
// add JSON-LD properties
53-
if (this.verifiableCredential != null) this.verifiableCredential.addToJsonLDObject(this.jsonLDObject);
54-
if (this.ldProof != null) this.ldProof.addToJsonLDObject(this.jsonLDObject);
53+
if (this.verifiableCredential != null) this.verifiableCredential.addToJsonLDObject(this.jsonLdObject);
54+
if (this.ldProof != null) this.ldProof.addToJsonLDObject(this.jsonLdObject);
5555

56-
return (VerifiablePresentation) this.jsonLDObject;
56+
return (VerifiablePresentation) this.jsonLdObject;
5757
}
5858

5959
public B verifiableCredential(VerifiableCredential verifiableCredential) {
@@ -83,6 +83,10 @@ public static VerifiablePresentation fromJson(String json) {
8383
return new VerifiablePresentation(readJson(json));
8484
}
8585

86+
public static VerifiablePresentation fromMap(Map<String, Object> jsonObject) {
87+
return new VerifiablePresentation(jsonObject);
88+
}
89+
8690
/*
8791
* Adding, getting, and removing the JSON-LD object
8892
*/

src/main/java/com/danubetech/verifiablecredentials/credentialstatus/CredentialStatus.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,16 @@ protected CredentialStatus(Map<String, Object> jsonObject) {
3333

3434
public static class Builder<B extends Builder<B>> extends JsonLDObject.Builder<B> {
3535

36-
public Builder(CredentialStatus jsonLDObject) {
37-
super(jsonLDObject);
36+
public Builder(CredentialStatus jsonLdObject) {
37+
super(jsonLdObject);
3838
}
3939

4040
@Override
4141
public CredentialStatus build() {
4242

4343
super.build();
4444

45-
return (CredentialStatus) this.jsonLDObject;
45+
return (CredentialStatus) this.jsonLdObject;
4646
}
4747
}
4848

@@ -62,6 +62,10 @@ public static CredentialStatus fromJson(String json) {
6262
return new CredentialStatus(readJson(json));
6363
}
6464

65+
public static CredentialStatus fromMap(Map<String, Object> jsonObject) {
66+
return new CredentialStatus(jsonObject);
67+
}
68+
6569
/*
6670
* Adding, getting, and removing the JSON-LD object
6771
*/

src/main/java/com/danubetech/verifiablecredentials/credentialstatus/RevocationList2020Status.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ public static class Builder<B extends Builder<B>> extends CredentialStatus.Build
3737
private String revocationListIndex;
3838
private URI revocationListCredential;
3939

40-
public Builder(RevocationList2020Status jsonLDObject) {
41-
super(jsonLDObject);
40+
public Builder(RevocationList2020Status jsonLdObject) {
41+
super(jsonLdObject);
4242
this.defaultTypes(true);
4343
}
4444

@@ -48,10 +48,10 @@ public RevocationList2020Status build() {
4848
super.build();
4949

5050
// add JSON-LD properties
51-
if (this.revocationListIndex != null) JsonLDUtils.jsonLdAdd(this.jsonLDObject, VerifiableCredentialKeywords.JSONLD_TERM_REVOCATIONLISTINDEX, this.revocationListIndex);
52-
if (this.revocationListCredential != null) JsonLDUtils.jsonLdAdd(this.jsonLDObject, VerifiableCredentialKeywords.JSONLD_TERM_REVOCATIONLISTCREDENTIAL, JsonLDUtils.uriToString(this.revocationListCredential));
51+
if (this.revocationListIndex != null) JsonLDUtils.jsonLdAdd(this.jsonLdObject, VerifiableCredentialKeywords.JSONLD_TERM_REVOCATIONLISTINDEX, this.revocationListIndex);
52+
if (this.revocationListCredential != null) JsonLDUtils.jsonLdAdd(this.jsonLdObject, VerifiableCredentialKeywords.JSONLD_TERM_REVOCATIONLISTCREDENTIAL, JsonLDUtils.uriToString(this.revocationListCredential));
5353

54-
return (RevocationList2020Status) this.jsonLDObject;
54+
return (RevocationList2020Status) this.jsonLdObject;
5555
}
5656

5757
public B revocationListIndex(String revocationListIndex) {

src/main/java/com/danubetech/verifiablecredentials/credentialstatus/RevocationQuery2020Status.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ public static class Builder<B extends Builder<B>> extends CredentialStatus.Build
3838
private String credentialReference;
3939
private String revocationService;
4040

41-
public Builder(RevocationQuery2020Status jsonLDObject) {
42-
super(jsonLDObject);
41+
public Builder(RevocationQuery2020Status jsonLdObject) {
42+
super(jsonLdObject);
4343
this.defaultTypes(true);
4444
}
4545

@@ -49,10 +49,10 @@ public RevocationQuery2020Status build() {
4949
super.build();
5050

5151
// add JSON-LD properties
52-
if (this.credentialReference != null) JsonLDUtils.jsonLdAdd(this.jsonLDObject, VerifiableCredentialKeywords.JSONLD_TERM_CREDENTIALREFERENCE, this.credentialReference);
53-
if (this.revocationService != null) JsonLDUtils.jsonLdAdd(this.jsonLDObject, VerifiableCredentialKeywords.JSONLD_TERM_REVOCATIONSERVICE, this.revocationService);
52+
if (this.credentialReference != null) JsonLDUtils.jsonLdAdd(this.jsonLdObject, VerifiableCredentialKeywords.JSONLD_TERM_CREDENTIALREFERENCE, this.credentialReference);
53+
if (this.revocationService != null) JsonLDUtils.jsonLdAdd(this.jsonLdObject, VerifiableCredentialKeywords.JSONLD_TERM_REVOCATIONSERVICE, this.revocationService);
5454

55-
return (RevocationQuery2020Status) this.jsonLDObject;
55+
return (RevocationQuery2020Status) this.jsonLdObject;
5656
}
5757

5858
public B credentialReference(String credentialReference) {

src/main/java/com/danubetech/verifiablecredentials/proof/BlockchainHashProof2020.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ protected BlockchainHashProof2020(Map<String, Object> jsonObject) {
3535

3636
public static class Builder<B extends Builder<B>> extends LdProof.Builder<B> {
3737

38-
public Builder(BlockchainHashProof2020 jsonLDObject) {
39-
super(jsonLDObject);
38+
public Builder(BlockchainHashProof2020 jsonLdObject) {
39+
super(jsonLdObject);
4040
}
4141

4242
public BlockchainHashProof2020 build() {
@@ -45,7 +45,7 @@ public BlockchainHashProof2020 build() {
4545

4646
// add JSON-LD properties
4747

48-
return (BlockchainHashProof2020) this.jsonLDObject;
48+
return (BlockchainHashProof2020) this.jsonLdObject;
4949
}
5050
}
5151

src/main/java/com/danubetech/verifiablecredentials/w3ctestsuite/Generator.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,24 +53,24 @@ public static void main(String[] args) throws Exception {
5353

5454
if (argJwt == null) {
5555

56-
JsonLDObject jsonLDObject = JsonLDObject.fromJson(input);
56+
JsonLDObject jsonLdObject = JsonLDObject.fromJson(input);
5757

58-
if (jsonLDObject.isType(VerifiableCredential.DEFAULT_JSONLD_TYPES[0])) {
58+
if (jsonLdObject.isType(VerifiableCredential.DEFAULT_JSONLD_TYPES[0])) {
5959

60-
VerifiableCredential verifiableCredential = VerifiableCredential.fromJsonObject(jsonLDObject.getJsonObject());
60+
VerifiableCredential verifiableCredential = VerifiableCredential.fromJsonObject(jsonLdObject.getJsonObject());
6161
Validation.validate(verifiableCredential);
6262
if (verifiableCredential.getLdProof() == null) throw new IllegalStateException("No proof in VC");
63-
} else if (jsonLDObject.isType(VerifiablePresentation.DEFAULT_JSONLD_TYPES[0])) {
63+
} else if (jsonLdObject.isType(VerifiablePresentation.DEFAULT_JSONLD_TYPES[0])) {
6464

65-
VerifiablePresentation verifiablePresentation = VerifiablePresentation.fromJsonObject(jsonLDObject.getJsonObject());
65+
VerifiablePresentation verifiablePresentation = VerifiablePresentation.fromJsonObject(jsonLdObject.getJsonObject());
6666
Validation.validate(verifiablePresentation);
6767
if (verifiablePresentation.getLdProof() == null) throw new IllegalStateException("No proof in VP");
6868
} else {
6969

70-
throw new IllegalStateException("Unknown JSON-LD object type: " + jsonLDObject.getTypes());
70+
throw new IllegalStateException("Unknown JSON-LD object type: " + jsonLdObject.getTypes());
7171
}
7272

73-
output = jsonLDObject.toJson();
73+
output = jsonLdObject.toJson();
7474
} else {
7575

7676
RSAKey rsaKey = readRSAKey(argJwt);

0 commit comments

Comments
 (0)