diff --git a/README.md b/README.md
index 96e0606..08ed3ba 100644
--- a/README.md
+++ b/README.md
@@ -10,7 +10,10 @@ Licensed under the Apache 2.0 License
#### Geographical utils
* Mercator(EPSG:3857) to WSG84 convertor
* WSG84 to Mercator(EPSG:3857) convertor
-* Distance calculation between two WSG84 points
+* Distance calculation between two WSG84 points
+
+#### Collector utils
+* Collectors for Java streams
#### Collections utils
* Null-safe methods to work with collections
@@ -18,6 +21,10 @@ Licensed under the Apache 2.0 License
#### Optional utils
* Optional providers for different situations
+#### Functional utils
+
+* Functional utility methods
+
#### String Utils
* Null-safe methods to work with Strings
@@ -33,6 +40,10 @@ Licensed under the Apache 2.0 License
#### Math utils
* Methods that can help with computations
+#### Number utils
+
+* Methods that can help with numbers
+
#### Random utils
* Methods that can provide some random values or randomize arrays
@@ -50,6 +61,14 @@ Licensed under the Apache 2.0 License
* Tuple
* Triple
+#### Builders
+
+* List builder
+* Set builder
+* Map builder
+* Transformer
+* XBuilder
+
#### IO
##### TemporaryFile
@@ -87,7 +106,7 @@ Just add this to your **pom.xml**
com.hijackermax
- utils
- 0.0.7
+ utils
+ 0.0.8
```
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 486e352..d4def85 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
com.hijackermax
utils
- 0.0.7
+ 0.0.8
utils
A set of utils that can help in app development
@@ -55,7 +55,7 @@
org.junit.jupiter
junit-jupiter
- 5.9.2
+ 5.10.0
test
diff --git a/src/main/java/com/hijackermax/utils/builders/CollectionBuilder.java b/src/main/java/com/hijackermax/utils/builders/CollectionBuilder.java
new file mode 100644
index 0000000..b3c090b
--- /dev/null
+++ b/src/main/java/com/hijackermax/utils/builders/CollectionBuilder.java
@@ -0,0 +1,79 @@
+package com.hijackermax.utils.builders;
+
+import java.util.Collection;
+import java.util.function.Consumer;
+import java.util.function.Supplier;
+
+/**
+ * Interface for abstract collection builder
+ *
+ * @param collection element type
+ * @param collection type
+ * @param builder type
+ * @since 0.0.8
+ */
+public interface CollectionBuilder, B extends CollectionBuilder> {
+
+ /**
+ * Adds provided value to collection which is being built
+ *
+ * @param value value that should be added to collection
+ * @return builder instance
+ * @since 0.0.8
+ */
+ B add(T value);
+
+ /**
+ * Adds result of invoking of provided value supplier to collection which is being built
+ *
+ * @param valueSupplier supplier of value that should be added to collection
+ * @return builder instance
+ * @since 0.0.8
+ */
+ B add(Supplier extends T> valueSupplier);
+
+ /**
+ * Adds values from provided collection to collection which is being built
+ *
+ * @param values collection that should be added to collection which is being built
+ * @return builder instance
+ * @since 0.0.8
+ */
+ B addAll(Collection extends T> values);
+
+ /**
+ * Builds collection
+ *
+ * @return built collection
+ * @since 0.0.8
+ */
+ C build();
+
+ /**
+ * Builds unmodifiable representation of built collection
+ *
+ * @return unmodifiable representation of built collection
+ * @since 0.0.8
+ */
+ C buildUnmodifiable();
+
+ /**
+ * Builds collection and provides in to the consumer
+ *
+ * @param collectionConsumer resulting collection consumer
+ * @since 0.0.8
+ */
+ default void provide(Consumer collectionConsumer) {
+ collectionConsumer.accept(build());
+ }
+
+ /**
+ * Builds unmodifiable representation of built collection and provides in to the consumer
+ *
+ * @param collectionConsumer resulting unmodifiable collection consumer
+ * @since 0.0.8
+ */
+ default void provideUnmodifiable(Consumer collectionConsumer) {
+ collectionConsumer.accept(buildUnmodifiable());
+ }
+}
diff --git a/src/main/java/com/hijackermax/utils/builders/DictionaryBuilder.java b/src/main/java/com/hijackermax/utils/builders/DictionaryBuilder.java
new file mode 100644
index 0000000..7e88c84
--- /dev/null
+++ b/src/main/java/com/hijackermax/utils/builders/DictionaryBuilder.java
@@ -0,0 +1,81 @@
+package com.hijackermax.utils.builders;
+
+import java.util.Map;
+import java.util.function.Consumer;
+
+/**
+ * Interface for abstract map builder
+ *
+ * @param map keys type
+ * @param map values type
+ * @param map type
+ * @param builder type
+ * @since 0.0.8
+ */
+public interface DictionaryBuilder, B extends DictionaryBuilder> {
+
+ /**
+ * Puts provided key-value pair to map which is being built
+ *
+ * @param key key that should be added to map
+ * @param value value that should be added to map
+ * @return builder instance
+ * @since 0.0.8
+ */
+ B put(K key, V value);
+
+ /**
+ * Puts provided key-value pair to map which is being built if some value wasn't added previously with the same key
+ *
+ * @param key key that should be added to map
+ * @param value value that should be added to map
+ * @return builder instance
+ * @since 0.0.8
+ */
+ B putIfAbsent(K key, V value);
+
+ /**
+ * Puts key-value pairs from provided map to map which is being built
+ *
+ * @param values map that should be added to map which is being built
+ * @return builder instance
+ * @since 0.0.8
+ */
+ B putAll(Map extends K, ? extends V> values);
+
+ /**
+ * Builds map
+ *
+ * @return built map
+ * @since 0.0.8
+ */
+ M build();
+
+ /**
+ * Builds unmodifiable representation of built map
+ *
+ * @return unmodifiable representation of built map
+ * @since 0.0.8
+ */
+ M buildUnmodifiable();
+
+ /**
+ * Builds map and provides in to the consumer
+ *
+ * @param mapConsumer resulting map consumer
+ * @since 0.0.8
+ */
+ default void provide(Consumer mapConsumer) {
+ mapConsumer.accept(build());
+ }
+
+ /**
+ * Builds unmodifiable representation of built map and provides in to the consumer
+ *
+ * @param mapConsumer resulting unmodifiable map consumer
+ * @since 0.0.8
+ */
+ default void provideUnmodifiable(Consumer mapConsumer) {
+ mapConsumer.accept(buildUnmodifiable());
+ }
+}
diff --git a/src/main/java/com/hijackermax/utils/builders/ListBuilder.java b/src/main/java/com/hijackermax/utils/builders/ListBuilder.java
new file mode 100644
index 0000000..127b948
--- /dev/null
+++ b/src/main/java/com/hijackermax/utils/builders/ListBuilder.java
@@ -0,0 +1,142 @@
+package com.hijackermax.utils.builders;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+import java.util.function.Supplier;
+
+/**
+ * List builder, builds {@link ArrayList} if not initialized with custom list constructor via {@link com.hijackermax.utils.builders.ListBuilder#with(Supplier)}
+ * Does not support null elements
+ *
+ * @param list element type
+ * @since 0.0.8
+ */
+public class ListBuilder implements CollectionBuilder, ListBuilder> {
+ private final List data;
+
+ private ListBuilder() {
+ this.data = new ArrayList<>();
+ }
+
+ private ListBuilder(Collection extends T> data) {
+ this.data = new ArrayList<>(Objects.requireNonNull(data));
+ }
+
+ private ListBuilder(T value) {
+ this(List.of(Objects.requireNonNull(value)));
+ }
+
+ private ListBuilder(Supplier> listSupplier) {
+ this.data = Objects.requireNonNull(listSupplier.get());
+ }
+
+ /**
+ * Builds instance of list builder with provided list supplier as base collection
+ *
+ * @param listSupplier new base collection instance supplier
+ * @param collection element type
+ * @return builder instance with custom base collection
+ * @since 0.0.8
+ */
+ public static ListBuilder with(Supplier> listSupplier) {
+ return new ListBuilder<>(listSupplier);
+ }
+
+ /**
+ * Builds instance of list builder with {@link ArrayList} base collection
+ *
+ * @param collection element type
+ * @return builder instance with {@link ArrayList} base collection
+ * @since 0.0.8
+ */
+ public static ListBuilder of() {
+ return new ListBuilder<>();
+ }
+
+ /**
+ * Builds instance of list builder with {@link ArrayList} base collection and inserts provided value
+ *
+ * @param value element that should be inserted into list
+ * @param collection element type
+ * @return builder instance with {@link ArrayList} base collection
+ * @since 0.0.8
+ */
+ public static ListBuilder of(T value) {
+ return new ListBuilder<>(value);
+ }
+
+ /**
+ * Builds instance of list builder with {@link ArrayList} base collection and inserts provided collection values
+ *
+ * @param data element collection which values should be inserted into list
+ * @param collection element type
+ * @return builder instance with {@link ArrayList} base collection
+ * @since 0.0.8
+ */
+ public static ListBuilder of(Collection extends T> data) {
+ return new ListBuilder<>(data);
+ }
+
+ /**
+ * Adds provided value to list which is being built
+ *
+ * @param value value that should be added to collection
+ * @return builder instance
+ * @since 0.0.8
+ */
+ @Override
+ public ListBuilder add(T value) {
+ data.add(Objects.requireNonNull(value));
+ return this;
+ }
+
+ /**
+ * Adds values from provided collection to list which is being built
+ *
+ * @param values collection that should be added to collection which is being built
+ * @return builder instance
+ * @since 0.0.8
+ */
+ @Override
+ public ListBuilder addAll(Collection extends T> values) {
+ data.addAll(Objects.requireNonNull(values));
+ return this;
+ }
+
+ /**
+ * Adds result of invoking of provided value supplier to list which is being built
+ *
+ * @param valueSupplier supplier of value that should be added to collection
+ * @return builder instance
+ * @since 0.0.8
+ */
+ @Override
+ public ListBuilder add(Supplier extends T> valueSupplier) {
+ return add(valueSupplier.get());
+ }
+
+ /**
+ * Builds list
+ *
+ * @return built list
+ * @since 0.0.8
+ */
+ @Override
+ public List build() {
+ return data;
+ }
+
+ /**
+ * Builds unmodifiable representation of built list
+ *
+ * @return unmodifiable representation of built list
+ * @since 0.0.8
+ */
+ @Override
+ public List buildUnmodifiable() {
+ return Collections.unmodifiableList(data);
+ }
+}
diff --git a/src/main/java/com/hijackermax/utils/builders/MapBuilder.java b/src/main/java/com/hijackermax/utils/builders/MapBuilder.java
new file mode 100644
index 0000000..769ee7a
--- /dev/null
+++ b/src/main/java/com/hijackermax/utils/builders/MapBuilder.java
@@ -0,0 +1,163 @@
+package com.hijackermax.utils.builders;
+
+import java.util.Collections;
+import java.util.EnumMap;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+import java.util.function.Supplier;
+
+/**
+ * Map builder, builds {@link HashMap} if not initialized with custom map constructor via {@link com.hijackermax.utils.builders.MapBuilder#with(Supplier)} or {@link com.hijackermax.utils.builders.MapBuilder#ofEnum(Class)}
+ *
+ * @param key type
+ * @param value type
+ * @since 0.0.8
+ */
+public class MapBuilder implements DictionaryBuilder, MapBuilder> {
+ private final Map data;
+
+ private MapBuilder() {
+ this.data = new HashMap<>();
+ }
+
+ private MapBuilder(Map extends K, ? extends V> data) {
+ this.data = new HashMap<>(Objects.requireNonNull(data));
+ }
+
+ private MapBuilder(K key, V value) {
+ this(Map.of(key, value));
+ }
+
+ private MapBuilder(Supplier