Skip to content

Commit 74d34b5

Browse files
committed
Add Javadocs for resolver
1 parent 2b26805 commit 74d34b5

4 files changed

Lines changed: 117 additions & 15 deletions

File tree

src/main/java/com/apicatalog/did/resolver/DidResolutionException.java

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,103 @@
22

33
import com.apicatalog.did.Did;
44

5+
/**
6+
* Exception thrown during DID resolution.
7+
* <p>
8+
* Indicates resolution failures such as invalid input, not found, unsupported
9+
* representation, or internal errors.
10+
* </p>
11+
*/
512
public class DidResolutionException extends Exception {
613

714
private static final long serialVersionUID = -7104603698482015381L;
815

16+
/**
17+
* Standard resolution error codes.
18+
*/
919
public enum Code {
10-
InvalidDid,
20+
/** The DID method resolution is not supported. */
21+
UnsupportedMethod,
22+
23+
/** The DID could not be found. */
1124
NotFound,
12-
RepresentationNotSupported,
25+
26+
/** An internal error occurred. */
1327
Internal,
1428
}
1529

1630
protected final Did did;
1731
protected final Code code;
1832

33+
/**
34+
* Creates a new resolution exception with a DID and code.
35+
*
36+
* @param did the DID being resolved (may be {@code null})
37+
* @param code error code
38+
*/
1939
public DidResolutionException(Did did, Code code) {
2040
this.did = did;
2141
this.code = code;
2242
}
2343

44+
/**
45+
* Creates a new resolution exception with a message.
46+
*
47+
* @param did the DID being resolved (may be {@code null})
48+
* @param code error code
49+
* @param message detail message
50+
*/
2451
public DidResolutionException(Did did, Code code, String message) {
2552
super(message);
2653
this.did = did;
2754
this.code = code;
2855
}
2956

57+
/**
58+
* Creates a new resolution exception with a cause.
59+
* <p>
60+
* Code is set to {@link Code#Internal}.
61+
* </p>
62+
*
63+
* @param did the DID being resolved (may be {@code null})
64+
* @param e the cause
65+
*/
3066
public DidResolutionException(Did did, Throwable e) {
3167
super(e);
3268
this.did = did;
3369
this.code = Code.Internal;
3470
}
3571

72+
/**
73+
* Creates a new resolution exception with a message and cause.
74+
* <p>
75+
* Code is set to {@link Code#Internal}.
76+
* </p>
77+
*
78+
* @param did the DID being resolved (may be {@code null})
79+
* @param message detail message
80+
* @param e the cause
81+
*/
3682
public DidResolutionException(Did did, String message, Throwable e) {
3783
super(message, e);
3884
this.did = did;
3985
this.code = Code.Internal;
4086
}
4187

88+
/**
89+
* Returns the DID that failed to resolve.
90+
*
91+
* @return the DID, or {@code null}
92+
*/
4293
public Did getDid() {
4394
return did;
4495
}
4596

97+
/**
98+
* Returns the resolution error code.
99+
*
100+
* @return error code
101+
*/
46102
public Code getCode() {
47103
return code;
48104
}

src/main/java/com/apicatalog/did/resolver/DidResolver.java

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,17 @@
44
import com.apicatalog.did.document.DidDocument;
55

66
/**
7-
* Performs {@link Did} resolution by expanding {@link Did} into
8-
* {@link DidDocument}.
9-
*
10-
* @see <a href="https://www.w3.org/TR/did-core/#dfn-did-resolvers">DID
11-
* resolvers</a>
7+
* A <a href="https://www.w3.org/TR/did-core/#dfn-did-resolvers">DID
8+
* Resolver</a> expands a {@link Did} into a corresponding {@link DidDocument}.
129
*/
1310
public interface DidResolver {
1411

1512
/**
16-
* Resolves the given {@link Did} into {@link DidDocument}
13+
* Resolves the given DID into a {@link DidDocument}.
1714
*
18-
* @param did To resolve
19-
* @return a new {@link DidDocument} instance
20-
*
21-
* @throws IllegalArgumentException if the given DID cannot be resolved
22-
* @throws DidResolutionException
15+
* @param did the DID to resolve (must not be {@code null})
16+
* @return the resolution result as a {@link ResolvedDidDocument}
17+
* @throws DidResolutionException if resolution fails
2318
*/
2419
ResolvedDidDocument resolve(Did did) throws DidResolutionException;
2520
}

src/main/java/com/apicatalog/did/resolver/ResolvedDidDocument.java

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,51 @@
22

33
import com.apicatalog.did.document.DidDocument;
44

5+
/**
6+
* Result of a DID resolution process.
7+
* <p>
8+
* Contains the resolved {@link DidDocument} and optional
9+
* {@link DidDocumentMetadata}.
10+
* </p>
11+
*
12+
* @see <a href="https://www.w3.org/TR/did-core/#did-resolution">DID
13+
* Resolution</a>
14+
*/
515
public interface ResolvedDidDocument {
616

17+
/**
18+
* Returns the resolved DID Document.
19+
*
20+
* @return the DID Document (never {@code null})
21+
*/
722
DidDocument document();
8-
23+
24+
/**
25+
* Returns resolution metadata associated with the DID Document.
26+
*
27+
* @return metadata, or {@code null} if none
28+
*/
929
default DidDocumentMetadata metadata() {
1030
return null;
1131
}
1232

33+
/**
34+
* Creates a resolution result containing only a document.
35+
*
36+
* @param document the resolved DID Document
37+
* @return a new {@code ResolvedDidDocument}
38+
*/
1339
static ResolvedDidDocument of(DidDocument document) {
1440
return new ImmutableResolvedDocument(document, null);
1541
}
16-
42+
43+
/**
44+
* Creates a resolution result containing a document and metadata.
45+
*
46+
* @param document the resolved DID Document
47+
* @param meta associated metadata (may be {@code null})
48+
* @return a new {@code ResolvedDidDocument}
49+
*/
1750
static ResolvedDidDocument of(DidDocument document, DidDocumentMetadata meta) {
1851
return new ImmutableResolvedDocument(document, meta);
1952
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* DID Resolution interfaces and exceptions.
3+
* <p>
4+
* Provides abstractions for resolving Decentralized Identifiers (DIDs) into DID
5+
* Documents and associated metadata, following the
6+
* <a href="https://www.w3.org/TR/did-core/#did-resolution">DID Resolution</a>
7+
* specification.
8+
* </p>
9+
*
10+
* <ul>
11+
* <li>{@link com.apicatalog.did.resolver.DidResolver} — DID resolution API</li>
12+
* <li>{@link com.apicatalog.did.resolver.ResolvedDidDocument} — resolution
13+
* result</li>
14+
* <li>{@link com.apicatalog.did.resolver.DidResolutionException} — resolution
15+
* errors</li>
16+
* </ul>
17+
*/
18+
package com.apicatalog.did.resolver;

0 commit comments

Comments
 (0)