Util 情境 1 : 若要比對字串是否在列舉資料列中
不斷變更的flag + 若要比對字串是否在列舉資料列中
1. 步驟 1 : 設定 flag
boolean isValidate = flase ;
2. 步驟 2 : 更新 flag
isValidate = isValidate && theProcess ( );
3. 步驟 3 : theProcess -- Java Code -- 若要比對字串是否在列舉資料列中
/**
* <p>Title: XXXX</p>
* <p>Description: YYYY</p>
*/
public class ZZZUtils {
/**
* <p>Description : 比對字串是否在列舉資料列中</p>
* <p>Created By : ZZZZ</p>
* <p>Create Time : XXX 28, XXXX</p>
* @paramstr
* @param targets
* @return boolean 是否相符
*/
public static boolean theProcess ( String str, String... targets ) {
return StringUtil. theProcess ( str , targets);
}
}
package com . xxx. yyy. util ;
public class StringUtil {
public static boolean theProcess ( String str, String... targets ) {
if (targets == null || str == null)
return false;
for (String item : targets) {
if (item == null)
continue ;
if (str . equals( item)) {
return true;
}
}
return false;
}
}
不斷變更的flag + 若要比對字串是否在列舉資料列中
1. 步驟 1 : 設定 flag
2. 步驟 2 : 更新 flag
3. 步驟 3
/**
* <p>Title: XXXX</p>
* <p>Description: YYYY</p>
*/
/**
* <p>Description
* <p>Created By
* <p>Create Time
* @param
* @param targets
* @return boolean 是否相符
*/
}
}
}
}
}
}




















