/*
 * Copyright (c) 2017 by Botorabi. All rights reserved.
 * https://github.com/botorabi/Meet4Eat
 * 
 * License: MIT License (MIT), read the LICENSE text in
 *          main directory for more details.
 */

package net.m4e.common;

/**
 * A collection of string related utilities
 * 
 * @author boto
 * Date of creation Sep 5, 2017
 */
public class Strings {

    /**
     * Given an input string, limit its length. The method also handles null as input.
     * 
     * @param input     Input string
     * @param maxLen    Maximal character length
     * @return          Return length limited string, or null if the input was null.
     */
    public static String limitStringLen(String input, int maxLen) {
        if (input != null) {
            if (input.length() > maxLen) {
                input = input.substring(0, maxLen);
            }
        }
        return input;
    }

    /**
     * Check if the input string length is in given min/max range.
     * 
     * @param input    Input string
     * @param minLen   Min length
     * @param maxLen   Max length 
     * @return         Return true if the string has a length in given range, otherwise return false.
     */
    public static boolean checkMinMaxLength(String input, int minLen, int maxLen) {
        if (input == null) {
            return false;
        }
        int len = input.length();
        return (len >= minLen) && (len <= maxLen);
    }
}

@@ -94,17 +94,16 @@
 t4Eat%0A *
- 
 %0A * Lice
@@ -276,17 +276,16 @@
 ities%0A *
- 
 %0A * @aut
@@ -300,24 +300,14 @@
 %0A * 
-Date of creation
+@since
  Sep
@@ -436,33 +436,32 @@
 as input.%0A     *
- 
 %0A     * @param i
@@ -466,20 +466,21 @@
  input  
-   I
+the i
 nput str
@@ -504,20 +504,21 @@
  maxLen 
-   M
+the m
 aximal c
@@ -548,25 +548,16 @@
 @return 
-         
 Return l
@@ -657,16 +657,22 @@
 ringLen(
+final 
 String i
@@ -672,24 +672,30 @@
 tring input,
+ final
  int maxLen)
@@ -719,9 +719,9 @@
 put 
-!
+=
 = nu
@@ -722,32 +722,63 @@
  == null) %7B%0A    
+        return null;%0A        %7D%0A
         if (inpu
@@ -816,19 +816,14 @@
     
-    input =
+return
  inp
@@ -851,22 +851,8 @@
 n);%0A
-            %7D%0A
     
@@ -950,16 +950,8 @@
 ven 
-min/max 
 rang
@@ -959,17 +959,16 @@
 .%0A     *
- 
 %0A     * 
@@ -985,22 +985,26 @@
 ut  
-  Input string
+the string to test
 %0A   
@@ -1021,19 +1021,21 @@
  minLen 
-  M
+the m
 in lengt
@@ -1031,24 +1031,35 @@
 e min length
+, inclusive
 %0A     * @par
@@ -1072,11 +1072,13 @@
 Len 
-  M
+the m
 ax l
@@ -1086,34 +1086,29 @@
 ngth
- %0A     * @return         R
+, inclusive%0A     * @r
 etur
@@ -1233,16 +1233,22 @@
 xLength(
+final 
 String i
@@ -1252,16 +1252,22 @@
 g input,
+ final
  int min
@@ -1270,16 +1270,22 @@
  minLen,
+ final
  int max
@@ -1364,16 +1364,22 @@
         
+final 
 int len 

Refactor Strings