-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f8b5863
commit 41ac18b
Showing
7 changed files
with
100 additions
and
8 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
src/main/java/com/vzurauskas/nereides/javax/AutoResetInputStream.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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.vzurauskas.nereides.javax; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
|
||
public final class AutoResetInputStream extends InputStream { | ||
|
||
private final InputStream origin; | ||
|
||
public AutoResetInputStream(InputStream origin) { | ||
super(); | ||
origin.mark(1 << 24); | ||
this.origin = origin; | ||
} | ||
|
||
@Override | ||
public void close() throws IOException { | ||
super.close(); | ||
origin.reset(); | ||
} | ||
|
||
@Override | ||
public int read() throws IOException { | ||
return origin.read(); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.vzurauskas.nereides.javax; | ||
|
||
import java.util.function.Supplier; | ||
|
||
final class Cached<T> { | ||
private final Supplier<T> scalar; | ||
private T value; | ||
|
||
Cached(Supplier<T> scalar) { | ||
this.scalar = scalar; | ||
} | ||
|
||
public T value() { | ||
if (value == null) { | ||
value = scalar.get(); | ||
} | ||
return value; | ||
} | ||
} |
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