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

org.onetwo.common.utils.GuavaUtils Maven / Gradle / Ivy

There is a newer version: 5.2.7
Show newest version
package org.onetwo.common.utils;

import java.util.Iterator;
import java.util.Map.Entry;

import com.google.common.base.Joiner;
import com.google.common.base.Splitter;
import com.google.common.collect.Iterators;

public final class GuavaUtils {

	public static Iterable EMPTY_ITERABLE = new Iterable() {
												      @Override public Iterator iterator() {
												          return Iterators.emptyIterator();
												        }
												    };
												    
	public static String[] split(String str, char splitChar) {
		return StringUtils.isBlank(str)?LangUtils.EMPTY_STRING_ARRAY:CUtils.asStringArray(Splitter.on(splitChar).trimResults().omitEmptyStrings().split(str));
	}
	
	public static String[] split(String str, String splitChar) {
		return StringUtils.isBlank(str)?LangUtils.EMPTY_STRING_ARRAY:CUtils.asStringArray(Splitter.on(splitChar).trimResults().omitEmptyStrings().split(str));
	}
	
	public static Iterable splitAsIterable(String str, char splitChar) {
		return StringUtils.isBlank(str)?EMPTY_ITERABLE:Splitter.on(splitChar).trimResults().omitEmptyStrings().split(str);
	}
	
	public static Iterable splitAsIterable(String str, String splitChar) {
		return StringUtils.isBlank(str)?EMPTY_ITERABLE:Splitter.on(splitChar).trimResults().omitEmptyStrings().split(str);
	}
	
	public static String join(Iterable strs, String joiner) {
		return Joiner.on(joiner).skipNulls().join(strs);
	}
	
	public static String join(Iterable> strs, String joiner, String keyValueSeparator) {
		return Joiner.on(joiner).skipNulls().withKeyValueSeparator(keyValueSeparator).join(strs);
	}
	
	private GuavaUtils(){
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy