Fix CI Cent OS 8 configuration issue (workaround)
[transportpce.git] / inventory / src / main / java / org / opendaylight / transportpce / inventory / utils / StringUtils.java
index 7b48f784c4b86a5a54106ce9de31f99fec1fd58a..443988f483e31609ba433e6e9857be65abb64d42 100644 (file)
@@ -22,59 +22,64 @@ public final class StringUtils {
     }
 
     /**
-     * Returns the current timestamp formatted with
-     * {@link StringUtils#DEFAULT_SQL_DATE}.
+     * Returns the current timestamp formatted with {@link StringUtils#DEFAULT_SQL_DATE}.
      *
      * @see StringUtils#getTimestamp(Date)
-     * @return String the current timestamp formatted
+     * @return Timestamp represenation of the given date
      */
     public static String getCurrentTimestamp() {
         return getTimestamp(new Date());
     }
 
     /**
-     * This method will format the provided {@link Date} with the
-     * {@link StringUtils#DEFAULT_SQL_DATE} format.
+     * This method will format the provided {@link Date} with the {@link StringUtils#DEFAULT_SQL_DATE} format.
      *
-     * @param date a date
+     * @param date link date
      * @return string represenation of the given date
      */
     public static String getTimestamp(Date date) {
-        SimpleDateFormat simpleDate = new SimpleDateFormat(DEFAULT_SQL_DATE);
-        return simpleDate.format(date);
+        SimpleDateFormat myTimeStamp = new SimpleDateFormat(DEFAULT_SQL_DATE);
+        return myTimeStamp.format(date);
     }
 
     /**
      * Checks the input object for null and if it's null returns a dash instead.
      *
-     * @param object an input object
-     * @return if object is null a dash is returned,
-     *         otherwise {@link Object#toString()}
+     * @param object an object
+     * @return if object is null a dash is returned, otherwise {@link Object#toString()}
      */
     public static String prepareDashString(Object object) {
-        return prepareString(object, "-");
+        return prepareString(object, "");
     }
 
     /**
      * Checks the input object for null and if's null returns an empty string instead.
      *
-     * @param object an input object
-     * @return if object is null an empty string is returned,
-     *         otherwise {@link Object#toString()}
+     * @param object an object
+     * @return if object is null an empty string is returned, otherwise {@link Object#toString()}
      */
     public static String prepareEmptyString(Object object) {
         return prepareString(object, "");
     }
 
     /**
-     * Checks if the given object is null and returns its representation given by
-     * replacement.
+     * Checks if the given object is null and returns its representation given by replacement.
      *
-     * @param objectString a string object
-     * @param replacement a replacement
-     * @return String the representation of the object given by replacement
+     * @param objectString an object
+     * @param replacement a replacement string
+     * @return a string representing the object
      */
     public static String prepareString(Object objectString, String replacement) {
         return objectString == null ? replacement : objectString.toString();
     }
+
+    /**
+     * Checks if the given object is null and returns -1 .
+     *
+     * @param object an object
+     * @return a string representing the object or -1 if null
+     */
+    public static String prepareEmptyInt(Object object) {
+        return (object == null ? "-1" : object.toString());
+    }
 }