8000 Revert "[ISSUE #3102] Create utils class to nacos-common" by KomachiSion · Pull Request #4191 · alibaba/nacos · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Revert "[ISSUE #3102] Create utils class to nacos-common" #4191

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
175 changes: 0 additions & 175 deletions common/src/main/java/com/alibaba/nacos/common/utils/ArrayUtil.java

This file was deleted.

This file was deleted.

75 changes: 1 addition & 74 deletions 8000 common/src/main/java/com/alibaba/nacos/common/utils/ConvertUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -245,79 +245,6 @@ public static Boolean toBooleanObject(String str) {
}
}

/**
* <p>Convert a <code>String</code> to a <code>double</code>, returning a
* default value if the conversion fails.</p>
*
* <p>If the string <code>str</code> is <code>null</code>, the default
* value is returned.</p>
*
* <pre>
* NumberUtils.toDouble(null, 1.1d) = 1.1d
* NumberUtils.toDouble("", 1.1d) = 1.1d
* NumberUtils.toDouble("1.5", 0.0d) = 1.5d
* </pre>
*
* @param str the string to convert, may be <code>null</code>
* @param defaultValue the default value
* @return the double represented by the string, or defaultValue if conversion fails
*/
public static double toDouble(final String str, final double defaultValue) {
if (str == null) {
return defaultValue;
}
try {
return Double.parseDouble(str);
} catch (final NumberFormatException nfe) {
return defaultValue;
}
}
// end

/**
* <p>Convert a <code>String</code> to a <code>float</code>, returning
* <code>0.0f</code> if the conversion fails.</p>
*
* <p>If the string <code>str</code> is <code>null</code>,
* <code>0.0f</code> is returned.</p>
*
* <pre>
* NumberUtils.toFloat(null) = 0.0f
* NumberUtils.toFloat("") = 0.0f
* NumberUtils.toFloat("1.5") = 1.5f
* </pre>
*
* @param str the string to convert, may be <code>null</code>
* @return the float represented by the string, or <code>0.0f</code> if conversion fails
*/
public static float toFloat(final String str) {
return toFloat(str, 0.0f);
}

/**
* <p>Convert a <code>String</code> to a <code>float</code>, returning a
* default value if the conversion fails.</p>
*
* <p>If the string <code>str</code> is <code>null</code>, the default
* value is returned.</p>
*
* <pre>
* NumberUtils.toFloat(null, 1.1f) = 1.0f
* NumberUtils.toFloat("", 1.1f) = 1.1f
* NumberUtils.toFloat("1.5", 0.0f) = 1.5f
* </pre>
*
* @param str the string to convert, may be <code>null</code>
* @param defaultValue the default value
* @return the float represented by the string, or defaultValue if conversion fails
*/
public static float toFloat(final String str, final float defaultValue) {
if (str == null) {
return defaultValue;
}
try {
return Float.parseFloat(str);
} catch (final NumberFormatException nfe) {
return defaultValue;
}
}
}
Loading
0