Skip to content
This repository has been archived by the owner on Aug 20, 2021. It is now read-only.

Commit

Permalink
update javadoc
Browse files Browse the repository at this point in the history
  • Loading branch information
venusdrogon committed Jul 28, 2016
1 parent c7c18ee commit 51e1edd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ feilong core
[![License](http://img.shields.io/:license-apache-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0.html)
![build](https://img.shields.io/jenkins/s/https/jenkins.qa.ubuntu.com/precise-desktop-amd64_default.svg "build")
[![docs](http://progressed.io/bar/79?title=docs "docs")](http://venusdrogon.github.io/feilong-platform/javadocs/feilong-core/)
![tests](https://img.shields.io/badge/tests-401%20%2F%20401-green.svg "tests")
![tests](https://img.shields.io/badge/tests-407%20%2F%20407-green.svg "tests")
![JDK](https://img.shields.io/badge/JDK-1.7-green.svg "JDK")

> Reduce development, Release ideas (减少开发,释放思想)
Expand Down
12 changes: 7 additions & 5 deletions src/main/java/com/feilong/tools/formatter/AbstractFormatter.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import static java.lang.Math.max;
import static org.apache.commons.lang3.StringUtils.EMPTY;
import static org.apache.commons.lang3.StringUtils.SPACE;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -53,10 +54,7 @@ public abstract class AbstractFormatter implements Formatter{
*/
@Override
public <T> String format(T bean){
if (isNullOrEmpty(bean)){
return EMPTY;
}
return format(PropertyUtil.describe(bean));
return isNullOrEmpty(bean) ? EMPTY : format(PropertyUtil.describe(bean));
}

/*
Expand All @@ -69,22 +67,26 @@ public <K, V> String format(Map<K, V> map){
if (isNullOrEmpty(map)){
return EMPTY;
}

//*******************************************************
int maxKeyLength = -1;
for (K key : map.keySet()){
maxKeyLength = max(maxKeyLength, StringUtils.length(ConvertUtil.toString(key)));
}
//*******************************************************

List<Object[]> dataList = new ArrayList<>(map.size());

Map<K, V> useMap = sortByKeyAsc(map);//不影响原map

String separator = SPACE + ":" + SPACE;

//*******************************************************
for (Map.Entry<K, V> entry : useMap.entrySet()){
K key = entry.getKey();
V value = entry.getValue();
//StringUtils.leftPad(ConvertUtil.toString(key), maxKeyLength)
dataList.add(toArray(ConvertUtil.toString(key), ":", value));
dataList.add(toArray(ConvertUtil.toString(key), separator, value));
}
return format(null, dataList);
}
Expand Down
9 changes: 9 additions & 0 deletions src/test/java/com/feilong/core/lang/StringUtilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package com.feilong.core.lang;

import static org.apache.commons.lang3.StringUtils.EMPTY;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;

Expand Down Expand Up @@ -242,6 +243,14 @@ public void replaceAll(){
assertEquals("'SH1265',SH5951", "SH1265,SH5951".replaceFirst("([a-zA-Z]+[0-9]+)", "'$1'"));
}

@Test
public void replaceAll1(){
String regex = "(_[A-Za-z0-9]+){0,2}\\.(properties|xml)";
LOGGER.debug(StringUtil.replaceAll("help_mes_mes_sss_age_en_GB.properties", regex, EMPTY));
LOGGER.debug(StringUtil.replaceAll("help_message_en_GB.properties", regex, EMPTY));
LOGGER.debug(StringUtil.replaceAll("help_en_GB.properties", regex, EMPTY));
}

/**
* Substring2.
*/
Expand Down

0 comments on commit 51e1edd

Please sign in to comment.