package org.gcube.common.clients.config; import java.util.concurrent.TimeUnit; import org.gcube.common.clients.builders.AbstractStatefulBuilder; import org.gcube.common.clients.builders.AbstractStatelessBuilder; /** * A custom configuration property for proxies. * * @author Fabio Simeoni * * @see AbstractStatefulBuilder * @see AbstractStatelessBuilder * * @param the type of the property value */ public class Property { /** * The name of the call timeout {@link Property}. */ public static final String timeout = "timeout"; /** * The name of the sticky session property {@link Property}. */ public static final String sticky_session = "sticky_session"; /** * Return the call timeout {@link Property}. * @param value the property value * @return the property */ public static Property timeout(long value) { return new Property(timeout,value); } /** * Return the call timeout {@link Property}. * @param duration the duration of the timeout * @param unit the time unit of the timeout * @return the property */ public static Property timeout(long duration, TimeUnit unit) { return new Property(timeout,unit.toMillis(duration)); } /** * Return the sticky session {@link Property}. * @param value the property value * @return the property */ public static Property sticky_session(boolean value) { return new Property(sticky_session,value); } private final String name; private final T value; /** * Creates an instance with a name and a value. * @param name the name * @param value the value */ public Property(String name, T value) { this.name=name; this.value=value; } /** * Returns the name of the property. * @return the name */ public String name() { return name; } /** * Returns the value of the property. * @return the value */ public T value() { return value; } }