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

com.avaje.ebeaninternal.server.transaction.BeanPersistIdMap Maven / Gradle / Ivy

There is a newer version: 8.1.1
Show newest version
package com.avaje.ebeaninternal.server.transaction;

import com.avaje.ebeaninternal.server.core.PersistRequest;
import com.avaje.ebeaninternal.server.deploy.BeanDescriptor;

import java.io.Serializable;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.Map;

/**
 * Organises the individual bean persist requests by type.
 */
public final class BeanPersistIdMap {

  private final Map beanMap = new LinkedHashMap();

  public String toString() {
    return beanMap.toString();
  }

  public boolean isEmpty() {
    return beanMap.isEmpty();
  }

  public Collection values() {
    return beanMap.values();
  }

  /**
   * Add a Insert Update or Delete payload.
   */
  public void add(BeanDescriptor desc, PersistRequest.Type type, Object id) {

    BeanPersistIds r = getPersistIds(desc);
    r.addId(type, (Serializable) id);
  }

  private BeanPersistIds getPersistIds(BeanDescriptor desc) {
    String beanType = desc.getFullName();
    BeanPersistIds r = beanMap.get(beanType);
    if (r == null) {
      r = new BeanPersistIds(desc);
      beanMap.put(beanType, r);
    }
    return r;
  }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy