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

io.ebeaninternal.server.dto.DtoBeanDescriptor Maven / Gradle / Ivy

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

import io.ebean.meta.MetricVisitor;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * Manages the query plans for a given DTO bean type.
 */
public final class DtoBeanDescriptor {

  private final Map plans = new ConcurrentHashMap<>();
  private final Class dtoType;
  private final DtoMeta meta;
  private final Map namedQueries;

  DtoBeanDescriptor(Class dtoType, DtoMeta meta, Map namedQueries) {
    this.dtoType = dtoType;
    this.meta = meta;
    this.namedQueries = namedQueries;
  }

  public Class type() {
    return dtoType;
  }

  public DtoQueryPlan queryPlan(Object planKey) {
    return plans.get(planKey);
  }

  public DtoQueryPlan buildPlan(DtoMappingRequest request) {
    return meta.match(request);
  }

  public void putQueryPlan(Object planKey, DtoQueryPlan plan) {
    plans.put(planKey, plan);
  }

  public void visit(MetricVisitor visitor) {
    for (DtoQueryPlan plan : plans.values()) {
      plan.visit(visitor);
    }
  }

  /**
   * Return the named RawSql query.
   */
  public String namedRawSql(String name) {
    return namedQueries.get(name);
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy