Commit 0a5e45a6 authored by yanzg's avatar yanzg

将源码打包进jar包

parent 7dba90b4
...@@ -55,7 +55,7 @@ public class StringHelper { ...@@ -55,7 +55,7 @@ public class StringHelper {
for (Object from : froms) { for (Object from : froms) {
boolean isEmpty = from == null || from.toString().length() < 1; boolean isEmpty = from == null || from.toString().length() < 1;
if (isEmpty) { if (isEmpty) {
return isEmpty; return true;
} }
} }
return false; return false;
...@@ -139,20 +139,24 @@ public class StringHelper { ...@@ -139,20 +139,24 @@ public class StringHelper {
* @param expandValue 排除值 * @param expandValue 排除值
* @param defReturn 默认返回值 * @param defReturn 默认返回值
* @param froms 其他值 * @param froms 其他值
* @param <T> * @param <T> 数据类型
* @return 返回值 * @return 返回值
*/ */
public static <T extends Object> T getFirstRun(T expandValue, T defReturn, T... froms) { public static <T> T getFirstRun(T expandValue, T defReturn, T... froms) {
if (froms != null) { if (froms == null) {
for (T from : froms) { return defReturn;
if (isEmpty(from)) { }
continue; for (T from : froms) {
} if (from == null || isEmpty(from)) {
if (expandValue != null && (expandValue == from || expandValue.equals(from))) { continue;
continue; }
} if (expandValue == null) {
return from; return from;
} }
if (expandValue == from || expandValue.equals(from)) {
continue;
}
return from;
} }
return defReturn; return defReturn;
} }
......
package helper; package helper;
import com.yanzuoguang.util.helper.StringHelper; import com.yanzuoguang.util.helper.StringHelper;
import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
public class TestStringHelper { public class TestStringHelper {
@Test
public void testFirstRun() {
int firstRun = StringHelper.toInt(StringHelper.getFirstRun(0, 0, 1, 2));
Assert.assertEquals(firstRun, 1);
Assert.assertNotEquals(firstRun, 2);
firstRun = StringHelper.toInt(StringHelper.getFirstRun(0, 0, null, 0, 2));
Assert.assertEquals(firstRun, 2);
String yzg = "颜佐光";
String yzg1 = "颜佐光1";
String firstEmpty = StringHelper.getFirstRun(null, StringHelper.EMPTY,
null, StringHelper.EMPTY, yzg, yzg1);
Assert.assertEquals(firstEmpty, yzg);
Assert.assertNotEquals(yzg, yzg1);
}
@Test @Test
public void test() { public void test() {
System.out.println(StringHelper.left("100500103", 3)); System.out.println(StringHelper.left("100500103", 3));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment