public static OrderId unique() { return new OrderId(UUID.randomUUID().toString().toUpperCase()); }
@Override public int hashCode() { int hashCodeValue = + (95123 * 89) + this.id().hashCode(); return hashCodeValue; }
public OrderId(String anId) { super(); this.setId(anId); }
public void testPaymentTotalAmount() throws Exception { final Money cost = new Money("1000.00"); final Money fee = new Money("9.99"); Payment payment = new Payment( AccountId.unique(), OrderId.unique(), "This is a test", cost, fee, new Date()); assertEquals(cost, payment.cost()); assertEquals(fee, payment.fee()); assertEquals(cost.addedTo(fee), payment.totalAmount()); }
@Override public int hashCode() { int hashCodeValue = + (45321 * 61) + this.accountId().hashCode() + this.orderId().hashCode(); return hashCodeValue; }
@Override public boolean equals(Object anObject) { boolean equalObjects = false; if (anObject != null && this.getClass() == anObject.getClass()) { BuyOrder typedObject = (BuyOrder) anObject; equalObjects = this.accountId().equals(typedObject.accountId()) && this.orderId().equals(typedObject.orderId()); } return equalObjects; }
public void testSaveWithOverwrite() throws Exception { Account account = this.accountFixture(); this.repository.save(account); assertTrue(account.holdings().isEmpty()); Account changedAccount = this.repository.accountOf(account.accountId()); Holding holding = new Holding( account.accountId(), OrderId.unique(), new TickerSymbol("GOOG"), 2, new Money("1490.25"), new Date()); changedAccount.reconcileWith(holding); this.repository.save(changedAccount); changedAccount = this.repository.accountOf(account.accountId()); assertFalse(changedAccount.holdings().isEmpty()); assertEquals(1, changedAccount.holdings().size()); }
@Override public int hashCode() { int hashCodeValue = + (87643 * 107) + this.accountId().hashCode() + this.cost().hashCode() + this.description().hashCode() + this.fee().hashCode() + this.orderId().hashCode() + this.paidOn().hashCode(); return hashCodeValue; }
@Override public boolean equals(Object anObject) { boolean equalObjects = false; if (anObject != null && this.getClass() == anObject.getClass()) { Payment typedObject = (Payment) anObject; equalObjects = this.accountId().equals(typedObject.accountId()) && this.cost().equals(typedObject.cost()) && this.description().equals(typedObject.description()) && this.fee().equals(typedObject.fee()) && this.orderId().equals(typedObject.orderId()) && this.paidOn().equals(typedObject.paidOn()); } return equalObjects; }
public BuyOrder( AccountId anAccountId, Quote aQuote, int aQuantityOfSharesOrdered, Money anOrderFee) { super(); this.setAccountId(anAccountId); this.setExecution(new PurchaseExecution(aQuantityOfSharesOrdered)); this.setOrderId(OrderId.unique()); this.setQuote(aQuote); DomainEventPublisher.instance().publish( new BuyOrderPlaced( this.accountId(), this.orderId(), this.quote(), this.execution().quantityOfSharesOrdered(), this.execution().openDate(), aQuote.price().multipliedBy(aQuantityOfSharesOrdered), anOrderFee)); }
@Override public int hashCode() { int hashCodeValue = + (72721 * 97) + this.accountId().hashCode() + this.acquiredOn().hashCode() + this.numberOfShares() + this.orderId().hashCode() + this.tickerSymbol().hashCode() + this.totalValue().hashCode(); return hashCodeValue; }
@Override public boolean equals(Object anObject) { boolean equalObjects = false; if (anObject != null && this.getClass() == anObject.getClass()) { Holding typedObject = (Holding) anObject; equalObjects = this.accountId().equals(typedObject.accountId()) && this.acquiredOn().equals(typedObject.acquiredOn()) && this.numberOfShares() == typedObject.numberOfShares() && this.orderId().equals(typedObject.orderId()) && this.tickerSymbol().equals(typedObject.tickerSymbol()) && this.totalValue().equals(typedObject.totalValue()); } return equalObjects; }
@Override public BuyOrder orderOf(OrderId anOrderId) { return this.orders().get(anOrderId.id()); }
@Override public void remove(BuyOrder aOrder) { this.orders().remove(aOrder.orderId().id()); }
@Override public void save(BuyOrder aOrder) { this.orders().put(aOrder.orderId().id(), aOrder); }