File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed
core-api/src/main/java/com/bloxbean/cardano/client/api Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change 9
9
* UtxoSelectionStrategy implementation.
10
10
*/
11
11
public interface AddressIterator extends Iterator <Address > {
12
+
13
+ /**
14
+ * Retrieves the first address in the iterator's list of addresses without moving the cursor.
15
+ *
16
+ * @return the first {@link Address} in the list, or null if the list is empty.
17
+ */
18
+ Address getFirst ();
19
+
12
20
/**
13
21
* Reset the pointer to the beginning
14
22
*/
15
23
void reset ();
16
24
25
+ /**
26
+ * Creates and returns a copy of this AddressIterator.
27
+ * The cloned instance is independent of the original and can be used separately.
28
+ *
29
+ * @return a new AddressIterator instance that is a copy of the current iterator.
30
+ */
31
+ AddressIterator clone ();
32
+
17
33
}
Original file line number Diff line number Diff line change @@ -12,6 +12,10 @@ public static AddressIterator of(Address address) {
12
12
return new SingleAddressIterator (address );
13
13
}
14
14
15
+ public static AddressIterator of (String address ) {
16
+ return new SingleAddressIterator (new Address (address ));
17
+ }
18
+
15
19
static class SingleAddressIterator implements AddressIterator {
16
20
private Address address ;
17
21
private Iterator <Address > iterator ;
@@ -31,9 +35,19 @@ public Address next() {
31
35
return iterator .next ();
32
36
}
33
37
38
+ @ Override
39
+ public Address getFirst () {
40
+ return address ;
41
+ }
42
+
34
43
@ Override
35
44
public void reset () {
36
45
this .iterator = List .of (address ).iterator ();
37
46
}
47
+
48
+ @ Override
49
+ public AddressIterator clone () {
50
+ return new SingleAddressIterator (address );
51
+ }
38
52
}
39
53
}
You can’t perform that action at this time.
0 commit comments