chavdardim1990

Untitled

Dec 14th, 2023
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. package com.example.regauto.dto;
  2.  
  3. public class Plate {
  4.  
  5. private final String value;
  6.  
  7. public Plate(String value) {
  8. validate(value);
  9. this.value = value;
  10. }
  11.  
  12. public String get() {
  13. return this.value;
  14. }
  15.  
  16. void validate(String value) {
  17. if(value == null) {
  18. throw new RuntimeException();
  19. }
  20.  
  21. for(int i=0; i < value.length(); i++) {
  22. char c = value.charAt(i);
  23. if(Character.isLetterOrDigit(c)) {
  24. continue;
  25. }
  26. throw new RuntimeException();
  27. }
  28. }
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment