-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c473cc3
commit b219941
Showing
26 changed files
with
165 additions
and
86 deletions.
There are no files selected for viewing
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
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
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
9 changes: 0 additions & 9 deletions
9
domain/src/main/java/br/com/ifsp/tickets/domain/shared/exceptions/IllegalCPFException.java
This file was deleted.
Oops, something went wrong.
9 changes: 9 additions & 0 deletions
9
.../src/main/java/br/com/ifsp/tickets/domain/shared/exceptions/IllegalDocumentException.java
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,9 @@ | ||
package br.com.ifsp.tickets.domain.shared.exceptions; | ||
|
||
public class IllegalDocumentException extends DomainException { | ||
|
||
public IllegalDocumentException(String cnpj) { | ||
super("Document '%s' is not valid".formatted(cnpj)); | ||
} | ||
|
||
} |
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
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
22 changes: 8 additions & 14 deletions
22
domain/src/main/java/br/com/ifsp/tickets/domain/user/vo/CPF.java
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 |
---|---|---|
@@ -1,41 +1,35 @@ | ||
package br.com.ifsp.tickets.domain.user.vo; | ||
|
||
import br.com.ifsp.tickets.domain.shared.ValueObject; | ||
import br.com.ifsp.tickets.domain.shared.exceptions.IllegalCPFException; | ||
import br.com.ifsp.tickets.domain.shared.exceptions.IllegalDocumentException; | ||
import br.com.ifsp.tickets.domain.shared.utils.ValidationUtils; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public class CPF extends ValueObject { | ||
|
||
private final String value; | ||
public class CPF extends Document { | ||
|
||
public CPF(String value) { | ||
if (value == null || value.isBlank()) | ||
throw new IllegalCPFException(value); | ||
super(value); | ||
|
||
if (!ValidationUtils.isCPF(value)) | ||
throw new IllegalCPFException(value); | ||
|
||
this.value = value; | ||
throw new IllegalDocumentException(value); | ||
} | ||
|
||
public String getInitials() { | ||
return value.substring(0, this.value.length() - 5) + "*****"; | ||
return this.getValue().substring(0, this.getValue().length() - 5) + "*****"; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
|
||
CPF cpf = (CPF) o; | ||
final CPF cpf = (CPF) o; | ||
|
||
return value.equals(cpf.value); | ||
return this.getValue().equals(cpf.getValue()); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return value.hashCode(); | ||
return this.getValue().hashCode(); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
domain/src/main/java/br/com/ifsp/tickets/domain/user/vo/Document.java
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,37 @@ | ||
package br.com.ifsp.tickets.domain.user.vo; | ||
|
||
import br.com.ifsp.tickets.domain.shared.ValueObject; | ||
import br.com.ifsp.tickets.domain.shared.exceptions.IllegalDocumentException; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public class Document extends ValueObject { | ||
|
||
private final String value; | ||
|
||
public Document(String value) { | ||
if (value == null || value.isBlank()) | ||
throw new IllegalDocumentException(value); | ||
|
||
this.value = value; | ||
} | ||
|
||
public String getInitials() { | ||
return this.value.substring(0, this.value.length() - 5) + "*****"; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
|
||
final Document doc = (Document) o; | ||
|
||
return this.value.equals(doc.value); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return this.value.hashCode(); | ||
} | ||
} |
Oops, something went wrong.