Skip to content

Commit 4e71bcd

Browse files
committed
Improve kdocs
1 parent 131a0d5 commit 4e71bcd

File tree

3 files changed

+66
-27
lines changed

3 files changed

+66
-27
lines changed

src/main/kotlin/io/vavr/kotlin/Collections.kt

+52-18
Original file line numberDiff line numberDiff line change
@@ -31,120 +31,154 @@ import io.vavr.collection.Stream
3131
*/
3232

3333
/**
34+
* Creates a [List] of the given elements.
35+
*
3436
* @see List.of
3537
*/
3638
fun <T> list(vararg t: T):
3739
List<T> = List.of(*t)
3840

3941
/**
40-
* Converts a Value (that is, _any_ Vavr data class) into a Kotlin MutableList
42+
* Converts a Vavr [Value] (that is, _any_ Vavr data class) into a Kotlin [MutableList].
4143
*/
4244
fun <T> Value<T>.toMutableList():
4345
MutableList<T> = this.toJavaList().toMutableList()
4446

4547
/**
46-
* Converts a Kotlin Iterable into a List
48+
* Converts a Kotlin [Iterable] into a Vavr [List].
49+
*
50+
* @see List.ofAll
4751
*/
4852
fun <T> Iterable<T>.toVavrList():
4953
List<T> = List.ofAll(this)
5054

5155
/**
52-
* Converts a Kotlin Array into a List
56+
* Converts a Kotlin [Array] into a Vavr [List].
57+
*
58+
* @see List.ofAll
5359
*/
5460
fun <T> Array<T>.toVavrList():
5561
List<T> = List.ofAll(this.asIterable())
5662

5763
/**
64+
* Creates a Vavr [Stream] of the given elements.
65+
*
5866
* @see Stream.of
5967
*/
6068
fun <T> stream(vararg t: T):
6169
Stream<T> = Stream.of(*t)
6270

6371
/**
72+
* Converts a Kotlin [Iterable] into a Vavr [Stream].
73+
*
6474
* @see Stream.ofAll
6575
*/
6676
fun <T> Iterable<T>.toVavrStream():
6777
Stream<T> = Stream.ofAll(this)
6878

6979
/**
70-
* Converts a Kotlin Array into a Stream
80+
* Converts a Kotlin [Array] into a Vavr [Stream].
81+
*
82+
* @see Stream.ofAll
7183
*/
7284
fun <T> Array<T>.toVavrStream():
7385
Stream<T> = Stream.ofAll(this.asIterable())
7486

7587
/**
76-
* Converts a Kotlin Sequence into a Stream
88+
* Converts a Kotlin [Sequence] into a Vavr [Stream].
89+
*
90+
* @see Stream.ofAll
7791
*/
7892
fun <T> Sequence<T>.toVavrStream():
7993
Stream<T> = Stream.ofAll(this.asIterable())
8094

8195
/**
82-
* Converts a Kotlin Map into a Vavr Map
96+
* Converts a Kotlin [kotlin.collections.Map] into a Vavr [Map].
97+
*
98+
* @see HashMap.ofAll
8399
*/
84100
fun <K, V> kotlin.collections.Map<K, V>.toVavrMap():
85101
io.vavr.collection.Map<K, V> = io.vavr.collection.HashMap.ofAll(this)
86102

87103
/**
88-
* Converts a Vavr Map to a Kotlin MutableMap
104+
* Converts a Vavr [Map] to a Kotlin [MutableMap].
89105
*/
90106
fun <K, V> io.vavr.collection.Map<K, V>.toMutableMap():
91107
kotlin.collections.MutableMap<K, V> = this.toJavaMap().toMutableMap()
92108

93109
/**
94-
* Creates a Vavr HashMap from a series of Kotlin Pairs
110+
* Creates a Vavr [HashMap] from a series of Kotlin [Pair]s.
95111
*/
96112
fun <K, V> hashMap(vararg p: Pair<K, V>):
97113
io.vavr.collection.HashMap<K, V> =
98114
io.vavr.collection.HashMap.ofEntries(p.asIterable().map { it.tuple() })
99115

100116
/**
101-
* Creates a Vavr LinkedHashMap from a series of Kotlin Pairs
117+
* Creates a Vavr [LinkedHashMap] from a series of Kotlin [Pair]s.
102118
*/
103119
fun <K, V> linkedHashMap(vararg p: Pair<K, V>):
104120
io.vavr.collection.LinkedHashMap<K, V> =
105121
io.vavr.collection.LinkedHashMap.ofEntries(p.asIterable().map { it.tuple() })
106122

107123
/**
108-
* Creates a Vavr TreeMap from a series of Kotlin Pairs.
109-
* Notice that the keys of a TreeMap must be Comparable
124+
* Creates a Vavr [TreeMap] from a series of Kotlin [Pair]s.
125+
*
126+
* Note that the keys of a [TreeMap] must be [Comparable].
127+
*
128+
* @param K a [Comparable] key
129+
* @see TreeMap.ofEntries
110130
*/
111131
fun <K : Comparable<K>, V> treeMap(vararg p: Pair<K, V>):
112132
io.vavr.collection.TreeMap<K, V> =
113133
io.vavr.collection.TreeMap.ofEntries(p.asIterable().map { it.tuple() })
114134

115135
/**
116-
* Returns the value associated with a key, or null if the key is not contained in the map.
136+
* Returns the value associated with a key, or null if the key is not contained in the [Map].
137+
*
138+
* @see Map.getOrElse
117139
*/
118140
fun <K, V> Map<K, V>.getOrNull(key: K):
119141
V? = this.getOrElse(key, null)
120142

121143
/**
122-
* Converts a Kotlin Set into a Vavr Set
144+
* Creates a Vavr [HashSet] of the given elements.
145+
*
146+
* @see HashSet.ofAll
123147
*/
124148
fun <T> kotlin.collections.Set<T>.toVavrSet():
125149
io.vavr.collection.Set<T> = io.vavr.collection.HashSet.ofAll(this)
126150

127151
/**
128-
* Converts a Vavr Set into a Kotlin MutableSet
152+
* Converts a Kotlin [Array] into a Vavr [Set].
153+
*
154+
* @see HashSet.ofAll
129155
*/
130156
fun <T> io.vavr.collection.Set<T>.toMutableSet():
131157
kotlin.collections.MutableSet<T> = this.toJavaSet().toMutableSet()
132158

133159
/**
134-
* Creates a Vavr HashSet
160+
* Converts a Kotlin [Sequence] into a Vavr [List].
161+
*
162+
* @see HashSet.ofAll
135163
*/
136164
fun <T> hashSet(vararg t: T):
137165
io.vavr.collection.HashSet<T> = io.vavr.collection.HashSet.ofAll(t.asIterable())
138166

139167
/**
140-
* Creates a Vavr LinkedHashSet
168+
* Creates a Vavr [LinkedHashSet] of the given elements.
169+
*
170+
* @see LinkedHashSet.ofAll
141171
*/
142172
fun <T> linkedHashSet(vararg t: T):
143173
io.vavr.collection.LinkedHashSet<T> = io.vavr.collection.LinkedHashSet.ofAll(t.asIterable())
144174

145175
/**
146-
* Creates a Vavr TreeSet.
147-
* Notice that the elements of a TreeSet must be Comparable
176+
* Creates a Vavr [TreeSet] from a series of Kotlin [Pair]s.
177+
*
178+
* Note that the elements of a [TreeSet] must be [Comparable].
179+
*
180+
* @param t a [Comparable] element
181+
* @see TreeSet.ofAll
148182
*/
149183
fun <T : Comparable<T>> treeSet(vararg t: T):
150184
io.vavr.collection.TreeSet<T> =

src/main/kotlin/io/vavr/kotlin/Control.kt

+9-6
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ import io.vavr.control.Validation
3535
*/
3636

3737
/**
38-
* Creates an Option of a nullable.
39-
* @return None() for null, Some(this) for a present value
38+
* Creates an [Option] of a nullable.
39+
*
40+
* @return [Option.none] for null or [Option.some] for a present value.
4041
*/
4142
fun <A> A?.option():
4243
Option<A> = if (this == null) none() else some(this)
@@ -54,15 +55,17 @@ fun <A> none():
5455
Option<A> = Option.none()
5556

5657
/**
57-
* Creates an Option predicated on a Boolean, using the supplied value.
58-
* @return Some(a) if this is true, None() otherwise
58+
* Creates an [Option] predicated on a Boolean, using the supplied value.
59+
*
60+
* @return [Option.some] if this is true, otherwise [Option.none].
5961
*/
6062
fun <A> Boolean.option(a: A):
6163
Option<A> = if (this) some(a) else none()
6264

6365
/**
64-
* Creates an Option predicated on a Boolean, using the supplier of value.
65-
* @return Some(a.invoke()) if this is true, None() otherwise
66+
* Creates an [Option] predicated on a Boolean, using the supplier of value.
67+
*
68+
* @return [Some(a.invoke())][Option.some] if this is true, otherwise [Option.none].
6669
*/
6770
fun <A> Boolean.option(a: () -> A):
6871
Option<A> = if (this) some(a.invoke()) else none()

src/main/kotlin/io/vavr/kotlin/Tuples.kt

+5-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ package io.vavr.kotlin
2222
import io.vavr.*
2323

2424
/**
25-
* Constructors and sequence() extensions for the Vavr Tuple
25+
* Constructors and sequence() extensions for the Vavr Tuple.
2626
*
2727
* @author Alex Zuzin (github.com/zvozin)
2828
*/
@@ -76,13 +76,15 @@ fun <T1, T2, T3, T4, T5, T6, T7, T8> tuple(t1: T1, t2: T2, t3: T3, t4: T4, t5: T
7676
Tuple8<T1, T2, T3, T4, T5, T6, T7, T8> = Tuple.of(t1, t2, t3, t4, t5, t6, t7, t8)
7777

7878
/**
79-
* Creates a Tuple out of a Kotlin Pair
79+
* Creates a [Tuple] out of a Kotlin [Pair].
80+
*
81+
* @see Tuple.of
8082
*/
8183
fun <T1, T2> Pair<T1, T2>.tuple():
8284
Tuple2<T1, T2> = Tuple.of(this.first, this.second)
8385

8486
/**
85-
* Creates a Kotlin Pair out of a Tuple
87+
* Creates a Kotlin [Pair] out of a [Tuple].
8688
*/
8789
fun <T1, T2> Tuple2<T1, T2>.pair():
8890
Pair<T1, T2> = Pair(this._1, this._2)

0 commit comments

Comments
 (0)