Browse Source

implemented the exception throwed by supplier execution

master
Vyacheslav Boyko 3 years ago
parent
commit
98fcedfa59
  1. 2
      build.gradle
  2. 13
      jmonad.iml
  3. 12
      jmonad.main.iml
  4. 16
      jmonad.test.iml
  5. 5
      src/main/java/com/bvn13/jmonad/Failure.java
  6. 6
      src/main/java/com/bvn13/jmonad/Success.java
  7. 2
      src/main/java/com/bvn13/jmonad/Try.java

2
build.gradle

@ -12,5 +12,5 @@ repositories { @@ -12,5 +12,5 @@ repositories {
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
testImplementation group: 'junit', name: 'junit', version: '4.12'
}

13
jmonad.iml

@ -0,0 +1,13 @@ @@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id="jmonad" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="com.bvn13" external.system.module.version="1.0-SNAPSHOT" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
<excludeFolder url="file://$MODULE_DIR$/build" />
<excludeFolder url="file://$MODULE_DIR$/out" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

12
jmonad.main.iml

@ -0,0 +1,12 @@ @@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id="jmonad:main" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="com.bvn13" external.system.module.type="sourceSet" external.system.module.version="1.0-SNAPSHOT" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/out/production/classes" />
<exclude-output />
<content url="file://$MODULE_DIR$/src/main">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

16
jmonad.test.iml

@ -0,0 +1,16 @@ @@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id="jmonad:test" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="com.bvn13" external.system.module.type="sourceSet" external.system.module.version="1.0-SNAPSHOT" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output-test url="file://$MODULE_DIR$/out/test/classes" />
<exclude-output />
<content url="file://$MODULE_DIR$/src/test">
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="jmonad.main" />
<orderEntry type="library" scope="TEST" name="Gradle: junit:junit:4.12" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: org.hamcrest:hamcrest-core:1.3" level="project" />
</component>
<component name="TestModuleProperties" production-module="jmonad.main" />
</module>

5
src/main/java/com/bvn13/jmonad/Failure.java

@ -49,6 +49,11 @@ public class Failure<T> extends Try<T> { @@ -49,6 +49,11 @@ public class Failure<T> extends Try<T> {
throw e;
}
@Override
public T orElseThrow() throws Throwable {
throw e;
}
@Override
public Optional<T> toOptional() {
return Optional.empty();

6
src/main/java/com/bvn13/jmonad/Success.java

@ -51,7 +51,11 @@ public class Success<T> extends Try<T> { @@ -51,7 +51,11 @@ public class Success<T> extends Try<T> {
@Override
public T orElseThrow(Throwable e) throws Throwable {
Objects.requireNonNull(e);
return value;
}
@Override
public T orElseThrow() throws Throwable {
return value;
}

2
src/main/java/com/bvn13/jmonad/Try.java

@ -42,6 +42,8 @@ public abstract class Try<T> { @@ -42,6 +42,8 @@ public abstract class Try<T> {
public abstract T orElseThrow(Throwable e) throws Throwable;
public abstract T orElseThrow() throws Throwable;
public abstract Optional<T> toOptional();
public abstract boolean isSuccess();

Loading…
Cancel
Save