All Downloads are FREE. Search and download functionalities are using the official Maven repository.

co.easimart.KnownEasimartObjectDecoder Maven / Gradle / Ivy

package co.easimart;

import java.util.Map;

/**
 * A subclass of EasimartDecoder which can keep EasimartObject that
 * has been fetched instead of creating a new instance.
 */
/** package */ class KnownEasimartObjectDecoder extends EasimartDecoder {
  private Map fetchedObjects;

  public KnownEasimartObjectDecoder(Map fetchedObjects) {
    super();
    this.fetchedObjects = fetchedObjects;
  }

  /**
   * If the object has been fetched, the fetched object will be returned. Otherwise a
   * new created object will be returned.
   */
  @Override
  protected EasimartObject decodePointer(String className, String objectId) {
    if (fetchedObjects != null && fetchedObjects.containsKey(objectId)) {
      return fetchedObjects.get(objectId);
    }
    return super.decodePointer(className, objectId); 
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy