Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.idea
target
*.iml
/.gradle/
/build/
26 changes: 19 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# co.unruly.control
# AJ's control

This repo is for studying and documenting behavior, as well as updating and changing a few various parts

## co.unruly.control

[![Build Status](https://travis-ci.org/unruly/control.svg?branch=master)](https://travis-ci.org/unruly/control)
[![Release Version](https://img.shields.io/maven-central/v/co.unruly/control.svg)](https://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22co.unruly%22%20AND%20a%3A%22control%22)
Expand Down Expand Up @@ -185,8 +189,12 @@ and failure types, and both functions must return the same type.
`Result.then` takes a function from a `Result` to a value, and then applies
that function to the result. The following lines of code are (other than generics inference issues) equivalent:
```java
ifFailed(x -> "Hello World").apply(result);
result.then(ifFailed(x -> "Hello World"));
class example {
example() {
ifFailed(x -> "Hello World").apply(result);
result.then(ifFailed(x -> "Hello World"));
}
}
```

By structuring the API like this, instead of having a fixed set of methods available, we can
Expand Down Expand Up @@ -224,10 +232,14 @@ Piper<Integer> pipe = Piper.pipe(42);
You can then chain functions on the pipe:

```java
Piper.pipe(42) // yields a Pipe containing 42
.then(x -> x + 10) // yields a Pipe containing 52
.then(x -> x * 2) // yields a Pipe containing 104
.resolve() // returns 104
class example {
example() {
Piper.pipe(42) // yields a Pipe containing 42
.then(x -> x + 10) // yields a Pipe containing 52
.then(x -> x * 2) // yields a Pipe containing 104
.resolve(); // returns 104
}
}
```

This allows us to rewrite our failing-to-compile example from above as:
Expand Down
46 changes: 46 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* This file was generated by the Gradle 'init' task.
*
* This project uses @Incubating APIs which are subject to change.
*/

plugins {
id 'java-library'
id 'maven-publish'
}

repositories {
mavenLocal()
maven {
url = uri('https://repo.maven.apache.org/maven2/')
}
}

dependencies {
api 'org.hamcrest:java-hamcrest:2.0.0.0'
api 'org.hamcrest:hamcrest-junit:2.0.0.0'
api 'org.jetbrains:annotations:RELEASE'
implementation 'org.jetbrains:annotations:16.0.2'
testImplementation 'junit:junit:4.13.1'
testImplementation 'org.mockito:mockito-core:5.4.0'
}

group = 'co.unruly'
version = '0.8.14-SNAPSHOT'
description = 'control'

java {
withSourcesJar()
withJavadocJar()
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}

tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
}

tasks.withType(Javadoc).configureEach {
options.encoding = 'UTF-8'
}
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
7 changes: 7 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
249 changes: 249 additions & 0 deletions gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading