Formatting

This commit is contained in:
Liam Newman
2021-02-26 12:00:40 -08:00
parent 772a6c112b
commit 936ab499ce
3 changed files with 27 additions and 2 deletions

View File

@@ -2967,12 +2967,15 @@ public class GHRepository extends GHObject {
/** /**
* Streams a zip archive of the repository, optionally at a given <code>ref</code>. * Streams a zip archive of the repository, optionally at a given <code>ref</code>.
* *
* @param <T>
* the type of result
* @param streamFunction * @param streamFunction
* The {@link InputStreamFunction} that will process the stream * The {@link InputStreamFunction} that will process the stream
* @param ref * @param ref
* if <code>null</code> the repository's default branch, usually <code>master</code>, * if <code>null</code> the repository's default branch, usually <code>master</code>,
* @throws IOException * @throws IOException
* The IO exception. * The IO exception.
* @return the result of reading the stream.
*/ */
public <T> T readZip(InputStreamFunction<T> streamFunction, String ref) throws IOException { public <T> T readZip(InputStreamFunction<T> streamFunction, String ref) throws IOException {
return downloadArchive("zip", ref, streamFunction); return downloadArchive("zip", ref, streamFunction);
@@ -2981,19 +2984,23 @@ public class GHRepository extends GHObject {
/** /**
* Streams a tar archive of the repository, optionally at a given <code>ref</code>. * Streams a tar archive of the repository, optionally at a given <code>ref</code>.
* *
* @param <T>
* the type of result
* @param streamFunction * @param streamFunction
* The {@link InputStreamFunction} that will process the stream * The {@link InputStreamFunction} that will process the stream
* @param ref * @param ref
* if <code>null</code> the repository's default branch, usually <code>master</code>, * if <code>null</code> the repository's default branch, usually <code>master</code>,
* @throws IOException * @throws IOException
* The IO exception. * The IO exception.
* @return the result of reading the stream.
*/ */
public <T> T readTar(InputStreamFunction<T> streamFunction, String ref) throws IOException { public <T> T readTar(InputStreamFunction<T> streamFunction, String ref) throws IOException {
return downloadArchive("tar", ref, streamFunction); return downloadArchive("tar", ref, streamFunction);
} }
private <T> T downloadArchive(@Nonnull String type, @CheckForNull String ref, @Nonnull InputStreamFunction<T> streamFunction) private <T> T downloadArchive(@Nonnull String type,
throws IOException { @CheckForNull String ref,
@Nonnull InputStreamFunction<T> streamFunction) throws IOException {
requireNonNull(streamFunction, "Sink must not be null"); requireNonNull(streamFunction, "Sink must not be null");
String tailUrl = getApiTailUrl(type + "ball"); String tailUrl = getApiTailUrl(type + "ball");
if (ref != null) { if (ref != null) {

View File

@@ -2,8 +2,24 @@ package org.kohsuke.github.function;
/** /**
* A functional interface, equivalent to {@link java.util.function.Function} but that allows throwing {@link Throwable} * 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 @FunctionalInterface
public interface FunctionThrows<T, R, E extends Throwable> { 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; R apply(T input) throws E;
} }

View File

@@ -6,6 +6,8 @@ import java.io.InputStream;
/** /**
* A functional interface, equivalent to {@link java.util.function.Function} but that allows throwing {@link Throwable} * 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 @FunctionalInterface
public interface InputStreamFunction<R> extends FunctionThrows<InputStream, R, IOException> { public interface InputStreamFunction<R> extends FunctionThrows<InputStream, R, IOException> {