Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
bitwiseman committed Feb 26, 2021
1 parent 772a6c1 commit 936ab49
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/main/java/org/kohsuke/github/GHRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -2967,12 +2967,15 @@ public GHTagObject createTag(String tag, String message, String object, String t
/**
* Streams a zip archive of the repository, optionally at a given <code>ref</code>.
*
* @param <T>
* the type of result
* @param streamFunction
* The {@link InputStreamFunction} that will process the stream
* @param ref
* if <code>null</code> the repository's default branch, usually <code>master</code>,
* @throws IOException
* The IO exception.
* @return the result of reading the stream.
*/
public <T> T readZip(InputStreamFunction<T> streamFunction, String ref) throws IOException {
return downloadArchive("zip", ref, streamFunction);
Expand All @@ -2981,19 +2984,23 @@ public <T> T readZip(InputStreamFunction<T> streamFunction, String ref) throws I
/**
* Streams a tar archive of the repository, optionally at a given <code>ref</code>.
*
* @param <T>
* the type of result
* @param streamFunction
* The {@link InputStreamFunction} that will process the stream
* @param ref
* if <code>null</code> the repository's default branch, usually <code>master</code>,
* @throws IOException
* The IO exception.
* @return the result of reading the stream.
*/
public <T> T readTar(InputStreamFunction<T> streamFunction, String ref) throws IOException {
return downloadArchive("tar", ref, streamFunction);
}

private <T> T downloadArchive(@Nonnull String type, @CheckForNull String ref, @Nonnull InputStreamFunction<T> streamFunction)
throws IOException {
private <T> T downloadArchive(@Nonnull String type,
@CheckForNull String ref,
@Nonnull InputStreamFunction<T> streamFunction) throws IOException {
requireNonNull(streamFunction, "Sink must not be null");
String tailUrl = getApiTailUrl(type + "ball");
if (ref != null) {
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/org/kohsuke/github/function/FunctionThrows.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,24 @@

/**
* A functional interface, equivalent to {@link java.util.function.Function} but that allows throwing {@link Throwable}
*
* @param <T>
* the type of input
* @param <R>
* the type of output
* @param <E>
* the type of error
*/
@FunctionalInterface
public interface FunctionThrows<T, R, E extends Throwable> {
/**
* Apply r.
*
* @param input
* the input
* @return the r
* @throws E
* the e
*/
R apply(T input) throws E;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
/**
* A functional interface, equivalent to {@link java.util.function.Function} but that allows throwing {@link Throwable}
*
* @param <R>
* the type to of object to be returned
*/
@FunctionalInterface
public interface InputStreamFunction<R> extends FunctionThrows<InputStream, R, IOException> {
Expand Down

0 comments on commit 936ab49

Please sign in to comment.