com.nepxion.discovery.common.util.MathsUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of discovery-common Show documentation
Show all versions of discovery-common Show documentation
Nepxion Discovery is a solution for Spring Cloud with blue green, gray, weight, limitation, circuit breaker, degrade, isolation, monitor, tracing, dye, failover, async agent
package com.nepxion.discovery.common.util;
/**
* Title: Nepxion Aquarius
* Description: Nepxion Aquarius
* Copyright: Copyright (c) 2017-2050
* Company: Nepxion
* @author Haojun Ren
* @version 1.0
*/
import org.apache.commons.lang3.StringUtils;
public class MathsUtil {
private static final char ASTERISK = '*';
public static Long calculate(String value) {
if (StringUtils.isEmpty(value)) {
return null;
}
long result = 1;
try {
String[] array = StringUtils.split(value, ASTERISK);
for (String data : array) {
result *= Long.parseLong(data.trim());
}
} catch (Exception e) {
return null;
}
return result;
}
}