All Downloads are FREE. Search and download functionalities are using the official Maven repository.

aQute.bnd.exceptions.SupplierWithException Maven / Gradle / Ivy

Go to download

A main program (executable JAR) that will listen to port 29998. At first, it can only answer that it is an Envoy (a limited agent). The only function it supports is installing a -runpath. It will then create a framework + agent and transfer the connection to the just installed agent who will then install the bundles. This JAR is a main command for JPM called bndremote. In JPM, it will start up with debug enabled. This JAR does some highly complicated class loading wizardy to ensure that it does not enforce any constraints on the -runpath.

The newest version!
package aQute.bnd.exceptions;

import static java.util.Objects.requireNonNull;

import java.util.function.Supplier;

/**
 * Supplier interface that allows exceptions.
 *
 * @param  the result type
 */
@FunctionalInterface
public interface SupplierWithException {
	R get() throws Exception;

	default Supplier orElseThrow() {
		return () -> {
			try {
				return get();
			} catch (Exception e) {
				throw Exceptions.duck(e);
			}
		};
	}

	default Supplier orElse(R orElse) {
		return () -> {
			try {
				return get();
			} catch (Exception e) {
				return orElse;
			}
		};
	}

	default Supplier orElseGet(Supplier orElseGet) {
		requireNonNull(orElseGet);
		return () -> {
			try {
				return get();
			} catch (Exception e) {
				return orElseGet.get();
			}
		};
	}

	static  Supplier asSupplier(SupplierWithException unchecked) {
		return unchecked.orElseThrow();
	}

	static  Supplier asSupplierOrElse(SupplierWithException unchecked, R orElse) {
		return unchecked.orElse(orElse);
	}

	static  Supplier asSupplierOrElseGet(SupplierWithException unchecked, Supplier orElseGet) {
		return unchecked.orElseGet(orElseGet);
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy