Guest User

Untitled

a guest
Dec 16th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. import java.util.Set;
  2. import java.util.TreeSet;
  3.  
  4. public class LoginCharLimiter {
  5.  
  6. private final Set<Character> chars = new TreeSet<>();
  7.  
  8.  
  9. public LoginCharLimiter(String chars){
  10. for(char ch : chars.toCharArray()){
  11. this.chars.add(ch);
  12. }
  13. }
  14.  
  15.  
  16. public String handle(String str){
  17. String splited[] = str.split("[;:]", 2);
  18. if(splited.length != 2)
  19. return null;
  20.  
  21.  
  22. for(char ch : splited[0].toCharArray()){
  23. if(!this.chars.contains(ch))
  24. return null;
  25. }
  26.  
  27. return str;
  28. }
  29. }
Add Comment
Please, Sign In to add comment