コード例 #1
0
 private void validateForPrioritize(S s) {
   if (s.strict()) {
     throw new IllegalArgumentException(s.name() + ": not prioritizable: is strict");
   }
   if (!this.range.contains(s)) {
     throw new IllegalArgumentException(s.name() + ": not contained or is backup");
   }
 }
コード例 #2
0
 private boolean containsName(List<S> source, String strategyName) {
   for (S s : source) {
     if (s.name().equals(strategyName)) {
       return true;
     }
   }
   return false;
 }
コード例 #3
0
 /**
  * Returns <code>true</code> if the given strategy is contained within this instance, <code>
  * false</code> otherwise.
  *
  * @param s to search
  * @return true if strategy has been found, false otherwise
  */
 public boolean contains(S s) {
   // if s is strict then search in strict:
   if (s.strict() && this.strict.containsKey(s.target())) {
     return true;
   }
   // else search in range:
   if (this.containsName(this.range, s.name())) {
     return true;
   }
   // search for it in backup, if any:
   if (this.backup != null) {
     if (this.containsName(this.backup, s.name())) {
       return true;
     }
   }
   return false;
 }
コード例 #4
0
 /**
  * Removes the given strategy and returns true if it was found and removed. If <code>s</code> is
  * strict then it will be searched by target, else it will be searched by name.
  *
  * @param s to remove
  * @return true if strategy has been removed, false otherwise
  */
 public boolean remove(S s) {
   if (s.strict()) {
     return this.strict.remove(s.target()) != null;
   } else {
     final ListIterator<S> it = this.range.listIterator();
     while (it.hasNext()) {
       if (it.next().name().equals(s.name())) {
         it.remove();
         return true;
       }
     }
     return false;
   }
 }
コード例 #5
0
ファイル: Transaction.java プロジェクト: osarrat/sigmah
 public ObjectStore getObjectStore(S store) {
   return getObjectStore(store.name());
 }