Пример #1
0
 @Override
 public String[] unparse(LoadContext context, CDOMObject obj) {
   Changes<ShieldProfProvider> changes = context.obj.getListChanges(obj, ListKey.AUTO_SHIELDPROF);
   Changes<ChooseSelectionActor<?>> listChanges =
       context.getObjectContext().getListChanges(obj, ListKey.NEW_CHOOSE_ACTOR);
   Collection<ShieldProfProvider> added = changes.getAdded();
   Set<String> set = new TreeSet<String>();
   Collection<ChooseSelectionActor<?>> listAdded = listChanges.getAdded();
   boolean foundAny = false;
   boolean foundOther = false;
   if (listAdded != null && !listAdded.isEmpty()) {
     for (ChooseSelectionActor<?> cra : listAdded) {
       if (cra.getSource().equals(getTokenName())) {
         try {
           set.add(cra.getLstFormat());
           foundOther = true;
         } catch (PersistenceLayerException e) {
           context.addWriteMessage("Error writing Prerequisite: " + e);
           return null;
         }
       }
     }
   }
   if (added != null) {
     for (ShieldProfProvider spp : added) {
       StringBuilder sb = new StringBuilder();
       sb.append(spp.getLstFormat());
       if (spp.hasPrerequisites()) {
         sb.append('|');
         sb.append(getPrerequisiteString(context, spp.getPrerequisiteList()));
       }
       String ab = sb.toString();
       boolean isUnconditionalAll = Constants.LST_ALL.equals(ab);
       foundAny |= isUnconditionalAll;
       foundOther |= !isUnconditionalAll;
       set.add(ab);
     }
   }
   if (foundAny && foundOther) {
     context.addWriteMessage(
         "Non-sensical " + getFullName() + ": Contains ANY and a specific reference: " + set);
     return null;
   }
   if (set.isEmpty()) {
     // okay
     return null;
   }
   return set.toArray(new String[set.size()]);
 }