Class PropertiesHelper


  • public class PropertiesHelper
    extends java.lang.Object
    Properties helper class with generally useful methods.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String getProperty​(java.util.Properties props, java.lang.String[] keys)  
      static java.lang.String getProperty​(java.util.Properties props, java.lang.String[] keys, java.lang.String defaultValue)  
      static int getPropertyAsInt​(java.util.Properties props, java.lang.String[] keys, int defaultValue)  
      static long getPropertyAsLong​(java.util.Properties props, java.lang.String[] keys, long defaultValue)  
      static java.lang.String getPropertyByKeys​(java.util.Properties props, java.lang.String key, java.lang.String alternativeKey)  
      static java.lang.String getPropertyByKeys​(java.util.Properties props, java.lang.String key, java.lang.String alternativeKey, java.lang.String defaultValue)  
      static boolean isExistProperty​(java.util.Properties props, java.lang.String key, java.lang.String alternativeKey, boolean defaultValue)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PropertiesHelper

        public PropertiesHelper()
    • Method Detail

      • getProperty

        public static java.lang.String getProperty​(java.util.Properties props,
                                                   java.lang.String[] keys)
        Parameters:
        props - props
        keys - keys
        Returns:
        the first property string value found from the passed-in properties with the specified keys.
      • getProperty

        public static java.lang.String getProperty​(java.util.Properties props,
                                                   java.lang.String[] keys,
                                                   java.lang.String defaultValue)
        Parameters:
        props - props
        keys - keys
        defaultValue - defaultValue
        Returns:
        the first property string value found from the passed-in properties with the specified keys. If it can't find a value, then return the passed-in defaultValue.
      • getPropertyAsInt

        public static int getPropertyAsInt​(java.util.Properties props,
                                           java.lang.String[] keys,
                                           int defaultValue)
        Parameters:
        props - props
        keys - keys
        defaultValue - defaultValue
        Returns:
        the first property value found as an int, if possible. If it can't find a value, then return the passed-in defaultValue.
      • getPropertyAsLong

        public static long getPropertyAsLong​(java.util.Properties props,
                                             java.lang.String[] keys,
                                             long defaultValue)
        Parameters:
        props - props
        keys - keys
        defaultValue - defaultValue
        Returns:
        the property value as a long, if possible. If it can't find a value by the specified key, then return the passed-in defaultValue.
      • getPropertyByKeys

        public static java.lang.String getPropertyByKeys​(java.util.Properties props,
                                                         java.lang.String key,
                                                         java.lang.String alternativeKey,
                                                         java.lang.String defaultValue)
      • getPropertyByKeys

        public static java.lang.String getPropertyByKeys​(java.util.Properties props,
                                                         java.lang.String key,
                                                         java.lang.String alternativeKey)
      • isExistProperty

        public static boolean isExistProperty​(java.util.Properties props,
                                              java.lang.String key,
                                              java.lang.String alternativeKey,
                                              boolean defaultValue)