Skip to content

Commit 45cb3c4

Browse files
committed
Release 1.11.1
1 parent c45300d commit 45cb3c4

28 files changed

+93
-59
lines changed

.github/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ repositories {
3636
3737
dependencies {
3838
// Default
39-
implementation 'net.dzikoysk:cdn:1.11.0'
39+
implementation 'net.dzikoysk:cdn:1.11.1'
4040
// Kotlin wrapper
41-
implementation 'net.dzikoysk:cdn-kt:1.11.0'
41+
implementation 'net.dzikoysk:cdn-kt:1.11.1'
4242
}
4343
```
4444

cdn-kt/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<parent>
2020
<artifactId>cdn-parent</artifactId>
2121
<groupId>net.dzikoysk</groupId>
22-
<version>1.11.0</version>
22+
<version>1.11.1</version>
2323
</parent>
2424
<modelVersion>4.0.0</modelVersion>
2525

cdn-kt/src/main/kotlin/net/dzikoysk/cdn/KCdn.kt

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,29 @@ package net.dzikoysk.cdn
1818

1919
import net.dzikoysk.cdn.model.KConfiguration
2020
import net.dzikoysk.cdn.model.KNamedElement
21+
import net.dzikoysk.cdn.source.Source
2122
import kotlin.reflect.KClass
2223

23-
class KCdn(private val cdn: Cdn) {
24+
class KCdn(val cdn: Cdn) {
2425

25-
fun parse(source: String): KConfiguration = KConfiguration(cdn.load { source } )
26+
companion object
2627

27-
fun <T : Any> parse(scheme: KClass<T>, source: String): T = cdn.load( { source } , scheme.java)
28+
fun parse(source: Source): KConfiguration = KConfiguration(cdn.load(source))
2829

29-
inline fun <reified T : Any> parseAs(source: String): T = this.parse(T::class, source)
30+
fun <T : Any> parse(source: Source, template: KClass<T>): T = cdn.load(source, template.java)
31+
32+
fun <T : Any> parse(source: Source, instance: T): T = cdn.load(source, instance)
33+
34+
inline fun <reified T : Any> parseAs(source: Source): T = this.parse(source, T::class)
3035

3136
fun render(element: KNamedElement<*>): String = cdn.render(element.namedElement)
3237

3338
fun render(entity: Any): String = cdn.render(entity)
3439

35-
companion object {
36-
37-
fun configure(): CdnSettings = CdnSettings()
40+
}
3841

39-
}
42+
fun Cdn.toKotlinWrapper(): KCdn =
43+
KCdn(this)
4044

41-
}
45+
fun KCdn.Companion.configure(): CdnSettings =
46+
CdnSettings()
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright (c) 2021 dzikoysk
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package net.dzikoysk.cdn
18+
19+
object KCdnFactory {
20+
21+
fun createStandard(): KCdn =
22+
Cdn.configure()
23+
.registerKotlinModule()
24+
.build()
25+
.toKotlinWrapper()
26+
27+
}

cdn-kt/src/main/kotlin/net/dzikoysk/cdn/KCdnSettingsExtension.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,5 @@ package net.dzikoysk.cdn
22

33
import net.dzikoysk.cdn.annotation.KotlinMemberResolver
44

5-
fun CdnSettings.registerKotlinModule() : CdnSettings {
6-
this.withAnnotationResolver(KotlinMemberResolver())
7-
return this
8-
}
5+
fun CdnSettings.registerKotlinModule() : CdnSettings =
6+
this.withAnnotationResolver(KotlinMemberResolver())

cdn/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<parent>
2020
<artifactId>cdn-parent</artifactId>
2121
<groupId>net.dzikoysk</groupId>
22-
<version>1.11.0</version>
22+
<version>1.11.1</version>
2323
</parent>
2424
<modelVersion>4.0.0</modelVersion>
2525

cdn/src/main/java/net/dzikoysk/cdn/Cdn.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
import net.dzikoysk.cdn.model.Configuration;
2020
import net.dzikoysk.cdn.model.Element;
21-
import net.dzikoysk.cdn.shared.source.Source;
21+
import net.dzikoysk.cdn.source.Source;
2222
import panda.utilities.FileUtils;
2323
import java.io.File;
2424
import java.io.IOException;
@@ -52,7 +52,7 @@ public static CdnSettings configure() {
5252
*
5353
* @param source the source to load
5454
* @return the parsed configuration
55-
* @see net.dzikoysk.cdn.shared.source.Source
55+
* @see net.dzikoysk.cdn.source.Source
5656
*/
5757
public Configuration load(Source source) {
5858
return new CdnReader(settings).read(source);

cdn/src/main/java/net/dzikoysk/cdn/CdnReader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import net.dzikoysk.cdn.model.Element;
2222
import net.dzikoysk.cdn.model.Section;
2323
import net.dzikoysk.cdn.model.Unit;
24-
import net.dzikoysk.cdn.shared.source.Source;
24+
import net.dzikoysk.cdn.source.Source;
2525
import panda.std.Option;
2626
import panda.utilities.StringUtils;
2727
import java.util.ArrayList;

cdn/src/main/java/net/dzikoysk/cdn/model/MutableReference.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,15 @@
1616

1717
package net.dzikoysk.cdn.model;
1818

19+
import org.jetbrains.annotations.Contract;
20+
import org.jetbrains.annotations.NotNull;
21+
1922
public interface MutableReference<V> extends Reference<V> {
2023

2124
MutableReference<V> update(V value);
2225

23-
static <T> MutableReference<T> mutable(T value) {
26+
@Contract(value = "_ -> new", pure = true)
27+
static <T> MutableReference<@NotNull T> mutableReference(@NotNull T value) {
2428
return new MutableReferenceImpl<>(value);
2529
}
2630

cdn/src/main/java/net/dzikoysk/cdn/model/MutableReferenceImpl.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package net.dzikoysk.cdn.model;
1818

19+
import org.jetbrains.annotations.NotNull;
1920
import panda.std.Subscriber;
2021
import java.util.ArrayList;
2122
import java.util.Collection;
@@ -51,13 +52,13 @@ public Reference<V> subscribe(Subscriber<? super V> subscriber) {
5152
}
5253

5354
@Override
54-
public V get() {
55+
public @NotNull V get() {
5556
return value;
5657
}
5758

5859
@SuppressWarnings("unchecked")
5960
@Override
60-
public Class<V> getType() {
61+
public @NotNull Class<V> getType() {
6162
return (Class<V>) value.getClass();
6263
}
6364

0 commit comments

Comments
 (0)