Exemplo n.º 1
0
 /**
  * Returns a non-null copy of the Set of objects the character qualifies for in this
  * AbstractQualifiedListFacet for the Player Character represented by the given CharID and the
  * given source. This method returns an empty set if the Player Character identified by the given
  * CharID qualifies for none of the objects in this AbstractQualifiedListFacet granted by the
  * given source.
  *
  * <p>This method is value-semantic in that ownership of the returned List is transferred to the
  * class calling this method. Modification of the returned List will not modify this
  * AbstractQualifiedListFacet and modification of this AbstractQualifiedListFacet will not modify
  * the returned List. Modifications to the returned List will also not modify any future or
  * previous objects returned by this (or other) methods on AbstractQualifiedListFacet. If you wish
  * to modify the information stored in this AbstractQualifiedListFacet, you must use the add*()
  * and remove*() methods of AbstractQualifiedListFacet.
  *
  * <p>Generally, use of this method is discouraged in general operational aspects. However, it is
  * recognized that certain output tokens can list certain items by source, and thus this method is
  * required, and it is unreasonable to expect complete elimination of this method or entirely
  * prohibit future use of this method.
  *
  * @param id The CharID representing the Player Character for which the items in this
  *     AbstractQualifiedListFacet should be returned.
  * @param source The source object for which a copy of the List of objects the Player Character
  *     qualifies for should be returned.
  * @return A non-null Set of objects the Player Character represented by the given CharID
  *     qualifies for in this AbstractQualifiedListFacet
  */
 public Collection<T> getQualifiedSet(CharID id, Object source) {
   Set<T> set = new WrappedMapSet<T>(IdentityHashMap.class);
   Map<T, Set<Object>> componentMap = getCachedMap(id);
   if (componentMap != null) {
     for (Map.Entry<T, Set<Object>> me : componentMap.entrySet()) {
       T obj = me.getKey();
       Set<Object> sources = me.getValue();
       if (sources.contains(source)) {
         if (prereqFacet.qualifies(id, obj, source)) {
           set.add(obj);
         }
       }
     }
   }
   return set;
 }
Exemplo n.º 2
0
 /**
  * Acts on the Set of objects the character qualifies for in this AbstractQualifiedListFacet for
  * the Player Character represented by the given CharID. The results of each action as provided by
  * the given QualifiedActor are returned in a non-null List.
  *
  * <p>This method returns an empty List if the Player Character identified by the given CharID
  * qualifies for none of the objects in this AbstractQualifiedListFacet.
  *
  * <p>This method is value-semantic in that ownership of the returned List is transferred to the
  * class calling this method. Modification of the returned List will not modify this
  * AbstractQualifiedListFacet and modification of this AbstractQualifiedListFacet will not modify
  * the returned List. Modifications to the returned List will also not modify any future or
  * previous objects returned by this (or other) methods on AbstractQualifiedListFacet. If you wish
  * to modify the information stored in this AbstractQualifiedListFacet, you must use the add*()
  * and remove*() methods of AbstractQualifiedListFacet.
  *
  * <p>Note: If a particular item has been granted by more than one source, then the QualifiedActor
  * will only be called for the first source that (successfully grants) the underlying object.
  *
  * @param id The CharID representing the Player Character for which the items in this
  *     AbstractQualifiedListFacet should be returned.
  * @param qa The QualifiedActor which will act on each of the items in this
  *     AbstractQualifiedListFacet for which the Player Character qualifies.
  * @return A non-null List of objects created by the QualifiedActor from each of the objects in
  *     this AbstractQualifiedListFacet for which the Player Character qualifies.
  */
 public <R> List<R> actOnQualifiedSet(CharID id, QualifiedActor<T, R> qa) {
   List<R> list = new ArrayList<R>();
   Map<T, Set<Object>> componentMap = getCachedMap(id);
   if (componentMap != null) {
     for (Map.Entry<T, Set<Object>> me : componentMap.entrySet()) {
       T obj = me.getKey();
       Set<Object> sources = me.getValue();
       for (Object source : sources) {
         if (prereqFacet.qualifies(id, obj, source)) {
           list.add(qa.act(obj, source));
         }
       }
     }
   }
   return list;
 }
Exemplo n.º 3
0
 /**
  * Returns a non-null copy of the Set of objects the character qualifies for in this
  * AbstractQualifiedListFacet for the Player Character represented by the given CharID. This
  * method returns an empty set if the Player Character identified by the given CharID qualifies
  * for none of the objects in this AbstractQualifiedListFacet.
  *
  * <p>This method is value-semantic in that ownership of the returned Collection is transferred to
  * the class calling this method. Modification of the returned Collection will not modify this
  * AbstractQualifiedListFacet and modification of this AbstractQualifiedListFacet will not modify
  * the returned Collection. Modifications to the returned Collection will also not modify any
  * future or previous objects returned by this (or other) methods on AbstractQualifiedListFacet.
  * If you wish to modify the information stored in this AbstractQualifiedListFacet, you must use
  * the add*() and remove*() methods of AbstractQualifiedListFacet.
  *
  * @param id The CharID representing the Player Character for which the items in this
  *     AbstractQualifiedListFacet should be returned.
  * @return A non-null Set of objects the Player Character represented by the given CharID
  *     qualifies for in this AbstractQualifiedListFacet
  */
 public Collection<T> getQualifiedSet(CharID id) {
   Set<T> set = new HashSet<T>();
   Map<T, Set<Object>> componentMap = getCachedMap(id);
   if (componentMap != null) {
     for (Map.Entry<T, Set<Object>> me : componentMap.entrySet()) {
       T obj = me.getKey();
       Set<Object> sources = me.getValue();
       for (Object source : sources) {
         if (prereqFacet.qualifies(id, obj, source)) {
           set.add(obj);
           break;
         }
       }
     }
   }
   return set;
 }