All Downloads are FREE. Search and download functionalities are using the official Maven repository.

club.gclmit.chaos.executor.IDGeneratorExecutor Maven / Gradle / Ivy

package club.gclmit.chaos.executor;

import club.gclmit.chaos.enums.IDGenerator;
import club.gclmit.chaos.enums.IDGeneratorType;

/**
 * 

* ID 生成仓库 *

* * @author: gclm * @date: 2019-10-25 20:01:00 * @version: V1.0 * @since JDK1.8 */ public class IDGeneratorExecutor { /** *

* idGeneratorByLong:根据选择生成器类型,生成唯一ID *

* * @author 孤城落寞 * @param: type 证书类型 * @date 2019/10/22 21:16 * @return: java.lang.Long * @throws */ public static Long getLongId(IDGeneratorType type) { Long id = null; if (IDGeneratorType.SNOWFLAKE.equals(type)){ id = new SnowflakeDistributeId(0, 0).nextId(); } else if (IDGeneratorType.SNOWFLAKE_PLUS.equals(type)){ id = IDGenerator.BASIC.getIdGen(); } return id; } /** *

* idGeneratorByString: 根据选择生成器类型,生成唯一ID *

* * @author 孤城落寞 * @param: type 证书类型 * @date 2019/10/22 21:15 * @return: java.lang.String * @throws */ public static String getStringId(IDGeneratorType type) { String id = null; if (IDGeneratorType.SNOWFLAKE.equals(type)){ SnowflakeDistributeId snowflakeDistributeId = new SnowflakeDistributeId(0, 0); id = String.valueOf(snowflakeDistributeId.nextId()); } else if (IDGeneratorType.SNOWFLAKE_PLUS.equals(type)){ id = IDGenerator.BASIC.getIdGenStr(); } return id; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy