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

me.chanjar.weixin.common.util.xml.StringArrayConverter Maven / Gradle / Ivy

The newest version!
package me.chanjar.weixin.common.util.xml;

import com.google.common.base.Joiner;
import com.google.common.base.Splitter;
import com.google.common.collect.Iterables;
import com.thoughtworks.xstream.converters.basic.StringConverter;


/**
 * String 数组转换
 * @author chily.lin
 */
public class StringArrayConverter  extends StringConverter {
  @Override
  public boolean canConvert(Class type) {
    return type == String[].class;
  }

  @Override
  public String toString(Object obj) {
    return "";
  }

  @Override
  public Object fromString(String str) {
    final Iterable iterable = Splitter.on(",").split(str);
    String[] results = Iterables.toArray(iterable, String.class);
    return results;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy