Skip to content

Commit

Permalink
add ids
Browse files Browse the repository at this point in the history
  • Loading branch information
AnthonyBuisset committed Aug 26, 2024
1 parent ef5e165 commit 1cb1aa6
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/main/java/onlydust/com/marketplace/kernel/model/ProgramId.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package onlydust.com.marketplace.kernel.model;

import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.experimental.SuperBuilder;

import java.util.UUID;

@NoArgsConstructor(staticName = "random")
@EqualsAndHashCode(callSuper = true)
@SuperBuilder
public class ProgramId extends UuidWrapper {
public static ProgramId of(@NonNull final UUID uuid) {
return ProgramId.builder().uuid(uuid).build();
}

public static ProgramId of(@NonNull final String uuid) {
return ProgramId.of(UUID.fromString(uuid));
}
}
21 changes: 21 additions & 0 deletions src/main/java/onlydust/com/marketplace/kernel/model/ProjectId.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package onlydust.com.marketplace.kernel.model;

import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.experimental.SuperBuilder;

import java.util.UUID;

@NoArgsConstructor(staticName = "random")
@EqualsAndHashCode(callSuper = true)
@SuperBuilder
public class ProjectId extends UuidWrapper {
public static ProjectId of(@NonNull final UUID uuid) {
return ProjectId.builder().uuid(uuid).build();
}

public static ProjectId of(@NonNull final String uuid) {
return ProjectId.of(UUID.fromString(uuid));
}
}
25 changes: 25 additions & 0 deletions src/main/java/onlydust/com/marketplace/kernel/model/RewardId.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package onlydust.com.marketplace.kernel.model;

import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.experimental.SuperBuilder;

import java.util.UUID;

@NoArgsConstructor(staticName = "random")
@EqualsAndHashCode(callSuper = true)
@SuperBuilder
public class RewardId extends UuidWrapper {
public static RewardId of(@NonNull final UUID uuid) {
return RewardId.builder().uuid(uuid).build();
}

public static RewardId of(@NonNull final String uuid) {
return RewardId.of(UUID.fromString(uuid));
}

public String pretty() {
return "#" + this.value().toString().substring(0, 5).toUpperCase();
}
}
25 changes: 25 additions & 0 deletions src/main/java/onlydust/com/marketplace/kernel/model/SponsorId.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package onlydust.com.marketplace.kernel.model;

import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.experimental.SuperBuilder;

import java.util.UUID;

@NoArgsConstructor(staticName = "random")
@EqualsAndHashCode(callSuper = true)
@SuperBuilder
public class SponsorId extends UuidWrapper {
public static SponsorId of(@NonNull final UUID uuid) {
return SponsorId.builder().uuid(uuid).build();
}

public static SponsorId of(@NonNull final String uuid) {
return SponsorId.of(UUID.fromString(uuid));
}

public String pretty() {
return "#" + this.value().toString().substring(0, 5).toUpperCase();
}
}
21 changes: 21 additions & 0 deletions src/main/java/onlydust/com/marketplace/kernel/model/UserId.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package onlydust.com.marketplace.kernel.model;

import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.experimental.SuperBuilder;

import java.util.UUID;

@NoArgsConstructor(staticName = "random")
@EqualsAndHashCode(callSuper = true)
@SuperBuilder
public class UserId extends UuidWrapper {
public static UserId of(@NonNull final UUID uuid) {
return UserId.builder().uuid(uuid).build();
}

public static UserId of(@NonNull final String uuid) {
return UserId.of(UUID.fromString(uuid));
}
}

0 comments on commit 1cb1aa6

Please sign in to comment.