Skip to content
This repository has been archived by the owner on Nov 2, 2021. It is now read-only.

Commit

Permalink
Merge pull request #92 from sokomishalov/feature/1.2.0
Browse files Browse the repository at this point in the history
1.2.0
  • Loading branch information
sokomishalov authored Oct 22, 2020
2 parents d8106f4 + 4b5027e commit fc3ca47
Show file tree
Hide file tree
Showing 44 changed files with 153 additions and 852 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ out/
/build/

### Visual Studio Code related ###
.vscode/
.vscode/

.flattened-pom.xml
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,13 @@ Add the dependency:
<dependency>
<groupId>com.github.sokomishalov.commons</groupId>
<artifactId>commons-[module]</artifactId>
<version>1.1.19</version>
<version>1.2.0</version>
</dependency>
```

Available modules now are:
- core
- logging
- serialization
- reactor
- coroutines
- spring
77 changes: 1 addition & 76 deletions commons-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,44 +14,11 @@
<version>${revision}</version>

<dependencies>

<!-- COMPILE DEPS -->

<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
<version>${kotlin.version}</version>
</dependency>

<!-- TEST DEPS -->

<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>${logback.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-test</artifactId>
<version>${reactor.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test-junit</artifactId>
<version>${kotlin.version}</version>
<scope>test</scope>
</dependency>

</dependencies>

<build>
Expand All @@ -65,7 +32,7 @@
<configuration>
<jvmTarget>${java.version}</jvmTarget>
<args>
<arg>-Xuse-experimental=kotlin.Experimental</arg>
<arg>-Xopt-in=kotlin.contracts.ExperimentalContracts</arg>
</args>
</configuration>
<executions>
Expand All @@ -76,49 +43,7 @@
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>test-compile</goal>
</goals>
</execution>
<execution>
<id>kapt</id>
<goals>
<goal>kapt</goal>
</goals>
<configuration>
<sourceDirs>
<sourceDir>${project.basedir}/src/main/kotlin</sourceDir>
</sourceDirs>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>testCompile</id>
<phase>test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
</plugins>
</build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,4 @@

package ru.sokomishalov.commons.core.collections

inline fun <T, K, V> Array<out T>.toMap(transform: (T) -> Pair<K, V>): Map<K, V> {
return map(transform).toMap()
}
inline fun <T, K, V> Array<out T>.toMap(transform: (T) -> Pair<K, V>): Map<K, V> = map(transform).toMap()
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,20 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:Suppress("unused")
@file:Suppress("NOTHING_TO_INLINE")

package ru.sokomishalov.commons.core.serialization
package ru.sokomishalov.commons.core.collections

import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.dataformat.protobuf.ProtobufFactory
import kotlin.contracts.contract

/**
* @author sokomishalov
*/

inline fun <T> Collection<T>?.isNotNullOrEmpty(): Boolean {
contract {
returns(true) implies (this@isNotNullOrEmpty != null)
}

val PROTOBUF_OBJECT_MAPPER: ObjectMapper = buildComplexObjectMapper(factory = ProtobufFactory())
return (this == null || this.isEmpty()).not()
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:Suppress("unused")
@file:Suppress("unused", "NOTHING_TO_INLINE")

package ru.sokomishalov.commons.core.collections

/**
* @author sokomishalov
*/

inline fun <reified K, V> Iterable<Map<K, V>>.toMap(): Map<K, V> {
return fold(mutableMapOf(), { acc, map -> acc.putAll(map).let { acc } })
}
inline fun <K, V> Iterable<Map<K, V>>.toMap(): Map<K, V> = fold(mutableMapOf(), { acc, map -> acc.putAll(map).let { acc } })

inline fun <T, K, V> Iterable<T>.toMap(transform: (T) -> Pair<K, V>): Map<K, V> {
return map(transform).toMap()
}
inline fun <T, K, V> Iterable<T>.toMap(transform: (T) -> Pair<K, V>): Map<K, V> = map(transform).toMap()
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,23 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:Suppress("unused")
@file:Suppress("unused", "NOTHING_TO_INLINE")

package ru.sokomishalov.commons.core.collections

import kotlin.contracts.contract


/**
* @author sokomishalov
*/

infix fun <K, V> Map<K, V>.containsEntryFrom(other: Map<K, V>): Boolean {
return entries.intersect(other.entries).isNullOrEmpty().not()
}
infix fun <K, V> Map<K, V>.containsEntryFrom(other: Map<K, V>): Boolean = entries.intersect(other.entries).isNullOrEmpty().not()

inline fun <K, V> Map<K, V>?.isNotNullOrEmpty(): Boolean {
contract {
returns(true) implies (this@isNotNullOrEmpty != null)
}

return (this == null || this.isEmpty()).not()
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,4 @@ package ru.sokomishalov.commons.core.consts
/**
* @author sokomishalov
*/
const val EMPTY = ""
const val LOCALHOST = "localhost"
const val EMPTY = ""

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ package ru.sokomishalov.commons.core.reflection
*/


inline fun <T : Any> Class<T>.unwrapCompanionClass(): Class<*> {
return when {
name.endsWith("\$Companion") -> enclosingClass ?: this
else -> this
}
inline fun <T : Any> Class<T>.unwrapCompanionClass(): Class<*> = when {
name.endsWith("\$Companion") -> enclosingClass ?: this
else -> this
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,22 @@

package ru.sokomishalov.commons.core.string

import kotlin.contracts.ExperimentalContracts
import kotlin.contracts.contract

/**
* @author sokomishalov
*/

@OptIn(ExperimentalContracts::class)
inline fun CharSequence?.isNotNullOrBlank(): Boolean {
contract {
returns(true) implies (this@isNotNullOrBlank != null)
}
return (this == null || this.isBlank()).not()
return (this == null || isBlank()).not()
}

inline fun CharSequence?.isNotNullOrEmpty(): Boolean {
contract {
returns(true) implies (this@isNotNullOrEmpty != null)
}
return (this == null || length == 0).not()
}
Loading

0 comments on commit fc3ca47

Please sign in to comment.