This repository has been archived by the owner on Dec 14, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update all user commands/events/valueObjects to Kotlin equivalents
Update all user commands/events/valueObjects to Kotlin equivalents #28
- Loading branch information
Showing
11 changed files
with
69 additions
and
270 deletions.
There are no files selected for viewing
44 changes: 0 additions & 44 deletions
44
...api/src/main/java/org/axonframework/samples/trader/api/users/AuthenticateUserCommand.java
This file was deleted.
Oops, something went wrong.
65 changes: 0 additions & 65 deletions
65
core-api/src/main/java/org/axonframework/samples/trader/api/users/CreateUserCommand.java
This file was deleted.
Oops, something went wrong.
34 changes: 0 additions & 34 deletions
34
...-api/src/main/java/org/axonframework/samples/trader/api/users/UserAuthenticatedEvent.java
This file was deleted.
Oops, something went wrong.
62 changes: 0 additions & 62 deletions
62
core-api/src/main/java/org/axonframework/samples/trader/api/users/UserCreatedEvent.java
This file was deleted.
Oops, something went wrong.
61 changes: 0 additions & 61 deletions
61
core-api/src/main/java/org/axonframework/samples/trader/api/users/UserId.java
This file was deleted.
Oops, something went wrong.
41 changes: 41 additions & 0 deletions
41
core-api/src/main/java/org/axonframework/samples/trader/api/users/commands.kt
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 org.axonframework.samples.trader.api.users | ||
|
||
import org.axonframework.commandhandling.TargetAggregateIdentifier | ||
import java.util.* | ||
import javax.validation.constraints.NotNull | ||
import javax.validation.constraints.Size | ||
|
||
abstract class UserCommand(@TargetAggregateIdentifier open val userId: UserId) | ||
|
||
class CreateUserCommand( | ||
override val userId: UserId, | ||
val name: String, @NotNull @Size(min = 3) | ||
val username: String, @NotNull @Size(min = 3) | ||
val password: String | ||
) : UserCommand(userId) | ||
|
||
data class AuthenticateUserCommand( | ||
override val userId: UserId, | ||
val userName: String, | ||
@NotNull @Size(min = 3) val password: CharArray | ||
) : UserCommand(userId) { | ||
|
||
override fun equals(other: Any?): Boolean { | ||
if (this === other) return true | ||
if (other !is AuthenticateUserCommand) return false | ||
|
||
if (userId != other.userId) return false | ||
if (userName != other.userName) return false | ||
if (!Arrays.equals(password, other.password)) return false | ||
|
||
return true | ||
} | ||
|
||
override fun hashCode(): Int { | ||
var result = userId.hashCode() | ||
result = 31 * result + userName.hashCode() | ||
result = 31 * result + Arrays.hashCode(password) | ||
return result | ||
} | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
core-api/src/main/java/org/axonframework/samples/trader/api/users/events.kt
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,12 @@ | ||
package org.axonframework.samples.trader.api.users | ||
|
||
abstract class UserEvent(open val userId: UserId) | ||
|
||
data class UserCreatedEvent( | ||
override val userId: UserId, | ||
val name: String, | ||
val username: String, | ||
val password: String | ||
) : UserEvent(userId) | ||
|
||
data class UserAuthenticatedEvent(override val userId: UserId) : UserEvent(userId) |
12 changes: 12 additions & 0 deletions
12
core-api/src/main/java/org/axonframework/samples/trader/api/users/valueObjects.kt
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,12 @@ | ||
package org.axonframework.samples.trader.api.users | ||
|
||
import org.axonframework.common.IdentifierFactory | ||
import java.io.Serializable | ||
|
||
data class UserId(val identifier: String = IdentifierFactory.getInstance().generateIdentifier()) : Serializable { | ||
|
||
companion object { | ||
private const val serialVersionUID = -4860092244272266543L | ||
} | ||
|
||
} |
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
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