Skip to content

Instantly share code, notes, and snippets.

💭
R&D on Concurrency,Data Structures & Search for new Languages...Not enough time!

Stefano Fago stefanofago73

💭
R&D on Concurrency,Data Structures & Search for new Languages...Not enough time!
Block or report user

Report or block stefanofago73

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View it.fago.experiment.autocloseable.eh.AutocloseableMain2.java
package it.fago.experiment.autocloseable.eh;
import static it.fago.experiment.autocloseable.eh.Autocloser2.autoclose;
import it.fago.experiment.autocloseable.IService;
import it.fago.experiment.autocloseable.Service;
public class AutocloseableMain2 {
public static void main(String[] args) {
View it.fago.experiment.autocloseable.eh.LeanCloseable.java
package it.fago.experiment.autocloseable.eh;
import java.util.function.Consumer;
import java.util.function.Supplier;
public class LeanCloseable<S> implements Supplier<S>, AutoCloseable {
private S target;
private Consumer<S> callback;
View it.fago.experiment.autocloseable.eh.Autocloser2.java
package it.fago.experiment.autocloseable.eh;
import java.util.function.Consumer;
public class Autocloser2 {
public static final <S> LeanCloseable<S> autoclose(S element, Consumer<S> elementInvocation) {
return new LeanCloseable<S>(element, elementInvocation);
}
View it.fago.experiment.autocloseable.dirty.AutocloseableMain.java
package it.fago.experiment.autocloseable.dirty;
import static it.fago.experiment.autocloseable.dirty.AutoCloserDirty.autoclose;
import it.fago.experiment.autocloseable.IService;
import it.fago.experiment.autocloseable.Service;
public class AutocloseableMain {
public static void main(String[] args) {
View it.fago.experiment.autocloseable.dirty.AutoCloser.java
package it.fago.experiment.autocloseable.dirty;
import java.util.function.BiFunction;
import java.util.function.Consumer;
public class AutoCloser{
public static final <S> AutoCloseable autoclose(S element, Consumer<S> elementInvocation) {
return ((BiFunction<S, Consumer<S>, AutoCloseable>) (subject, callback) -> () -> callback.accept(subject)).apply(element, elementInvocation);
}
View it.fago.experiment.autocloseable.Service.java
package it.fago.experiment.autocloseable;
public class Service implements IService {
@Override
public void init() {
System.out.println("init");
}
@Override
View it.fago.experiment.autocloseable.IService.java
package it.fago.experiment.autocloseable;
public interface IService {
void init();
void destroy();
void execute(Object ... arguments);
You can’t perform that action at this time.