Пример #1
0
 /**
  * Returns the object associated with the reference, defaulting it to the parent if the reference
  * is unset, and the parent is of the correct archetype.
  *
  * @param reference the reference
  * @param parent the parent object
  * @param archetypeRange the archetypes that the reference may refer to
  * @param cache the cache
  * @return the object, or {@code null} if the reference is set but refers to an invalid object
  */
 private IMObject getObject(
     IMObjectReference reference, IMObject parent, String[] archetypeRange, IMObjectCache cache) {
   IMObject result = null;
   if (reference == null) {
     if (TypeHelper.isA(parent, archetypeRange)) {
       result = parent;
     }
   } else if (reference.equals(parent.getObjectReference())) {
     result = parent;
   } else {
     result = cache.get(reference);
   }
   return result;
 }
 /** Clears the cache. */
 public void clear() {
   cache.clear();
 }
 /**
  * Retrieves an object given its reference.
  *
  * @param reference the object reference
  * @return the corresponding object, or {@code null} if none is found
  * @throws ArchetypeServiceException if the query fails
  */
 @Override
 public IMObject get(IMObjectReference reference) {
   return cache.get(reference);
 }