Commit 0a5e45a6 authored by yanzg's avatar yanzg

将源码打包进jar包

parent 7dba90b4
......@@ -55,7 +55,7 @@ public class StringHelper {
for (Object from : froms) {
boolean isEmpty = from == null || from.toString().length() < 1;
if (isEmpty) {
return isEmpty;
return true;
}
}
return false;
......@@ -139,20 +139,24 @@ public class StringHelper {
* @param expandValue 排除值
* @param defReturn 默认返回值
* @param froms 其他值
* @param <T>
* @param <T> 数据类型
* @return 返回值
*/
public static <T extends Object> T getFirstRun(T expandValue, T defReturn, T... froms) {
if (froms != null) {
for (T from : froms) {
if (isEmpty(from)) {
continue;
}
if (expandValue != null && (expandValue == from || expandValue.equals(from))) {
continue;
}
public static <T> T getFirstRun(T expandValue, T defReturn, T... froms) {
if (froms == null) {
return defReturn;
}
for (T from : froms) {
if (from == null || isEmpty(from)) {
continue;
}
if (expandValue == null) {
return from;
}
if (expandValue == from || expandValue.equals(from)) {
continue;
}
return from;
}
return defReturn;
}
......
package helper;
import com.yanzuoguang.util.helper.StringHelper;
import org.junit.Assert;
import org.junit.Test;
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
public void test() {
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