File tree Expand file tree Collapse file tree
src/main/java/com/apicatalog/multibase Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -85,6 +85,26 @@ public Optional<Multibase> getBase(final String encoded) {
8585 return getBase (encoded .charAt (0 ));
8686 }
8787
88+ /**
89+ * Finds a registered {@link Multibase} encoding by its name.
90+ *
91+ * <p>
92+ * This method searches through all multibases registered with this decoder and
93+ * returns the first whose {@link Multibase#name()} matches the given name
94+ * exactly.
95+ * </p>
96+ *
97+ * @param name the name of the multibase encoding (must not be {@code null})
98+ * @return an {@code Optional} containing the matching {@link Multibase}, or an
99+ * empty {@code Optional} if no encoding with the given name is found
100+ * @throws NullPointerException if {@code name} is {@code null}
101+ */
102+ public final Optional <Multibase > findBase (final String name ) {
103+ return bases .values ().stream ()
104+ .filter (base -> base .name ().equals (name ))
105+ .findFirst ();
106+ }
107+
88108 /**
89109 * Decodes a multibase-encoded string into a byte array.
90110 *
You can’t perform that action at this time.
0 commit comments