All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.happinesea.ec.rws.lib.util.StringUtils.groovy Maven / Gradle / Ivy

There is a newer version: 1.0.0_preview
Show newest version
package com.happinesea.ec.rws.lib.util

import org.apache.commons.collections.CollectionUtils

/**
 * 文字列操作関連のUtils
 */
class StringUtils {
    /**
     * あらゆるリストを{@link String}の{@link List}に変換する。中身がnullの場合、空文字に変換する
* 尚、中では{@link String#valueOf}を使って文字列に変換するため、ラッパークラスでない、かつ、toStringを定義しない場合、
* 想定通りに文字列に変換できないかもしれません。 * * @param source 変換対象 * @return */ public static List convertStringList(List source){ if(CollectionUtils.isEmpty(source)) { return null } List result = new ArrayList() for(Object obj : source) { if(obj == null) { result.add('') }else { result.add(String.valueOf(obj)) } } return result } /** * nullの文字列を空文字に変換 * * @param source 対象となる文字列 * @return 変換結果 */ public static String changeNull2Empty(String source) { return source == null ? '' : source } /* public static boolean isEqualsStringList(List a1, List a2) { boolean isEmptyA1 = CollectionUtils.isEmpty(a1) boolean isEmptyA2 = CollectionUtils.isEmpty(a2) if(isEmptyA1 && isEmptyA2) { return true } if(isEmptyA1 || isEmptyA2) { return false } if(a1.size() != a2.size()) { println '[' + a1.size() + ']->[' + a2.size() + ']' return false } for(int i = 0; i < a1.size(); i++) { String str1 = a1.get(i) String str2 = a2.get(i) println '[' + str1 + ']->[' + str2 + ']' if(str1 == null && str2 == null) { continue } if(str1 == null || str2 == null) { return false } if(!str1.equals(str2)) { return false } } return true }*/ }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy