/** * @param v The value to be tested * @return {@code true} if <U>all</U> of these conditions hold:</BR> * <UL> * <LI>The mapped value is a {@link Number}</LI> * <LI>The {@link Number#intValue()} is non-zero</LI> * </UL> * @see #getBooleanSettingValue(int) */ public static boolean getBooleanSettingValue(Object v) { return (v instanceof Number) && getBooleanSettingValue(((Number) v).intValue()); }
/** * @param v The value to be tested * @return {@code true} if <U>all</U> of these conditions hold:</BR> * <UL> * <LI>The mapped value is a {@link Number}</LI> * <LI>The {@link Number#intValue()} is non-zero</LI> * </UL> * @see #getBooleanSettingValue(int) */ public static boolean getBooleanSettingValue(Object v) { return (v instanceof Number) && getBooleanSettingValue(((Number) v).intValue()); }
/** * @param modes The current modes {@link Map}-ing * @param m The required {@link PtyMode} * @return {@code true} if <U>all</U> of these conditions hold:</BR> * <UL> * <LI>Modes map is not {@code null}/empty</LI> * <LI>Required mode setting is not {@code null}</LI> * <LI>The setting has a mapped value</LI> * <LI>The mapped value is a {@link Number}</LI> * <LI>The {@link Number#intValue()} is non-zero</LI> * </UL> * @see #getBooleanSettingValue(Object) */ public static boolean getBooleanSettingValue(Map<PtyMode, ?> modes, PtyMode m) { if ((m == null) || GenericUtils.isEmpty(modes)) { return false; } else { return getBooleanSettingValue(modes.get(m)); } }
/** * @param modes The current modes {@link Map}-ing * @param m The required {@link PtyMode} * @return {@code true} if <U>all</U> of these conditions hold:</BR> * <UL> * <LI>Modes map is not {@code null}/empty</LI> * <LI>Required mode setting is not {@code null}</LI> * <LI>The setting has a mapped value</LI> * <LI>The mapped value is a {@link Number}</LI> * <LI>The {@link Number#intValue()} is non-zero</LI> * </UL> * @see #getBooleanSettingValue(Object) */ public static boolean getBooleanSettingValue(Map<PtyMode, ?> modes, PtyMode m) { if ((m == null) || GenericUtils.isEmpty(modes)) { return false; } else { return getBooleanSettingValue(modes.get(m)); } }
/** * @param modes The PTY settings - ignored if {@code null}/empty * @param options The options that should be enabled * @return A {@link Set} of all the {@link PtyMode}s that appeared * in the settings and were enabled * @see #getBooleanSettingValue(Map, PtyMode) */ public static Set<PtyMode> resolveEnabledOptions(Map<PtyMode, ?> modes, Collection<PtyMode> options) { if (GenericUtils.isEmpty(modes) || GenericUtils.isEmpty(options)) { return Collections.emptySet(); } Set<PtyMode> enabled = EnumSet.noneOf(PtyMode.class); for (PtyMode m : options) { if (getBooleanSettingValue(modes, m)) { enabled.add(m); } } return enabled; }
/** * @param modes The PTY settings - ignored if {@code null}/empty * @param options The options that should be enabled * @return A {@link Set} of all the {@link PtyMode}s that appeared * in the settings and were enabled * @see #getBooleanSettingValue(Map, PtyMode) */ public static Set<PtyMode> resolveEnabledOptions(Map<PtyMode, ?> modes, Collection<PtyMode> options) { if (GenericUtils.isEmpty(modes) || GenericUtils.isEmpty(options)) { return Collections.emptySet(); } Set<PtyMode> enabled = EnumSet.noneOf(PtyMode.class); for (PtyMode m : options) { if (getBooleanSettingValue(modes, m)) { enabled.add(m); } } return enabled; }