Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions fluent-interface/etc/fluent-interface.urm.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
@startuml
package com.iluwatar.fluentinterface.fluentiterable.simple {
class SimpleFluentIterable<E> {
- iterable : Iterable<E>
+ SimpleFluentIterable<E>(iterable : Iterable<E>)
+ asList() : List<E>
+ filter(predicate : Predicate<? super E>) : FluentIterable<E>
+ first() : Optional<E>
+ first(count : int) : FluentIterable<E>
+ forEach(action : Consumer<? super E>)
+ from(iterable : Iterable<E>) : FluentIterable<E> {static}
+ fromCopyOf(iterable : Iterable<E>) : FluentIterable<E> {static}
+ getRemainingElementsCount() : int
+ iterator() : Iterator<E>
+ last() : Optional<E>
+ last(count : int) : FluentIterable<E>
+ map(function : Function<? super E, T>) : FluentIterable<T>
+ spliterator() : Spliterator<E>
+ toList(iterator : Iterator<E>) : List<E> {static}
}
}
package com.iluwatar.fluentinterface.app {
class App {
- LOGGER : Logger {static}
+ App()
+ main(args : String[]) {static}
- negatives() : Predicate<? super Integer> {static}
- positives() : Predicate<? super Integer> {static}
- prettyPrint(delimiter : String, prefix : String, iterable : Iterable<E>) {static}
- prettyPrint(prefix : String, iterable : Iterable<E>) {static}
- transformToString() : Function<Integer, String> {static}
}
}
package com.iluwatar.fluentinterface.fluentiterable.lazy {
abstract class DecoratingIterator<E> {
# fromIterator : Iterator<E>
- next : E
+ DecoratingIterator<E>(fromIterator : Iterator<E>)
+ computeNext() : E {abstract}
+ hasNext() : boolean
+ next() : E
}
class LazyFluentIterable<E> {
- iterable : Iterable<E>
# LazyFluentIterable<E>()
+ LazyFluentIterable<E>(iterable : Iterable<E>)
+ asList() : List<E>
+ filter(predicate : Predicate<? super E>) : FluentIterable<E>
+ first() : Optional<E>
+ first(count : int) : FluentIterable<E>
+ from(iterable : Iterable<E>) : FluentIterable<E> {static}
+ iterator() : Iterator<E>
+ last() : Optional<E>
+ last(count : int) : FluentIterable<E>
+ map(function : Function<? super E, T>) : FluentIterable<T>
}
}
package com.iluwatar.fluentinterface.fluentiterable {
interface FluentIterable<E> {
+ asList() : List<E> {abstract}
+ copyToList(iterable : Iterable<E>) : List<E> {static}
+ filter(Predicate<? super E>) : FluentIterable<E> {abstract}
+ first() : Optional<E> {abstract}
+ first(int) : FluentIterable<E> {abstract}
+ last() : Optional<E> {abstract}
+ last(int) : FluentIterable<E> {abstract}
+ map(Function<? super E, T>) : FluentIterable<T> {abstract}
}
}
LazyFluentIterable ..|> FluentIterable
SimpleFluentIterable ..|> FluentIterable
@enduml
12 changes: 12 additions & 0 deletions function-composition/etc/function-composition.urm.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@startuml
package com.iluwatar.function.composition {
class App {
+ App()
+ main(args : String[]) {static}
}
class FunctionComposer {
+ FunctionComposer()
+ composeFunctions(f1 : Function<Integer, Integer>, f2 : Function<Integer, Integer>) : Function<Integer, Integer> {static}
}
}
@enduml
282 changes: 282 additions & 0 deletions hexagonal-architecture/etc/hexagonal-architecture.urm.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,282 @@
@startuml
package com.iluwatar.hexagonal.sampledata {
class SampleData {
- PLAYERS : List<PlayerDetails> {static}
- RANDOM : SecureRandom {static}
+ SampleData()
- getRandomPlayerDetails() : PlayerDetails {static}
+ submitTickets(lotteryService : LotteryService, numTickets : int) {static}
}
}
package com.iluwatar.hexagonal.service {
class ConsoleLottery {
- LOGGER : Logger {static}
+ ConsoleLottery()
+ main(args : String[]) {static}
- printMainMenu() {static}
- readString(scanner : Scanner) : String {static}
}
interface LotteryConsoleService {
+ addFundsToLotteryAccount(WireTransfers, Scanner) {abstract}
+ checkTicket(LotteryService, Scanner) {abstract}
+ queryLotteryAccountFunds(WireTransfers, Scanner) {abstract}
+ submitTicket(LotteryService, Scanner) {abstract}
}
class LotteryConsoleServiceImpl {
- logger : Logger
+ LotteryConsoleServiceImpl(logger : Logger)
+ addFundsToLotteryAccount(bank : WireTransfers, scanner : Scanner)
+ checkTicket(service : LotteryService, scanner : Scanner)
+ queryLotteryAccountFunds(bank : WireTransfers, scanner : Scanner)
- readString(scanner : Scanner) : String
+ submitTicket(service : LotteryService, scanner : Scanner)
}
}
package com.iluwatar.hexagonal.mongo {
class MongoConnectionPropertiesLoader {
- DEFAULT_HOST : String {static}
- DEFAULT_PORT : int {static}
- LOGGER : Logger {static}
+ MongoConnectionPropertiesLoader()
+ load() {static}
}
}
package com.iluwatar.hexagonal.domain {
class LotteryAdministration {
- notifications : LotteryEventLog
- repository : LotteryTicketRepository
- wireTransfers : WireTransfers
+ LotteryAdministration(repository : LotteryTicketRepository, notifications : LotteryEventLog, wireTransfers : WireTransfers)
+ getAllSubmittedTickets() : Map<LotteryTicketId, LotteryTicket>
+ performLottery() : LotteryNumbers
+ resetLottery()
}
class LotteryConstants {
+ PLAYER_MAX_BALANCE : int {static}
+ PRIZE_AMOUNT : int {static}
+ SERVICE_BANK_ACCOUNT : String {static}
+ SERVICE_BANK_ACCOUNT_BALANCE : int {static}
+ TICKET_PRIZE : int {static}
- LotteryConstants()
}
class LotteryNumbers {
+ MAX_NUMBER : int {static}
+ MIN_NUMBER : int {static}
+ NUM_NUMBERS : int {static}
- numbers : Set<Integer>
- LotteryNumbers()
- LotteryNumbers(givenNumbers : Set<Integer>)
# canEqual(other : Object) : boolean
+ create(givenNumbers : Set<Integer>) : LotteryNumbers {static}
+ createRandom() : LotteryNumbers {static}
+ equals(o : Object) : boolean
- generateRandomNumbers()
+ getNumbers() : Set<Integer>
+ getNumbersAsString() : String
+ hashCode() : int
+ toString() : String
}
-class RandomNumberGenerator {
- randomIterator : OfInt
+ RandomNumberGenerator(min : int, max : int)
+ nextInt() : int
}
class LotteryService {
- notifications : LotteryEventLog
- repository : LotteryTicketRepository
- wireTransfers : WireTransfers
+ LotteryService(repository : LotteryTicketRepository, notifications : LotteryEventLog, wireTransfers : WireTransfers)
+ checkTicketForPrize(id : LotteryTicketId, winningNumbers : LotteryNumbers) : LotteryTicketCheckResult
+ submitTicket(ticket : LotteryTicket) : Optional<LotteryTicketId>
}
class LotteryTicketCheckResult {
- prizeAmount : int
- result : CheckResult
+ LotteryTicketCheckResult(result : CheckResult)
+ LotteryTicketCheckResult(result : CheckResult, prizeAmount : int)
# canEqual(other : Object) : boolean
+ equals(o : Object) : boolean
+ getPrizeAmount() : int
+ getResult() : CheckResult
+ hashCode() : int
}
enum CheckResult {
+ NO_PRIZE {static}
+ TICKET_NOT_SUBMITTED {static}
+ WIN_PRIZE {static}
+ valueOf(name : String) : CheckResult {static}
+ values() : CheckResult[] {static}
}
class LotteryTicketId {
- id : int
- numAllocated : AtomicInteger {static}
+ LotteryTicketId()
+ LotteryTicketId(id : int)
# canEqual(other : Object) : boolean
+ equals(o : Object) : boolean
+ getId() : int
+ hashCode() : int
+ toString() : String
}
class LotteryUtils {
- LotteryUtils()
+ checkTicketForPrize(repository : LotteryTicketRepository, id : LotteryTicketId, winningNumbers : LotteryNumbers) : LotteryTicketCheckResult {static}
}
}
package com.iluwatar.hexagonal.banking {
class InMemoryBank {
- accounts : Map<String, Integer> {static}
+ InMemoryBank()
+ getFunds(bankAccount : String) : int
+ setFunds(bankAccount : String, amount : int)
+ transferFunds(amount : int, sourceAccount : String, destinationAccount : String) : boolean
}
class MongoBank {
- DEFAULT_ACCOUNTS_COLLECTION : String {static}
- DEFAULT_DB : String {static}
- accountsCollection : MongoCollection<Document>
- database : MongoDatabase
- mongoClient : MongoClient
+ MongoBank()
+ MongoBank(dbName : String, accountsCollectionName : String)
+ connect()
+ connect(dbName : String, accountsCollectionName : String)
+ getAccountsCollection() : MongoCollection<Document>
+ getDatabase() : MongoDatabase
+ getFunds(bankAccount : String) : int
+ getMongoClient() : MongoClient
+ setFunds(bankAccount : String, amount : int)
+ transferFunds(amount : int, sourceAccount : String, destinationAccount : String) : boolean
}
interface WireTransfers {
+ getFunds(String) : int {abstract}
+ setFunds(String, int) {abstract}
+ transferFunds(int, String, String) : boolean {abstract}
}
}
package com.iluwatar.hexagonal.database {
class InMemoryTicketRepository {
- tickets : Map<LotteryTicketId, LotteryTicket> {static}
+ InMemoryTicketRepository()
+ deleteAll()
+ findAll() : Map<LotteryTicketId, LotteryTicket>
+ findById(id : LotteryTicketId) : Optional<LotteryTicket>
+ save(ticket : LotteryTicket) : Optional<LotteryTicketId>
}
interface LotteryTicketRepository {
+ deleteAll() {abstract}
+ findAll() : Map<LotteryTicketId, LotteryTicket> {abstract}
+ findById(LotteryTicketId) : Optional<LotteryTicket> {abstract}
+ save(LotteryTicket) : Optional<LotteryTicketId> {abstract}
}
class MongoTicketRepository {
- DEFAULT_COUNTERS_COLLECTION : String {static}
- DEFAULT_DB : String {static}
- DEFAULT_TICKETS_COLLECTION : String {static}
- TICKET_ID : String {static}
- countersCollection : MongoCollection<Document>
- database : MongoDatabase
- mongoClient : MongoClient
- ticketsCollection : MongoCollection<Document>
+ MongoTicketRepository()
+ MongoTicketRepository(dbName : String, ticketsCollectionName : String, countersCollectionName : String)
+ connect()
+ connect(dbName : String, ticketsCollectionName : String, countersCollectionName : String)
+ deleteAll()
- docToTicket(doc : Document) : LotteryTicket
+ findAll() : Map<LotteryTicketId, LotteryTicket>
+ findById(id : LotteryTicketId) : Optional<LotteryTicket>
+ getCountersCollection() : MongoCollection<Document>
+ getNextId() : int
+ getTicketsCollection() : MongoCollection<Document>
- initCounters()
+ save(ticket : LotteryTicket) : Optional<LotteryTicketId>
}
}
package com.iluwatar.hexagonal {
class App {
+ App()
+ main(args : String[]) {static}
}
}
package com.iluwatar.hexagonal.administration {
class ConsoleAdministration {
- LOGGER : Logger {static}
+ ConsoleAdministration()
+ main(args : String[]) {static}
- printMainMenu() {static}
- readString(scanner : Scanner) : String {static}
}
interface ConsoleAdministrationSrv {
+ getAllSubmittedTickets() {abstract}
+ performLottery() {abstract}
+ resetLottery() {abstract}
}
class ConsoleAdministrationSrvImpl {
- administration : LotteryAdministration
- logger : Logger
+ ConsoleAdministrationSrvImpl(administration : LotteryAdministration, logger : Logger)
+ getAllSubmittedTickets()
+ performLottery()
+ resetLottery()
}
}
package com.iluwatar.hexagonal.eventlog {
interface LotteryEventLog {
+ prizeError(PlayerDetails, int) {abstract}
+ ticketDidNotWin(PlayerDetails) {abstract}
+ ticketSubmitError(PlayerDetails) {abstract}
+ ticketSubmitted(PlayerDetails) {abstract}
+ ticketWon(PlayerDetails, int) {abstract}
}
class MongoEventLog {
- DEFAULT_DB : String {static}
- DEFAULT_EVENTS_COLLECTION : String {static}
- EMAIL : String {static}
+ MESSAGE : String {static}
- PHONE : String {static}
- database : MongoDatabase
- eventsCollection : MongoCollection<Document>
- mongoClient : MongoClient
- stdOutEventLog : StdOutEventLog
+ MongoEventLog()
+ MongoEventLog(dbName : String, eventsCollectionName : String)
+ connect()
+ connect(dbName : String, eventsCollectionName : String)
+ getDatabase() : MongoDatabase
+ getEventsCollection() : MongoCollection<Document>
+ getMongoClient() : MongoClient
+ prizeError(details : PlayerDetails, prizeAmount : int)
+ ticketDidNotWin(details : PlayerDetails)
+ ticketSubmitError(details : PlayerDetails)
+ ticketSubmitted(details : PlayerDetails)
+ ticketWon(details : PlayerDetails, prizeAmount : int)
}
class StdOutEventLog {
- LOGGER : Logger {static}
+ StdOutEventLog()
+ prizeError(details : PlayerDetails, prizeAmount : int)
+ ticketDidNotWin(details : PlayerDetails)
+ ticketSubmitError(details : PlayerDetails)
+ ticketSubmitted(details : PlayerDetails)
+ ticketWon(details : PlayerDetails, prizeAmount : int)
}
}
LotteryAdministration --> "-wireTransfers" WireTransfers
LotteryService --> "-notifications" LotteryEventLog
LotteryAdministration --> "-repository" LotteryTicketRepository
MongoEventLog --> "-stdOutEventLog" StdOutEventLog
LotteryService --> "-wireTransfers" WireTransfers
LotteryAdministration --> "-notifications" LotteryEventLog
ConsoleAdministrationSrvImpl --> "-administration" LotteryAdministration
LotteryService --> "-repository" LotteryTicketRepository
LotteryTicketCheckResult --> "-result" CheckResult
ConsoleAdministrationSrvImpl ..|> ConsoleAdministrationSrv
InMemoryBank ..|> WireTransfers
MongoBank ..|> WireTransfers
InMemoryTicketRepository ..|> LotteryTicketRepository
MongoTicketRepository ..|> LotteryTicketRepository
MongoEventLog ..|> LotteryEventLog
StdOutEventLog ..|> LotteryEventLog
LotteryConsoleServiceImpl ..|> LotteryConsoleService
@enduml
Loading
Loading