Skip to content

Commit 83aef25

Browse files
committed
Add bases() + size() methods. (#96)
1 parent e20e3b2 commit 83aef25

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

src/main/java/com/apicatalog/multibase/MultibaseDecoder.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,32 @@ public byte[] decode(final String encoded) {
9898
.map(base -> base.decode(encoded))
9999
.orElseThrow(() -> new IllegalArgumentException("Unsupported multibase encoding [" + encoded.charAt(0) + "]."));
100100
}
101+
102+
/**
103+
* Returns an unmodifiable view of the registered multibase encodings.
104+
*
105+
* <p>
106+
* The returned map associates each multibase prefix character with its
107+
* corresponding {@link Multibase} instance. Attempts to modify the map (e.g.
108+
* {@code put}, {@code remove}) will result in an
109+
* {@link UnsupportedOperationException}.
110+
* </p>
111+
*
112+
* @return an unmodifiable map of prefix characters to {@link Multibase}
113+
* instances
114+
*/
115+
public Map<Character, Multibase> bases() {
116+
return bases;
117+
}
118+
119+
/**
120+
* Returns the number of multibase encodings currently registered with this
121+
* decoder.
122+
*
123+
* @return the count of registered encodings
124+
*/
125+
public long size() {
126+
return bases.size();
127+
}
128+
101129
}

0 commit comments

Comments
 (0)