@Test public void willReturnNullForInvalidJID() { final String jidString = "@test-domain"; final String key = "an invalid jid property"; final SystemProperty<JID> property = SystemProperty.Builder.ofType(JID.class) .setKey(key) .setDynamic(true) .build(); assertThat(property.getValue(),is(nullValue())); JiveGlobals.setProperty(key, jidString); assertThat(property.getValue(),is(nullValue())); }
@SuppressWarnings("unchecked") public T getValue() { final T value = (T) FROM_STRING.get(getConverterClass()).apply(JiveGlobals.getProperty(key), this); if (value == null || (Collection.class.isAssignableFrom(value.getClass()) && ((Collection) value).isEmpty())) { return defaultValue; } if (minValue != null && ((Comparable) minValue).compareTo(value) > 0) { LOGGER.warn("Configured value of {} is less than the minimum value of {} for the SystemProperty {} - will use default value of {} instead", value, minValue, key, defaultValue); return defaultValue; } if (maxValue != null && ((Comparable) maxValue).compareTo(value) < 0) { LOGGER.warn("Configured value of {} is more than the maximum value of {} for the SystemProperty {} - will use default value of {} instead", value, maxValue, key, defaultValue); return defaultValue; } return value; }
SystemProperty { @SuppressWarnings("unchecked") public T getValue() { final T value = (T) FROM_STRING.get(getConverterClass()).apply(JiveGlobals.getProperty(key), this); if (value == null || (Collection.class.isAssignableFrom(value.getClass()) && ((Collection) value).isEmpty())) { return defaultValue; } if (minValue != null && ((Comparable) minValue).compareTo(value) > 0) { LOGGER.warn("Configured value of {} is less than the minimum value of {} for the SystemProperty {} - will use default value of {} instead", value, minValue, key, defaultValue); return defaultValue; } if (maxValue != null && ((Comparable) maxValue).compareTo(value) < 0) { LOGGER.warn("Configured value of {} is more than the maximum value of {} for the SystemProperty {} - will use default value of {} instead", value, maxValue, key, defaultValue); return defaultValue; } return value; } }
SystemProperty { @SuppressWarnings("unchecked") public T getValue() { final T value = (T) FROM_STRING.get(getConverterClass()).apply(JiveGlobals.getProperty(key), this); if (value == null || (Collection.class.isAssignableFrom(value.getClass()) && ((Collection) value).isEmpty())) { return defaultValue; } if (minValue != null && ((Comparable) minValue).compareTo(value) > 0) { LOGGER.warn("Configured value of {} is less than the minimum value of {} for the SystemProperty {} - will use default value of {} instead", value, minValue, key, defaultValue); return defaultValue; } if (maxValue != null && ((Comparable) maxValue).compareTo(value) < 0) { LOGGER.warn("Configured value of {} is more than the maximum value of {} for the SystemProperty {} - will use default value of {} instead", value, maxValue, key, defaultValue); return defaultValue; } return value; } private  SystemProperty(final Builder<T> builder); }
SystemProperty { @SuppressWarnings("unchecked") public T getValue() { final T value = (T) FROM_STRING.get(getConverterClass()).apply(JiveGlobals.getProperty(key), this); if (value == null || (Collection.class.isAssignableFrom(value.getClass()) && ((Collection) value).isEmpty())) { return defaultValue; } if (minValue != null && ((Comparable) minValue).compareTo(value) > 0) { LOGGER.warn("Configured value of {} is less than the minimum value of {} for the SystemProperty {} - will use default value of {} instead", value, minValue, key, defaultValue); return defaultValue; } if (maxValue != null && ((Comparable) maxValue).compareTo(value) < 0) { LOGGER.warn("Configured value of {} is more than the maximum value of {} for the SystemProperty {} - will use default value of {} instead", value, maxValue, key, defaultValue); return defaultValue; } return value; } private  SystemProperty(final Builder<T> builder); static Collection<SystemProperty> getProperties(); @SuppressWarnings("WeakerAccess") static void removePropertiesForPlugin(final String plugin); static Optional<SystemProperty> getProperty(final String key); @SuppressWarnings("unchecked") T getValue(); String getValueAsSaved(); String getDisplayValue(); boolean hasValueChanged(); String getDefaultDisplayValue(); void setValue(final T value); String getPlugin(); boolean isDynamic(); boolean isEncrypted(); boolean isRestartRequired(); void addListener(final Consumer<T> listener); void removeListener(final Consumer<T> listener); String getKey(); String getDescription(); T getDefaultValue(); }
SystemProperty { @SuppressWarnings("unchecked") public T getValue() { final T value = (T) FROM_STRING.get(getConverterClass()).apply(JiveGlobals.getProperty(key), this); if (value == null || (Collection.class.isAssignableFrom(value.getClass()) && ((Collection) value).isEmpty())) { return defaultValue; } if (minValue != null && ((Comparable) minValue).compareTo(value) > 0) { LOGGER.warn("Configured value of {} is less than the minimum value of {} for the SystemProperty {} - will use default value of {} instead", value, minValue, key, defaultValue); return defaultValue; } if (maxValue != null && ((Comparable) maxValue).compareTo(value) < 0) { LOGGER.warn("Configured value of {} is more than the maximum value of {} for the SystemProperty {} - will use default value of {} instead", value, maxValue, key, defaultValue); return defaultValue; } return value; } private  SystemProperty(final Builder<T> builder); static Collection<SystemProperty> getProperties(); @SuppressWarnings("WeakerAccess") static void removePropertiesForPlugin(final String plugin); static Optional<SystemProperty> getProperty(final String key); @SuppressWarnings("unchecked") T getValue(); String getValueAsSaved(); String getDisplayValue(); boolean hasValueChanged(); String getDefaultDisplayValue(); void setValue(final T value); String getPlugin(); boolean isDynamic(); boolean isEncrypted(); boolean isRestartRequired(); void addListener(final Consumer<T> listener); void removeListener(final Consumer<T> listener); String getKey(); String getDescription(); T getDefaultValue();  }