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

io.ebeaninternal.server.transaction.BeanPersistIdMap Maven / Gradle / Ivy

There is a newer version: 15.8.0
Show newest version
package io.ebeaninternal.server.transaction;

import io.ebeaninternal.server.core.PersistRequest;
import io.ebeaninternal.server.deploy.BeanDescriptor;

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<>();

  @Override
  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, id);
  }

  private BeanPersistIds getPersistIds(BeanDescriptor desc) {
    String beanType = desc.fullName();
    return beanMap.computeIfAbsent(beanType, k -> new BeanPersistIds(desc));
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy