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

com.sirolf2009.util.retry.Retry.xtend Maven / Gradle / Ivy

The newest version!
package com.sirolf2009.util.retry

import java.util.function.Supplier

class Retry {

	public static RetryStrategy defaultStrategy = new SimpleRetryStrategy(3)

	def static void retry(Runnable runnable) {
		retry(new Supplier() {
			override Void get() {
				runnable.run()
				return null;
			}
		})
	}

	def static  RetryResult retry(Supplier supplier) {
		return retry(supplier, defaultStrategy)
	}

	def static  RetryResult retry(Supplier supplier, int attempts) {
		return retry(supplier, new SimpleRetryStrategy(attempts))
	}

	def static  RetryResult retry(Supplier supplier, RetryStrategy strategy) {
		return strategy.run(supplier)
	}
	
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy