2021-10-07 15:48:52 +02:00
|
|
|
// SPDX-FileCopyrightText: 2021 Paul Schaub <vanitasvitae@fsfe.org>
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
2021-07-15 16:55:13 +02:00
|
|
|
package sop;
|
2021-01-18 18:31:50 +01:00
|
|
|
|
2021-10-10 16:34:17 +02:00
|
|
|
import java.io.ByteArrayInputStream;
|
|
|
|
import java.io.InputStream;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Tuple of a byte array and associated result object.
|
|
|
|
* @param <T> type of result
|
|
|
|
*/
|
2021-07-15 16:55:13 +02:00
|
|
|
public class ByteArrayAndResult<T> {
|
2021-01-18 18:31:50 +01:00
|
|
|
|
2021-07-15 16:55:13 +02:00
|
|
|
private final byte[] bytes;
|
|
|
|
private final T result;
|
2021-01-18 18:31:50 +01:00
|
|
|
|
2021-07-15 16:55:13 +02:00
|
|
|
public ByteArrayAndResult(byte[] bytes, T result) {
|
|
|
|
this.bytes = bytes;
|
|
|
|
this.result = result;
|
|
|
|
}
|
|
|
|
|
2021-10-10 16:34:17 +02:00
|
|
|
/**
|
|
|
|
* Return the byte array part.
|
|
|
|
*
|
|
|
|
* @return bytes
|
|
|
|
*/
|
2021-07-15 16:55:13 +02:00
|
|
|
public byte[] getBytes() {
|
|
|
|
return bytes;
|
|
|
|
}
|
|
|
|
|
2021-10-10 16:34:17 +02:00
|
|
|
/**
|
|
|
|
* Return the result part.
|
|
|
|
*
|
|
|
|
* @return result
|
|
|
|
*/
|
2021-07-15 16:55:13 +02:00
|
|
|
public T getResult() {
|
|
|
|
return result;
|
2021-01-18 18:31:50 +01:00
|
|
|
}
|
2021-10-10 16:34:17 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the byte array part as an {@link InputStream}.
|
|
|
|
*
|
|
|
|
* @return input stream
|
|
|
|
*/
|
|
|
|
public InputStream getInputStream() {
|
|
|
|
return new ByteArrayInputStream(getBytes());
|
|
|
|
}
|
2021-01-18 18:31:50 +01:00
|
|
|
}
|