/** * @param namespacePattern - the format string to be used when constructing the namespace. this * can be a fully formed namespace. * @param operationParam - this argument is used to determine the list of possible operation * parameters * @param alternativeOperationParam - these arguments are treated as alternatives to * <tt>operationParam</tt> (e.g., <tt>Action</tt> is an alternative to <tt>Operation</tt> ). */ public BaseQueryBinding( final String namespacePattern, final T operationParam, final T... alternativeOperationParam) { super(namespacePattern); this.operationParam = operationParam; this.altOperationParams = Arrays.asList(alternativeOperationParam); this.possibleParams = Arrays.asList(operationParam.getDeclaringClass().getEnumConstants()); }
public <T extends Enum<T>> T getEnum(String key, T defaultValue) { if (mProperties.containsKey(key)) { final String val = get(key, defaultValue.toString()); return null == val ? defaultValue : Enum.valueOf(defaultValue.getDeclaringClass(), val); } return defaultValue; }
/** * Retrieve an enum value from the user preferences. * * @param <T> the enum type * @param key the key * @param def the default value, cannot be null * @return the value in the preferences, or the default value */ public final <T extends Enum<T>> T getEnum(String key, T def) { if (def == null) { throw new BugException("Default value cannot be null"); } String value = getString(key, null); if (value == null) { return def; } try { return Enum.valueOf(def.getDeclaringClass(), value); } catch (IllegalArgumentException e) { return def; } }
/** * Returns a map of offsets keyed by the enum collector member for the passed enum collector * member * * @param t The enum collector member * @param bitMask The bitmask * @return a map of offsets keyed by the enum collector member */ public Map<T, Long> offsets(T t, int bitMask) { return offsets(t.getDeclaringClass().getName(), bitMask); }
/** * Returns the index for the passed enum member * * @param t The enum member to get the index for * @return the index for the passed enum member */ public int index(T t) { return index(t.getDeclaringClass()); }
public static <T extends Enum<T>> String getPropertyID(T algo) { Class<T> clazz = algo.getDeclaringClass(); return "net.java.sip.communicator." + clazz.getName().replace('$', '_'); }