forked from plusone/plusone-commons
统一工具类命名规则。
This commit is contained in:
@@ -24,7 +24,7 @@ import xyz.zhouxy.plusone.commons.base.JRE;
|
||||
import xyz.zhouxy.plusone.commons.collection.SafeConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* ConcurrentHashMapUtil
|
||||
* ConcurrentHashMapTools
|
||||
*
|
||||
* <p>
|
||||
* Java 8 的 {@link ConcurrentHashMap#computeIfAbsent(Object, Function)} 方法有 bug,
|
||||
@@ -38,9 +38,10 @@ import xyz.zhouxy.plusone.commons.collection.SafeConcurrentHashMap;
|
||||
* @see ConcurrentHashMap
|
||||
* @see SafeConcurrentHashMap
|
||||
*/
|
||||
public class ConcurrentHashMapUtil {
|
||||
public class ConcurrentHashMapTools {
|
||||
|
||||
public static <K, V> V computeIfAbsent(ConcurrentHashMap<K, V> map, final K key,
|
||||
public static <K, V> V computeIfAbsent(
|
||||
ConcurrentHashMap<K, V> map, final K key, // NOSONAR
|
||||
final Function<? super K, ? extends V> mappingFunction) {
|
||||
Objects.requireNonNull(map, "map");
|
||||
return JRE.isJava8()
|
||||
@@ -48,7 +49,8 @@ public class ConcurrentHashMapUtil {
|
||||
: map.computeIfAbsent(key, mappingFunction);
|
||||
}
|
||||
|
||||
public static <K, V> V computeIfAbsentForJava8(ConcurrentHashMap<K, V> map, final K key,
|
||||
public static <K, V> V computeIfAbsentForJava8(
|
||||
ConcurrentHashMap<K, V> map, final K key, // NOSONAR
|
||||
final Function<? super K, ? extends V> mappingFunction) {
|
||||
Objects.requireNonNull(key);
|
||||
Objects.requireNonNull(mappingFunction);
|
||||
@@ -66,7 +68,7 @@ public class ConcurrentHashMapUtil {
|
||||
return v;
|
||||
}
|
||||
|
||||
private ConcurrentHashMapUtil() {
|
||||
private ConcurrentHashMapTools() {
|
||||
throw new IllegalStateException("Utility class");
|
||||
}
|
||||
}
|
@@ -20,7 +20,7 @@ import xyz.zhouxy.plusone.commons.collection.SafeConcurrentHashMap;
|
||||
|
||||
import xyz.zhouxy.plusone.commons.collection.MapWrapper;
|
||||
|
||||
public class DateTimeUtil {
|
||||
public class DateTimeTools {
|
||||
|
||||
private static final MapWrapper<String, DateTimeFormatter> DATE_TIME_FORMATTER_CACHE = MapWrapper
|
||||
.<String, DateTimeFormatter>wrap(new SafeConcurrentHashMap<>())
|
||||
@@ -325,7 +325,7 @@ public class DateTimeUtil {
|
||||
return org.joda.time.DateTimeZone.forID(zone.getId());
|
||||
}
|
||||
|
||||
private DateTimeUtil() {
|
||||
private DateTimeTools() {
|
||||
throw new IllegalStateException("Utility class");
|
||||
}
|
||||
}
|
@@ -27,9 +27,9 @@ import com.google.common.base.Preconditions;
|
||||
*
|
||||
* @author <a href="https://gitee.com/zhouxy108">ZhouXY</a>
|
||||
*/
|
||||
public final class EnumUtil {
|
||||
public final class EnumTools {
|
||||
|
||||
private EnumUtil() {
|
||||
private EnumTools() {
|
||||
throw new IllegalStateException("Utility class");
|
||||
}
|
||||
|
@@ -17,7 +17,7 @@
|
||||
package xyz.zhouxy.plusone.commons.util;
|
||||
|
||||
/**
|
||||
* NumberUtil
|
||||
* Numbers
|
||||
*
|
||||
* @author <a href="https://gitee.com/zhouxy108">ZhouXY</a>
|
||||
*/
|
||||
|
@@ -38,7 +38,7 @@ import com.google.common.annotations.Beta;
|
||||
* @see OptionalLong
|
||||
* @see OptionalDouble
|
||||
*/
|
||||
public class OptionalUtil {
|
||||
public class OptionalTools {
|
||||
|
||||
/**
|
||||
* 将包装类 {@link Integer} 转为 {@link OptionalInt}(not null)。
|
||||
@@ -149,7 +149,7 @@ public class OptionalUtil {
|
||||
return optionalObj.isPresent() ? optionalObj.getAsDouble() : null;
|
||||
}
|
||||
|
||||
private OptionalUtil() {
|
||||
private OptionalTools() {
|
||||
throw new IllegalStateException("Utility class");
|
||||
}
|
||||
}
|
@@ -2,8 +2,8 @@ package xyz.zhouxy.plusone.commons.util;
|
||||
|
||||
import java.security.SecureRandom;
|
||||
|
||||
public final class RandomUtil {
|
||||
private RandomUtil() {
|
||||
public final class RandomTools {
|
||||
private RandomTools() {
|
||||
throw new IllegalStateException("Utility class");
|
||||
}
|
||||
|
@@ -35,7 +35,7 @@ import xyz.zhouxy.plusone.commons.collection.SafeConcurrentHashMap;
|
||||
* @author ZhouXY
|
||||
*
|
||||
*/
|
||||
public final class RegexUtil {
|
||||
public final class RegexTools {
|
||||
|
||||
private static final int DEFAULT_CACHE_INITIAL_CAPACITY = 64;
|
||||
private static final int MAX_CACHE_SIZE = 256;
|
||||
@@ -330,7 +330,7 @@ public final class RegexUtil {
|
||||
@Nonnull
|
||||
private static Pattern[] getAndCachePatternsInternal(@Nonnull final String[] patterns) {
|
||||
return Arrays.stream(patterns)
|
||||
.map(RegexUtil::getAndCachePatternInternal)
|
||||
.map(RegexTools::getAndCachePatternInternal)
|
||||
.toArray(Pattern[]::new);
|
||||
}
|
||||
|
||||
@@ -344,7 +344,7 @@ public final class RegexUtil {
|
||||
@Nonnull
|
||||
private static Pattern[] getPatternsInternal(@Nonnull final String[] patterns) {
|
||||
return Arrays.stream(patterns)
|
||||
.map(RegexUtil::getPatternInternal)
|
||||
.map(RegexTools::getPatternInternal)
|
||||
.toArray(Pattern[]::new);
|
||||
}
|
||||
|
||||
@@ -389,7 +389,7 @@ public final class RegexUtil {
|
||||
return Arrays.stream(array).allMatch(Objects::nonNull);
|
||||
}
|
||||
|
||||
private RegexUtil() {
|
||||
private RegexTools() {
|
||||
// 不允许实例化
|
||||
throw new IllegalStateException("Utility class");
|
||||
}
|
Reference in New Issue
Block a user