package com.yami.trading.security.common.enums;
|
|
import java.util.Arrays;
|
import java.util.List;
|
import java.util.Map;
|
import java.util.stream.Collectors;
|
|
/**
|
* @program: trading-order-master
|
* @description: 充值币种
|
* @create: 2025-08-06 16:05
|
**/
|
public enum CryptoCurrencyEnum {
|
/*USDT_TRC20("usdt", "TRC20","usdt_trc20"),
|
USDT_ERC20("usdt", "ERC20","usdt_erc20"),
|
ETH("eth", "ETH","eth"),
|
BTC("btc", "BTC","btc"),
|
USDC_ERC20("usdc", "ERC20(1)","usdc_erc20(1)"),
|
USDC_ERC202("usdc", "ERC20(2)","usdc_erc20(2)"),
|
USDC_TRC20("usdc", "TRC20","usdc_trc20");*/
|
|
USDT_TRC20("usdt", "TRC20","USDT-TRC20", "usdt"),
|
USDT_ERC20("usdt", "ERC20","USDT-ERC20", "usdt"),
|
ETH("eth", "ETH","ETH", "ethusdt"),
|
BTC("btc", "BTC","BTC", "btcusdt"),
|
USDC_ERC20("usdc", "ERC20","USDC", "usdcusdt"),
|
USDC_TRC20("usdc", "TRC20","USDCTRC20", "usdcusdt");
|
|
|
private final String coin;
|
private final String chain;
|
private final String name;
|
private final String symbol;
|
|
CryptoCurrencyEnum(String coin, String chain,String name, String symbol) {
|
this.coin = coin;
|
this.chain = chain;
|
this.name = name;
|
this.symbol = symbol;
|
}
|
|
public String getSymbol() {
|
return symbol;
|
}
|
|
public String getCoin() {
|
return coin;
|
}
|
|
public String getChain() {
|
return chain;
|
}
|
|
public String getName() {
|
return name;
|
}
|
|
// 可选:根据代码获取枚举值的方法
|
public static CryptoCurrencyEnum fromCoin(String coin,String chain) {
|
for (CryptoCurrencyEnum currency : values()) {
|
if (currency.getCoin().equals(coin) && currency.getChain().equals(chain)) {
|
return currency;
|
}
|
}
|
throw new IllegalArgumentException("没找到对应的币种: " + coin);
|
}
|
|
/**
|
* 获取所有枚举值(返回 List)
|
*/
|
public static List<CryptoCurrencyEnum> getAll() {
|
return Arrays.asList(values());
|
}
|
|
/**
|
* 获取所有枚举值(按 coin 分组,返回 Map<String, List<CryptoCurrencyEnum>>)
|
*/
|
public static Map<String, List<CryptoCurrencyEnum>> getAllGroupedByCoin() {
|
return Arrays.stream(values())
|
.collect(Collectors.groupingBy(CryptoCurrencyEnum::getCoin));
|
}
|
|
/**
|
* 获取所有枚举值(按 chain 分组,返回 Map<String, List<CryptoCurrencyEnum>>)
|
*/
|
public static Map<String, List<CryptoCurrencyEnum>> getAllGroupedByChain() {
|
return Arrays.stream(values())
|
.collect(Collectors.groupingBy(CryptoCurrencyEnum::getChain));
|
}
|
}
|