// Repository - Groovy
maven {
name = "whackdevelopment-snapshots"
url = "https://repo.whackdevelopment.com/repository/maven-snapshots/"
}
// Repository - Kotlin DSL
maven("https://repo.whackdevelopment.com/repository/maven-snapshots/")
// Import - Groovy
implementation "com.whackdevelopment.snowflake:snowflakeid:1.0.0-SNAPSHOT"
// Import - Kotlin DSL
implementation("com.whackdevelopment.snowflake:snowflakeid:1.0.0-SNAPSHOT")
<repository>
<id>whackdevelopment-snapshots</id>
<url>https://repo.whackdevelopment.com/repository/maven-snapshots/</url>
</repository>
<dependency>
<groupId>com.whackdevelopment.snowflake</groupId>
<artifactId>snowflakeid</artifactId>
<version>1.0.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
SnowflakeGenerator flakeGenerator=new SnowflakeGenerator(
/*machineId*/ 1, // optional, define machine id (defaults to 1)
/*timeOffset*/ 0 // optional, define a offset time (defaults to 0)
);
machineId: (Defaults to 1) A machine id or any random id. If you are generating id in distributed system, its highly advised to provide a proper machineId which is unique to different machines.
timeOffset: (Defaults to 0) Time offset will be subtracted from current time to get the first 42 bit of id. This help in generating smaller ids. ( not recommended )
Snowflake id1=flakeGenerator.generate(); // returns something like 112867124767768576
Snowflake id2=flakeGenerator.generate(); // returns something like 112867124784545792
String id1String=id1.toString();
String id2String=id2.toString();
Snowflake id1Clone=new Snowflake(id1.toString());