-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add annotations. Migrate to Kotlin DSL. Fix invokespecial resolution
- Loading branch information
Showing
14 changed files
with
96 additions
and
121 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
plugins { | ||
java | ||
`maven-publish` | ||
} | ||
|
||
group = "dev.xdark" | ||
version = "2.1.0" | ||
|
||
repositories.mavenCentral() | ||
|
||
dependencies { | ||
val junitVersion = "5.10.1" | ||
testImplementation("org.junit.jupiter:junit-jupiter-api:$junitVersion") | ||
testImplementation("org.junit.jupiter:junit-jupiter-engine:$junitVersion") | ||
testImplementation("org.junit.jupiter:junit-jupiter-params:$junitVersion") | ||
|
||
val asmVersion = "9.7" | ||
testImplementation("org.ow2.asm:asm:$asmVersion") | ||
testImplementation("org.ow2.asm:asm-tree:$asmVersion") | ||
|
||
val annotationsVersion = "24.1.0" | ||
compileOnly("org.jetbrains:annotations:$annotationsVersion") | ||
testCompileOnly("org.jetbrains:annotations:$annotationsVersion") | ||
} | ||
|
||
tasks.withType<JavaCompile>().configureEach { | ||
options.compilerArgs.addAll(listOf("-parameters", "-g:lines,source,vars")) | ||
} | ||
tasks.withType<Test>().configureEach { | ||
useJUnitPlatform() | ||
} | ||
|
||
java { | ||
toolchain.languageVersion.set(JavaLanguageVersion.of(17)) | ||
withSourcesJar() | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
rootProject.name = "jlinker" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,32 @@ | ||
package dev.xdark.jlinker; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
public final class Error<V> implements Result<V> { | ||
private static final List<Error<?>> ERRORS = Arrays.stream(FailureReason.values()) | ||
.map(Error::new) | ||
.collect(Collectors.toList()); | ||
.<Error<?>>map(Error::new) | ||
.toList(); | ||
private final FailureReason reason; | ||
|
||
Error(FailureReason reason) { | ||
this.reason = reason; | ||
} | ||
|
||
@Override | ||
public V getValue() { | ||
throw new UnsupportedOperationException(); | ||
public @NotNull V value() { | ||
throw new IllegalStateException(); | ||
} | ||
|
||
@Override | ||
public FailureReason getFailureReason() { | ||
public @NotNull FailureReason failureReason() { | ||
return reason; | ||
} | ||
|
||
static <V> Error<V> of(FailureReason reason) { | ||
//noinspection unchecked | ||
return (Error<V>) ERRORS.get(reason.ordinal()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,25 @@ | ||
package dev.xdark.jlinker; | ||
|
||
public interface Result<V> { | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
V getValue(); | ||
/** | ||
* Resolution result. | ||
* | ||
* @author xDark | ||
*/ | ||
public sealed interface Result<V> permits Success, Error { | ||
|
||
FailureReason getFailureReason(); | ||
/** | ||
* @return Resolution result. | ||
* @throws IllegalStateException If in error state. | ||
*/ | ||
@NotNull | ||
V value(); | ||
|
||
/** | ||
* @return Resolution result. | ||
* @throws IllegalStateException If in success state. | ||
*/ | ||
@NotNull | ||
FailureReason failureReason(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
src/main/java11/module-info.java → src/main/java/module-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
module dev.xdark.jlinker { | ||
exports dev.xdark.jlinker; | ||
requires static org.jetbrains.annotations; | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.