public static <T> ConfigKey<T> newConfigKey(TypeToken<T> type, String name) { return new BasicConfigKey<T>(type, name); }
public static <T> BasicConfigKey.Builder<T> builder(TypeToken<T> type) { return BasicConfigKey.builder(type); }
@Override public T extractValue(Map vals, ExecutionContext exec) { return super.extractValue(vals, exec); }
@Override public boolean isSet(Map<?,?> vals) { return super.isSet(vals); } }
@Override public String toString() { return String.format("%s[ConfigKey:%s]", name, getTypeName()); }
/** * Retrieves the value corresponding to this config key from the given map. * Could be overridden by more sophisticated config keys, such as MapConfigKey etc. */ @SuppressWarnings("unchecked") @Override public T extractValue(Map<?,?> vals, ExecutionContext exec) { Object v = vals.get(this); try { return (T) resolveValue(v, exec); } catch (ExecutionException e) { throw Throwables.propagate(e); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw Throwables.propagate(e); } }
public static <T> ConfigKey<T> newConfigKey(Class<T> type, String name, String description, T defaultValue) { return new BasicConfigKey<T>(type, name, description, defaultValue); }
public static <T> BasicConfigKey.Builder<T> builder(Class<T> type) { return BasicConfigKey.builder(type); }
public BasicConfigKey<T> build() { return new BasicConfigKey<T>(this); } }
/** @deprecated since 0.6.0; use #PASSWORD_FOR_USER */ public final static ConfigKey<String> SECURITY_PROVIDER_EXPLICIT__PASSWORD(String user) { return new BasicConfigKey<String>(String.class, BASE_NAME+".security.explicit.user."+user); }
public static <T> ConfigKey<T> newConfigKey(Class<T> type, String name) { return new BasicConfigKey<T>(type, name); }
public static <T> ConfigKey<T> newConfigKey(TypeToken<T> type, String name, String description) { return new BasicConfigKey<T>(type, name, description); }
public final static ConfigKey<String> SECURITY_PROVIDER_EXPLICIT__PASSWORD(String user) { return new BasicConfigKey<String>(String.class, BASE_NAME+".security.explicit.user."+user); }
public static <T> ConfigKey<T> newConfigKey(TypeToken<T> type, String name, String description, T defaultValue) { return new BasicConfigKey<T>(type, name, description, defaultValue); }
public final static ConfigKey<String> PASSWORD_FOR_USER(String user) { return new BasicConfigKey<String>(String.class, BASE_NAME_SECURITY+".user."+user+".password"); }
public static <T> ConfigKey<T> newConfigKey(Class<T> type, String name, String description) { return new BasicConfigKey<T>(type, name, description); }
/** Infers the type from the default value */ @SuppressWarnings({ "unchecked", "rawtypes" }) public static <T> ConfigKey<T> newConfigKey(String name, String description, @Nonnull T defaultValue) { return new BasicConfigKey<T>((Class)Preconditions.checkNotNull(defaultValue, "Type must be exlicit for ConfigKey if defaultValue is null").getClass(), name, description, defaultValue); }
@Override public Map<ConfigKey<?>, Object> getAllConfig() { Map<ConfigKey<?>, Object> result = new LinkedHashMap<ConfigKey<?>, Object>(); for (Object entry: entrySet()) result.put(new BasicConfigKey<Object>(Object.class, ""+((Map.Entry)entry).getKey()), ((Map.Entry)entry).getValue()); return result; }
public AttributeSensorAndConfigKey(Class<ConfigType> configType, Class<SensorType> sensorType, String name, String description, Object defaultValue) { super(sensorType, name, description); configKey = new BasicConfigKey<ConfigType>(configType, name, description, TypeCoercions.coerce(defaultValue, configType)); }
@Override public Object get(Object key) { return target.getConfig(new BasicConfigKey<Object>(Object.class, (String)key)); }