title: How can i restrict the values of a variable?
body: <pre><code>Profissional prof = new Profissional(null, null);
  List&lt;Profissional&gt; profissional = new ArrayList&lt;Profissional&gt;();
  Scanner sc = new Scanner(System.in);
  while(true) {
      String comando = sc.next().toUpperCase();
  
      if (comando.contentEquals("RP")) {
          String categoriaPro = sc.next();
          if(!categoriaPro.equals("Medicina")) {
              System.out.println("Categoria inexistente");
          }else if(!categoriaPro.equals("Enfermagem")) {
              System.out.println("Categoria inexistente");
          }else if(!categoriaPro.equals("Auxiliar")) {
              System.out.println("Categoria inexistente");
          }
          String nomePro = sc.next();
          prof.NomeVerificacao(profissional , nomePro, categoriaPro);
      }
  
  
      if(comando.contentEquals("SAIR")) {
          break;
      }
  }
  
  for(Profissional pro : profissional) {
      System.out.println(pro);
  }
  </code></pre>
  
  <p>This is my main.</p>
  
  <pre><code>public class Profissional {
      private String nome;
      private String categoria;
  
      public Profissional(String nome, String categoria) {
          this.nome = nome;
          this.categoria = categoria;
      }
       // getters and setter
  
      public void NomeVerificacao(List&lt;Profissional&gt; profissional, String nome, String categoria) {
          if (profissional.isEmpty() == true) {
              profissional.add(new Profissional(nome, categoria));
          } else {
              int i = 0;
              for (; i &lt; profissional.size(); i++) {
                  if (profissional.get(i).nome.equals(nome)) {
                      System.out.println("Profissional existente.");
                      break;
                  }
              }
              if (i == profissional.size()) {
                  profissional.add(new Profissional(nome, categoria));
              }
          }
      }
  }
  </code></pre>
  
  <p>i'm trying to create Object, in this case is a professional of an hospital.
  What is done is that can't have more that one professional with the same name, but what i can't figure it out is how to restrict the value of "categoriaPro" to "Medicina", "Enfermagem" and "Auxiliar".
  And if it isn't one of them i print the messagem "Categoria inexistente".
  but it isn't working.
  can any body help??</p>