Created
February 5, 2018 11:40
-
-
Save nicolopignatelli/f5d460e8ecb99e83a6b9e6240457036f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
package com.mywonderfulbnb.bnb.definition | |
final class ActivatedOwnerNotFound extends Exception { | |
private OwnerId ownerId; | |
public ActivatedOwnerNotFound(OwnerId ownerId) { | |
this.ownerId = ownerId; | |
} | |
} |
This file contains hidden or 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
package com.mywonderfulbnb.bnb.definition | |
interface ActivatedOwners { | |
bool existsOneWithId(OwnerId ownerId); | |
} |
This file contains hidden or 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
package com.mywonderfulbnb.bnb.definition | |
final class Service { | |
private ActivatedOwners activatedOwners; | |
public Service(ActivatedOwners activatedOwners) { | |
this.activatedOwners = activatedOwners; | |
} | |
public addBnb(UUID ownerUuid, UUID bnbUuid, String nameStr) { | |
ownerId = new OwnerId(ownerUuid); | |
bnbId = new BnbId(bnbUuid); | |
name = new Name(nameStr); | |
assertOwnerIsActivated(ownerId); | |
} | |
private assertOwnerIsActivated(OwnerId ownerId) { | |
itExists = activatedOwners.existsOneWithId(ownerId); | |
if (!itExists) { | |
throw new ActivatedOwnerNotFound(ownerId); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment