diff --git a/core-api/src/main/java/org/axonframework/samples/trader/api/orders/trades/AbstractOrderCommand.java b/core-api/src/main/java/org/axonframework/samples/trader/api/orders/trades/AbstractOrderCommand.java deleted file mode 100644 index 055a804..0000000 --- a/core-api/src/main/java/org/axonframework/samples/trader/api/orders/trades/AbstractOrderCommand.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2010-2012. Axon Framework - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.axonframework.samples.trader.api.orders.trades; - -import org.axonframework.commandhandling.TargetAggregateIdentifier; - -import javax.validation.constraints.Min; - -/** - *

Abstract parent class for all commands that are order related.

- * - * @author Allard Buijze - */ -public abstract class AbstractOrderCommand { - - private PortfolioId portfolioId; - @TargetAggregateIdentifier - private OrderBookId orderBookId; - private TransactionId transactionId; - @Min(0) - private long tradeCount; - @Min(0) - private long itemPrice; - private OrderId orderId; - - protected AbstractOrderCommand(OrderId orderId, PortfolioId portfolioId, OrderBookId orderBookId, - TransactionId transactionId, long tradeCount, long itemPrice) { - this.portfolioId = portfolioId; - this.orderBookId = orderBookId; - this.tradeCount = tradeCount; - this.itemPrice = itemPrice; - this.transactionId = transactionId; - this.orderId = orderId; - } - - public PortfolioId getPortfolioId() { - return portfolioId; - } - - public OrderBookId getOrderBookId() { - return orderBookId; - } - - public TransactionId getTransactionId() { - return transactionId; - } - - public long getTradeCount() { - return tradeCount; - } - - public long getItemPrice() { - return itemPrice; - } - - public OrderId getOrderId() { - return orderId; - } -} diff --git a/core-api/src/main/java/org/axonframework/samples/trader/api/orders/trades/AbstractOrderPlacedEvent.java b/core-api/src/main/java/org/axonframework/samples/trader/api/orders/trades/AbstractOrderPlacedEvent.java deleted file mode 100644 index b51fd6c..0000000 --- a/core-api/src/main/java/org/axonframework/samples/trader/api/orders/trades/AbstractOrderPlacedEvent.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2010-2012. Axon Framework - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.axonframework.samples.trader.api.orders.trades; - -/** - *

Abstract parent class for all buy and sell order placed events.

- * - * @author Allard Buijze - */ -public abstract class AbstractOrderPlacedEvent { - - private final OrderBookId orderBookId; - private final OrderId orderId; - private TransactionId transactionId; - private final long tradeCount; - private final long itemPrice; - private final PortfolioId portfolioId; - - protected AbstractOrderPlacedEvent(OrderBookId orderBookId, OrderId orderId, TransactionId transactionId, - long tradeCount, long itemPrice, PortfolioId portfolioId) { - this.orderId = orderId; - this.transactionId = transactionId; - this.tradeCount = tradeCount; - this.itemPrice = itemPrice; - this.portfolioId = portfolioId; - this.orderBookId = orderBookId; - } - - public OrderBookId orderBookIdentifier() { - return this.orderBookId; - } - - public TransactionId getTransactionIdentifier() { - return transactionId; - } - - public OrderId getOrderId() { - return orderId; - } - - public long getTradeCount() { - return tradeCount; - } - - public long getItemPrice() { - return itemPrice; - } - - public PortfolioId getPortfolioId() { - return portfolioId; - } -} diff --git a/core-api/src/main/java/org/axonframework/samples/trader/api/orders/trades/BuyOrderPlacedEvent.java b/core-api/src/main/java/org/axonframework/samples/trader/api/orders/trades/BuyOrderPlacedEvent.java deleted file mode 100644 index d31cb5f..0000000 --- a/core-api/src/main/java/org/axonframework/samples/trader/api/orders/trades/BuyOrderPlacedEvent.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2010-2012. Axon Framework - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.axonframework.samples.trader.api.orders.trades; - -/** - *

A new Buy Order is placed.

- * - * @author Allard Buijze - */ -public class BuyOrderPlacedEvent extends AbstractOrderPlacedEvent { - - public BuyOrderPlacedEvent(OrderBookId orderBookId, OrderId orderId, TransactionId transactionId, long tradeCount, - long itemPrice, PortfolioId portfolioId) { - super(orderBookId, orderId, transactionId, tradeCount, itemPrice, portfolioId); - } -} diff --git a/core-api/src/main/java/org/axonframework/samples/trader/api/orders/trades/CreateBuyOrderCommand.java b/core-api/src/main/java/org/axonframework/samples/trader/api/orders/trades/CreateBuyOrderCommand.java deleted file mode 100644 index b1100a5..0000000 --- a/core-api/src/main/java/org/axonframework/samples/trader/api/orders/trades/CreateBuyOrderCommand.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2010-2012. Axon Framework - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.axonframework.samples.trader.api.orders.trades; - -/** - *

Create a new Buy Order.

- * - * @author Allard Buijze - */ -public class CreateBuyOrderCommand extends AbstractOrderCommand { - - public CreateBuyOrderCommand(OrderId orderId, PortfolioId portfolioId, OrderBookId orderBookId, - TransactionId transactionId, long tradeCount, long itemPrice) { - super(orderId, portfolioId, orderBookId, transactionId, tradeCount, itemPrice); - } -} diff --git a/core-api/src/main/java/org/axonframework/samples/trader/api/orders/trades/CreateOrderBookCommand.java b/core-api/src/main/java/org/axonframework/samples/trader/api/orders/trades/CreateOrderBookCommand.java deleted file mode 100644 index 59bb546..0000000 --- a/core-api/src/main/java/org/axonframework/samples/trader/api/orders/trades/CreateOrderBookCommand.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2010-2012. Axon Framework - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.axonframework.samples.trader.api.orders.trades; - -/** - *

Create a new OrderBook for the Company represented by the provided companyIdentifier.

- * - * @author Jettro Coenradie - */ -public class CreateOrderBookCommand { - - private OrderBookId orderBookId; - - public CreateOrderBookCommand(OrderBookId orderBookId) { - this.orderBookId = orderBookId; - } - - public OrderBookId getOrderBookIdentifier() { - return this.orderBookId; - } - -} diff --git a/core-api/src/main/java/org/axonframework/samples/trader/api/orders/trades/CreateSellOrderCommand.java b/core-api/src/main/java/org/axonframework/samples/trader/api/orders/trades/CreateSellOrderCommand.java deleted file mode 100644 index ee4dda4..0000000 --- a/core-api/src/main/java/org/axonframework/samples/trader/api/orders/trades/CreateSellOrderCommand.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2010-2012. Axon Framework - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.axonframework.samples.trader.api.orders.trades; - -/** - *

Create a new Sell Order using the amount of items to sell for the provided price.

- * - * @author Allard Buijze - */ -public class CreateSellOrderCommand extends AbstractOrderCommand { - - public CreateSellOrderCommand(OrderId orderId, PortfolioId portfolioId, OrderBookId orderBookId, - TransactionId transactionId, long tradeCount, long itemPrice) { - super(orderId, portfolioId, orderBookId, transactionId, tradeCount, itemPrice); - } -} diff --git a/core-api/src/main/java/org/axonframework/samples/trader/api/orders/trades/OrderBookCreatedEvent.java b/core-api/src/main/java/org/axonframework/samples/trader/api/orders/trades/OrderBookCreatedEvent.java deleted file mode 100644 index c424cff..0000000 --- a/core-api/src/main/java/org/axonframework/samples/trader/api/orders/trades/OrderBookCreatedEvent.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2010-2012. Axon Framework - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.axonframework.samples.trader.api.orders.trades; - -/** - *

A new OrderBook is created for the company with the provided identifier.

- * - * @author Jettro Coenradie - */ -public class OrderBookCreatedEvent { - - private OrderBookId orderBookId; - - public OrderBookCreatedEvent(OrderBookId orderBookId) { - this.orderBookId = orderBookId; - } - - public OrderBookId getOrderBookIdentifier() { - return this.orderBookId; - } -} diff --git a/core-api/src/main/java/org/axonframework/samples/trader/api/orders/trades/OrderBookId.java b/core-api/src/main/java/org/axonframework/samples/trader/api/orders/trades/OrderBookId.java deleted file mode 100644 index 5baa5cf..0000000 --- a/core-api/src/main/java/org/axonframework/samples/trader/api/orders/trades/OrderBookId.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2012. Axon Framework - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.axonframework.samples.trader.api.orders.trades; - -import org.axonframework.common.Assert; -import org.axonframework.common.IdentifierFactory; - -import java.io.Serializable; - -/** - * @author Jettro Coenradie - */ -public class OrderBookId implements Serializable { - private static final long serialVersionUID = -7842002574176005113L; - - private String identifier; - - public OrderBookId() { - this.identifier = IdentifierFactory.getInstance().generateIdentifier(); - } - - public OrderBookId(String identifier) { - Assert.notNull(identifier, () -> "Identifier may not be null"); - this.identifier = identifier; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - OrderBookId that = (OrderBookId) o; - - return identifier.equals(that.identifier); - - } - - @Override - public int hashCode() { - return identifier.hashCode(); - } - - @Override - public String toString() { - return identifier; - } -} diff --git a/core-api/src/main/java/org/axonframework/samples/trader/api/orders/trades/OrderId.java b/core-api/src/main/java/org/axonframework/samples/trader/api/orders/trades/OrderId.java deleted file mode 100644 index a343953..0000000 --- a/core-api/src/main/java/org/axonframework/samples/trader/api/orders/trades/OrderId.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2012. Axon Framework - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.axonframework.samples.trader.api.orders.trades; - -import org.axonframework.common.Assert; -import org.axonframework.common.IdentifierFactory; - -import java.io.Serializable; - -/** - * @author Jettro Coenradie - */ -public class OrderId implements Serializable { - private static final long serialVersionUID = 4034328048230397374L; - private String identifier; - - /** - * Constructor uses the IdentifierFactory to generate an identifier. - */ - public OrderId() { - this.identifier = IdentifierFactory.getInstance().generateIdentifier(); - } - - public OrderId(String identifier) { - Assert.notNull(identifier, () -> "Identifier may not be null"); - this.identifier = identifier; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - OrderId orderId = (OrderId) o; - - return identifier.equals(orderId.identifier); - - } - - @Override - public int hashCode() { - return identifier.hashCode(); - } - - @Override - public String toString() { - return identifier; - } - - -} diff --git a/core-api/src/main/java/org/axonframework/samples/trader/api/orders/trades/PortfolioId.java b/core-api/src/main/java/org/axonframework/samples/trader/api/orders/trades/PortfolioId.java deleted file mode 100644 index dcdf6e2..0000000 --- a/core-api/src/main/java/org/axonframework/samples/trader/api/orders/trades/PortfolioId.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2012. Axon Framework - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.axonframework.samples.trader.api.orders.trades; - -import org.axonframework.common.Assert; -import org.axonframework.common.IdentifierFactory; - -import java.io.Serializable; - -/** - * @author Jettro Coenradie - */ -public class PortfolioId implements Serializable { - private static final long serialVersionUID = 6784433385287437985L; - - private String identifier; - - public PortfolioId() { - this.identifier = IdentifierFactory.getInstance().generateIdentifier(); - } - - public PortfolioId(String identifier) { - Assert.notNull(identifier, () -> "Identifier may not be null"); - this.identifier = identifier; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - PortfolioId that = (PortfolioId) o; - - return identifier.equals(that.identifier); - - } - - @Override - public int hashCode() { - return identifier.hashCode(); - } - - @Override - public String toString() { - return identifier; - } -} diff --git a/core-api/src/main/java/org/axonframework/samples/trader/api/orders/trades/SellOrderPlacedEvent.java b/core-api/src/main/java/org/axonframework/samples/trader/api/orders/trades/SellOrderPlacedEvent.java deleted file mode 100644 index ee981b9..0000000 --- a/core-api/src/main/java/org/axonframework/samples/trader/api/orders/trades/SellOrderPlacedEvent.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2010-2012. Axon Framework - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.axonframework.samples.trader.api.orders.trades; - -/** - *

A new Sell Order is placed for the current OrderBook.

- * - * @author Allard Buijze - */ -public class SellOrderPlacedEvent extends AbstractOrderPlacedEvent { - - public SellOrderPlacedEvent(OrderBookId orderBookId, OrderId orderId, TransactionId transactionId, long tradeCount, - long itemPrice, PortfolioId portfolioId) { - super(orderBookId, orderId, transactionId, tradeCount, itemPrice, portfolioId); - } -} diff --git a/core-api/src/main/java/org/axonframework/samples/trader/api/orders/trades/TradeExecutedEvent.java b/core-api/src/main/java/org/axonframework/samples/trader/api/orders/trades/TradeExecutedEvent.java deleted file mode 100644 index ee9e8be..0000000 --- a/core-api/src/main/java/org/axonframework/samples/trader/api/orders/trades/TradeExecutedEvent.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2010-2012. Axon Framework - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.axonframework.samples.trader.api.orders.trades; - -import java.io.Serializable; - -/** - *

A new trade has been executed. The event contains the amount of items that are traded and the price for the items - * that are traded. The event also contains the identifiers for the Buy Order and the Sell order.

- * - * @author Allard Buijze - */ -public class TradeExecutedEvent implements Serializable { - private static final long serialVersionUID = 6292249351659536792L; - - private final long tradeCount; - private final long tradePrice; - private final OrderId buyOrderId; - private final OrderId sellOrderId; - private final TransactionId buyTransactionId; - private final TransactionId sellTransactionId; - private final OrderBookId orderBookId; - - public TradeExecutedEvent(OrderBookId orderBookId, - long tradeCount, - long tradePrice, - OrderId buyOrderId, - OrderId sellOrderId, - TransactionId buyTransactionId, - TransactionId sellTransactionId) { - this.tradeCount = tradeCount; - this.tradePrice = tradePrice; - this.buyOrderId = buyOrderId; - this.sellOrderId = sellOrderId; - this.sellTransactionId = sellTransactionId; - this.buyTransactionId = buyTransactionId; - this.orderBookId = orderBookId; - } - - public OrderBookId getOrderBookIdentifier() { - return this.orderBookId; - } - - public long getTradeCount() { - return tradeCount; - } - - public long getTradePrice() { - return tradePrice; - } - - public OrderId getBuyOrderId() { - return buyOrderId; - } - - public OrderId getSellOrderId() { - return sellOrderId; - } - - public TransactionId getBuyTransactionId() { - return buyTransactionId; - } - - public TransactionId getSellTransactionId() { - return sellTransactionId; - } -} diff --git a/core-api/src/main/java/org/axonframework/samples/trader/api/orders/trades/TransactionId.java b/core-api/src/main/java/org/axonframework/samples/trader/api/orders/trades/TransactionId.java deleted file mode 100644 index b3b8e88..0000000 --- a/core-api/src/main/java/org/axonframework/samples/trader/api/orders/trades/TransactionId.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2012. Axon Framework - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.axonframework.samples.trader.api.orders.trades; - -import org.axonframework.common.Assert; -import org.axonframework.common.IdentifierFactory; - -import java.io.Serializable; - -/** - * @author Jettro Coenradie - */ -public class TransactionId implements Serializable { - private static final long serialVersionUID = -5267104328616955617L; - - private String identifier; - - public TransactionId() { - this.identifier = IdentifierFactory.getInstance().generateIdentifier(); - } - - public TransactionId(String identifier) { - Assert.notNull(identifier, () -> "Identifier may not be null"); - this.identifier = identifier; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - TransactionId that = (TransactionId) o; - - return identifier.equals(that.identifier); - - } - - @Override - public int hashCode() { - return identifier.hashCode(); - } - - @Override - public String toString() { - return identifier; - } -} diff --git a/core-api/src/main/java/org/axonframework/samples/trader/api/orders/trades/commands.kt b/core-api/src/main/java/org/axonframework/samples/trader/api/orders/trades/commands.kt new file mode 100644 index 0000000..db71376 --- /dev/null +++ b/core-api/src/main/java/org/axonframework/samples/trader/api/orders/trades/commands.kt @@ -0,0 +1,33 @@ +package org.axonframework.samples.trader.api.orders.trades + +import org.axonframework.commandhandling.TargetAggregateIdentifier +import javax.validation.constraints.Min + +abstract class AbstractOrderCommand( + open val orderId: OrderId, + open val portfolioId: PortfolioId, + @TargetAggregateIdentifier open val orderBookId: OrderBookId, + open val transactionId: TransactionId, + @Min(0) open val tradeCount: Long, + @Min(0) open val itemPrice: Long +) + +data class CreateBuyOrderCommand( + override val orderId: OrderId, + override val portfolioId: PortfolioId, + override val orderBookId: OrderBookId, + override val transactionId: TransactionId, + override val tradeCount: Long, + override val itemPrice: Long +) : AbstractOrderCommand(orderId, portfolioId, orderBookId, transactionId, tradeCount, itemPrice) + +data class CreateSellOrderCommand( + override val orderId: OrderId, + override val portfolioId: PortfolioId, + override val orderBookId: OrderBookId, + override val transactionId: TransactionId, + override val tradeCount: Long, + override val itemPrice: Long +) : AbstractOrderCommand(orderId, portfolioId, orderBookId, transactionId, tradeCount, itemPrice) + +data class CreateOrderBookCommand(@TargetAggregateIdentifier val orderBookIdentifier: OrderBookId) diff --git a/core-api/src/main/java/org/axonframework/samples/trader/api/orders/trades/events.kt b/core-api/src/main/java/org/axonframework/samples/trader/api/orders/trades/events.kt new file mode 100644 index 0000000..bfaffbe --- /dev/null +++ b/core-api/src/main/java/org/axonframework/samples/trader/api/orders/trades/events.kt @@ -0,0 +1,46 @@ +package org.axonframework.samples.trader.api.orders.trades + +import java.io.Serializable + +abstract class AbstractOrderPlacedEvent( + open val orderBookId: OrderBookId, + open val orderId: OrderId, + open val transactionId: TransactionId, + open val tradeCount: Long, + open val itemPrice: Long, + open val portfolioId: PortfolioId +) + +data class BuyOrderPlacedEvent( + override val orderBookId: OrderBookId, + override val orderId: OrderId, + override val transactionId: TransactionId, + override val tradeCount: Long, + override val itemPrice: Long, + override val portfolioId: PortfolioId +) : AbstractOrderPlacedEvent(orderBookId, orderId, transactionId, tradeCount, itemPrice, portfolioId) + +data class SellOrderPlacedEvent( + override val orderBookId: OrderBookId, + override val orderId: OrderId, + override val transactionId: TransactionId, + override val tradeCount: Long, + override val itemPrice: Long, + override val portfolioId: PortfolioId +) : AbstractOrderPlacedEvent(orderBookId, orderId, transactionId, tradeCount, itemPrice, portfolioId) + +data class OrderBookCreatedEvent(val orderBookId: OrderBookId) + +data class TradeExecutedEvent( + val orderBookIdentifier: OrderBookId, + val tradeCount: Long, + val tradePrice: Long, + val buyOrderId: OrderId, + val sellOrderId: OrderId, + val buyTransactionId: TransactionId, + val sellTransactionId: TransactionId +) : Serializable { + companion object { + private const val serialVersionUID = 6292249351659536792L + } +} diff --git a/core-api/src/main/java/org/axonframework/samples/trader/api/orders/trades/valueObjects.kt b/core-api/src/main/java/org/axonframework/samples/trader/api/orders/trades/valueObjects.kt new file mode 100644 index 0000000..0cb3626 --- /dev/null +++ b/core-api/src/main/java/org/axonframework/samples/trader/api/orders/trades/valueObjects.kt @@ -0,0 +1,37 @@ +package org.axonframework.samples.trader.api.orders.trades + +import org.axonframework.common.IdentifierFactory +import java.io.Serializable + +data class OrderBookId(val identifier: String = IdentifierFactory.getInstance().generateIdentifier()) : Serializable { + + companion object { + private const val serialVersionUID = -7842002574176005113L + } + +} + +data class OrderId(val identifier: String = IdentifierFactory.getInstance().generateIdentifier()) : Serializable { + + companion object { + private const val serialVersionUID = 4034328048230397374L + } + +} + +data class PortfolioId(val identifier: String = IdentifierFactory.getInstance().generateIdentifier()) : Serializable { + + companion object { + private const val serialVersionUID = 6784433385287437985L + } + +} + + +class TransactionId(val identifier: String = IdentifierFactory.getInstance().generateIdentifier()) : Serializable { + + companion object { + private const val serialVersionUID = -5267104328616955617L + } + +}