![JAR search and dependency download from the Maven repository](/logo.png)
com.swak.license.api.io.GenSink Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of swak-license-core Show documentation
Show all versions of swak-license-core Show documentation
swak component of trueLicense core
The newest version!
/*
* Copyright (C) 2013-2018 Schlichtherle IT Services.
* All rights reserved. Use is subject to license terms.
*/
package com.swak.license.api.io;
import com.swak.license.api.io.function.XConsumer;
import com.swak.license.api.io.function.XFunction;
/**
* A generic abstraction for safe access to some closeable output resource - DO NOT USE THIS DIRECTLY!
* This type primarily exists to enforce consistency between {@link Sink} and {@link ArchiveSink}.
*
* @author Christian Schlichtherle
*/
@FunctionalInterface
public interface GenSink {
/**
* Returns an output socket for safe access to some closeable output resource.
*/
Socket output();
/**
* Loans a closeable resource from the {@linkplain #output() output socket} to the given consumer.
* The loaned resource will be closed upon return from this method.
*/
default void acceptWriter(XConsumer super T> writer) throws Exception {
output().accept(writer);
}
/**
* Loans a closeable resource from the {@linkplain #output() output socket} to the given function and returns its
* value.
* The loaned resource will be closed upon return from this method.
* It is an error to return the loaned resource from the given function or any other object which holds on to it.
*/
default U applyWriter(XFunction super T, ? extends U> writer) throws Exception {
return output().apply(writer);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy