Skip to content

Commit

Permalink
[maven javadoc]:修改了部分 javadoc 的要求
Browse files Browse the repository at this point in the history
  • Loading branch information
mrzhqiang committed Jan 18, 2021
1 parent afb241e commit 74d3e0f
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 45 deletions.
17 changes: 14 additions & 3 deletions helper/src/main/java/com/github/mrzhqiang/helper/Namings.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ public enum Namings {
;

/**
* com.randall.FssdApplication, {".qing",".chun"} ==> com-randall-fssd-application.qing.chun
* com.randall.FssdApplication, {".qing",".chun"} == com-randall-fssdapplication.qing.chun
*
* @param clazz 任意类的描述对象。
* @param more 更多的后缀数组。
* @return 按照类全名拼接好的字符串,同时替换小数点为破折号。
*/
public static String ofCanonical(Class<?> clazz, String... more) {
String first = clazz.getCanonicalName().toLowerCase().replaceAll("[.$]", "-");
Expand All @@ -21,7 +25,11 @@ public static String ofCanonical(Class<?> clazz, String... more) {
}

/**
* NamingsTest, {"1","2","3"} ==> namings-test123
* NamingsTest, {"1","2","3"} == namings-test123
*
* @param clazz 任意类的描述对象。
* @param more 更多的后缀数组。
* @return 按照简单类名拼接好的字符串,同时将驼峰命名改为破折号连接。
*/
public static String ofSimple(Class<?> clazz, String... more) {
String first = ofCamel(clazz.getSimpleName());
Expand All @@ -33,7 +41,10 @@ public static String ofSimple(Class<?> clazz, String... more) {
}

/**
* CamelString ==> camel-string
* CamelString == camel-string
*
* @param camel 驼峰字符串。
* @return 修改驼峰字符串为破折号连接。
*/
public static String ofCamel(String camel) {
Preconditions.checkNotNull(camel, "camel == null");
Expand Down
133 changes: 91 additions & 42 deletions helper/src/main/java/com/github/mrzhqiang/helper/math/Numbers.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,28 @@ public enum Numbers {

/**
* <pre>
* ofInt(null) >> 0
* ofInt("") >> 0
* ofInt("1") >> 1
* ofInt(null) == 0
* ofInt("") == 0
* ofInt("1") == 1
* </pre>
*
* @param number 仅包含整型数字的字符串。
* @return 整型数字。无效的数字字符串将默认返回 0。
*/
public static int ofInt(String number) {
return ofInt(number, 0);
}

/**
* <pre>
* ofInt(null,0) >> 0
* ofInt("",1) >> 1
* ofInt("1",0) >> 1
* ofInt(null,0) == 0
* ofInt("",1) == 1
* ofInt("1",0) == 1
* </pre>
*
* @param number 仅包含整型数字的字符串。
* @param defaultValue 默认返回的整型数字。
* @return 整型数字。
*/
public static int ofInt(String number, int defaultValue) {
if (Strings.isNullOrEmpty(number)) {
Expand All @@ -42,21 +49,28 @@ public static int ofInt(String number, int defaultValue) {

/**
* <pre>
* ofLong(null) >> 0L
* ofLong("") >> 0L
* ofLong("1") >> 1L
* ofLong(null) == 0L
* ofLong("") == 0L
* ofLong("1") == 1L
* </pre>
*
* @param number 仅包含长整型数字的字符串。
* @return 长整型数字。无效的数字字符串将默认返回 0L。
*/
public static long ofLong(String number) {
return ofLong(number, 0L);
}

/**
* <pre>
* ofLong(null,0L) >> 0L
* ofLong("",1L) >> 1L
* ofLong("1",0L) >> 1L
* ofLong(null,0L) == 0L
* ofLong("",1L) == 1L
* ofLong("1",0L) == 1L
* </pre>
*
* @param number 仅包含长整型数字的字符串。
* @param defaultValue 默认返回的长整型数字。
* @return 长整型数字。
*/
public static long ofLong(String number, long defaultValue) {
if (Strings.isNullOrEmpty(number)) {
Expand All @@ -72,21 +86,28 @@ public static long ofLong(String number, long defaultValue) {

/**
* <pre>
* ofFloat(null) >> 0.0f
* ofFloat("") >> 0.0f
* ofFloat("1.0") >> 1.0f
* ofFloat(null) == 0.0f
* ofFloat("") == 0.0f
* ofFloat("1.0") == 1.0f
* </pre>
*
* @param number 包含单精度浮点型数字的字符串。
* @return 单精度浮点型数字。无效的字符串将默认返回 0.0f。
*/
public static float ofFloat(String number) {
return ofFloat(number, 0.0f);
}

/**
* <pre>
* ofFloat(null,0.0f) >> 0.0f
* ofFloat("",1.0f) >> 1.0f
* ofFloat("1",0.0f) >> 1.0f
* ofFloat(null,0.0f) == 0.0f
* ofFloat("",1.0f) == 1.0f
* ofFloat("1",0.0f) == 1.0f
* </pre>
*
* @param number 包含单精度浮点型数字的字符串。
* @param defaultValue 默认返回的单精度浮点型数字。
* @return 单精度浮点型数字。
*/
public static float ofFloat(String number, float defaultValue) {
if (Strings.isNullOrEmpty(number)) {
Expand All @@ -102,21 +123,28 @@ public static float ofFloat(String number, float defaultValue) {

/**
* <pre>
* ofDouble(null) >> 0.0d
* ofDouble("") >> 0.0d
* ofDouble("1") >> 1.0d
* ofDouble(null) == 0.0d
* ofDouble("") == 0.0d
* ofDouble("1") == 1.0d
* </pre>
*
* @param number 包含双精度浮点型数字的字符串。
* @return 双精度浮点型数字。无效的字符串将默认返回 0.0d。
*/
public static double ofDouble(String number) {
return ofDouble(number, 0.0d);
}

/**
* <pre>
* ofDouble(null,0.0d) >> 0.0d
* ofDouble("",1.0d) >> 1.0d
* ofDouble("1",0.0d) >> 1.0d
* ofDouble(null,0.0d) == 0.0d
* ofDouble("",1.0d) == 1.0d
* ofDouble("1",0.0d) == 1.0d
* </pre>
*
* @param number 包含双精度浮点型数字的字符串。
* @param defaultValue 默认返回的双精度浮点型数字。
* @return 双精度浮点型数字。
*/
public static double ofDouble(String number, double defaultValue) {
if (Strings.isNullOrEmpty(number)) {
Expand All @@ -132,41 +160,55 @@ public static double ofDouble(String number, double defaultValue) {

/**
* <pre>
* ofDouble(null) >> 0.0d
* ofDouble(BigDecimal.valueOf(1.0d)) >> 1.0d
* ofDouble(null) == 0.0d
* ofDouble(BigDecimal.valueOf(1.0d)) == 1.0d
* </pre>
*
* @param number 大数值数字,带小数点。
* @return 双精度浮点型数字。无效的字符串将默认返回 0.0d。
*/
public static double ofDouble(BigDecimal number) {
return ofDouble(number, 0.0d);
}

/**
* <pre>
* ofDouble(null, 1.1d) >> 1.1d
* ofDouble(BigDecimal.valueOf(1.0d), 1.1d) >> 1.0d
* ofDouble(null, 1.1d) == 1.1d
* ofDouble(BigDecimal.valueOf(1.0d), 1.1d) == 1.0d
* </pre>
*
* @param number 大数值数字,带小数点。
* @param defaultValue 默认返回的双精度浮点型数字。
* @return 双精度浮点型数字。
*/
public static double ofDouble(BigDecimal number, double defaultValue) {
return number == null ? defaultValue : number.doubleValue();
}

/**
* <pre>
* ofByte(null) = 0
* ofByte("") = 0
* ofByte("1") = 1
* ofByte(null) == 0
* ofByte("") == 0
* ofByte("1") == 1
* </pre>
*
* @param number 仅包含字节数字的字符串。
* @return 字节数字。
*/
public static byte ofByte(String numer) {
return ofByte(numer, (byte) 0);
public static byte ofByte(String number) {
return ofByte(number, (byte) 0);
}

/**
* <pre>
* ofByte(null, 1) = 1
* ofByte("", 1) = 1
* ofByte("1", 0) = 1
* ofByte(null, 1) == 1
* ofByte("", 1) == 1
* ofByte("1", 0) == 1
* </pre>
*
* @param number 仅包含字节数字的字符串。
* @param defaultValue 默认返回的字节数字。
* @return 字节数字。
*/
public static byte ofByte(String number, byte defaultValue) {
if (Strings.isNullOrEmpty(number)) {
Expand All @@ -182,21 +224,28 @@ public static byte ofByte(String number, byte defaultValue) {

/**
* <pre>
* ofShort(null) = 0
* ofShort("") = 0
* ofShort("1") = 1
* ofShort(null) == 0
* ofShort("") == 0
* ofShort("1") == 1
* </pre>
*
* @param number 仅包含短整型数字的字符串。
* @return 短整型数字。
*/
public static short ofShort(String number) {
return ofShort(number, (short) 0);
}

/**
* <pre>
* ofShort(null, 1) = 1
* ofShort("", 1) = 1
* ofShort("1", 0) = 1
* ofShort(null, 1) == 1
* ofShort("", 1) == 1
* ofShort("1", 0) == 1
* </pre>
*
* @param number 仅包含短整型数字的字符串。
* @param defaultValue 默认返回的短整型数字。
* @return 短整型数字。
*/
public static short ofShort(String number, short defaultValue) {
if (number == null) {
Expand Down

0 comments on commit 74d3e0f

Please sign in to comment.