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

com.avaje.ebeaninternal.server.deploy.BeanCollectionHelpFactory Maven / Gradle / Ivy

There is a newer version: 9.5.1
Show newest version
package com.avaje.ebeaninternal.server.deploy;

import com.avaje.ebeaninternal.api.SpiQuery;
import com.avaje.ebeaninternal.server.core.OrmQueryRequest;


/**
 * Creates Helpers specific to the type of the property (List Set or Map).
 */
public class BeanCollectionHelpFactory {

  static final BeanListHelp LIST_HELP = new BeanListHelp();

  static final BeanSetHelp SET_HELP = new BeanSetHelp();

  /**
   * Create the helper based on the many property.
   */
  public static  BeanCollectionHelp create(BeanPropertyAssocMany manyProperty) {

    ManyType manyType = manyProperty.getManyType();
    switch (manyType) {
      case LIST:
        return new BeanListHelp(manyProperty);
      case SET:
        return new BeanSetHelp(manyProperty);
      case MAP:
        return new BeanMapHelp(manyProperty);
      default:
        throw new RuntimeException("Invalid type " + manyType);
    }

  }

  @SuppressWarnings("unchecked")
  public static  BeanCollectionHelp create(OrmQueryRequest request) {

    SpiQuery.Type manyType = request.getQuery().getType();

    if (manyType.equals(SpiQuery.Type.LIST)) {
      return LIST_HELP;

    } else if (manyType.equals(SpiQuery.Type.SET)) {
      return SET_HELP;

    } else {
      BeanDescriptor target = request.getBeanDescriptor();
      String mapKey = request.getQuery().getMapKey();
      return new BeanMapHelp(target, mapKey);
    }
  }


}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy