title: How to compare StringBuilder tokens with multiple java strings?
body: <ol>
  <li><p>My video will be published in all or any one or any two or any three of the below departments like </p>
  
  <p>Test1,Test2,Test3,Test4 etc...</p></li>
  <li><p>Programmatically I will fetch all the department names for my video and constructed as Java StringBuilder as below:</p>
  
  <p>Test1,Test2,Test3,Test4 etc.</p></li>
  <li><p>These departments has privacy values of one of the below enum constants:
  PUBLIC,PROTECTED,PRIVATE.</p></li>
  <li><p>If my department is public then video privacy is public.</p></li>
  <li>If my department is protected then video privacy is protected.</li>
  <li>If my department is private then video privacy is private.</li>
  </ol>
  
  <p>I can set video privacy as specified above if my video is published in single department. But if my video is published in more than one department and then one department privacy is public another department privacy is protected then I need to set it as protected considering the highest value.</p>
  
  <p>How to manage all these conditions like:</p>
  
  <ol>
  <li>If privacy is public, private, protected then set video privacy as private</li>
  <li>If privacy is public, public, protected then set video privacy as protected like these combinations</li>
  </ol>
  
  <p>Here is the code which gets all ids and privacies</p>
  
  <pre><code>List&lt;Integer&gt; newdepList = new ArrayList&lt;Integer&gt;();
      if(depName != null) {
          mediaVO.setDepNames(depName.toString());
          StringTokenizer st1 = new StringTokenizer(depName.toString(),",");
              if(depName.toString().contains(",")) {
                  System.out.println("Media is assigned to more than one dep" + depName );
                  while(st1.hasMoreTokens()) {
                      depname= st1.nextToken();
                      System.out.println("depname"+depname);
                      if(depname!= null) {
                      ListResponse resp = fetchDepDetails(depname);
                          if(resp.totalCount &gt;= 1) {
                              for(Department dep:resp.objects) {
                                  int rootdepId = Integer.valueOf(properties.getProperty("dep.id"));
                                  if(dep.parentId == rootdepid|| dep.id == rootdepId) {
                                      newdepList.add(dep.id);
                                      //System.out.println("Department Id :::::::"+dep.id);
                                      //PrivacyType pri = fetchDepPrivacy(dep.id);
                                      //System.out.println("Privacy for the retrieved channels -----&gt;"+pri);
                                  }
                              }
                          }
                      }
                  }
  </code></pre>
  
  <p>Thanks in advance,
  Sakuntala</p>