-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Domain specific collision checker for id generator
- Loading branch information
1 parent
8727e11
commit daaec42
Showing
7 changed files
with
208 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,5 @@ | |
"iterations" : 4, | ||
"threads" : 1, | ||
"forks" : 3, | ||
"mean_ops" : 644166.1778513143 | ||
"mean_ops" : 738950.7655028169 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,5 @@ | |
"iterations" : 4, | ||
"threads" : 1, | ||
"forks" : 3, | ||
"mean_ops" : 502644.4941310657 | ||
"mean_ops" : 573183.379799968 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
ranger-discovery-bundle/src/main/java/io/appform/ranger/discovery/bundle/id/Domain.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package io.appform.ranger.discovery.bundle.id; | ||
|
||
|
||
import io.appform.ranger.discovery.bundle.id.constraints.IdValidationConstraint; | ||
import io.appform.ranger.discovery.bundle.id.formatter.DefaultIdFormatter; | ||
import io.appform.ranger.discovery.bundle.id.formatter.IdFormatter; | ||
import io.appform.ranger.discovery.bundle.id.formatter.IdFormatters; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NonNull; | ||
|
||
import java.util.List; | ||
import java.util.Objects; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
@Getter | ||
public class Domain { | ||
public static final String DEFAULT_DOMAIN_NAME = "__DEFAULT_DOMAIN__"; | ||
public static final Domain DEFAULT = new Domain(DEFAULT_DOMAIN_NAME, | ||
List.of(), | ||
new DefaultIdFormatter(), | ||
TimeUnit.MILLISECONDS); | ||
|
||
private final String domain; | ||
private final List<IdValidationConstraint> constraints; | ||
private final IdFormatter idFormatter; | ||
private final CollisionChecker collisionChecker; | ||
|
||
|
||
@Builder | ||
public Domain(@NonNull String domain, | ||
@NonNull List<IdValidationConstraint> constraints, | ||
IdFormatter idFormatter, | ||
TimeUnit resolution) { | ||
this.domain = domain; | ||
this.constraints = constraints; | ||
this.idFormatter = Objects.requireNonNullElse(idFormatter, IdFormatters.original()); | ||
this.collisionChecker = new CollisionChecker(Objects.requireNonNullElse(resolution, TimeUnit.MILLISECONDS)); | ||
} | ||
|
||
} |
Oops, something went wrong.