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

io.ebeaninternal.server.querydefn.OrmQueryPropertiesParser Maven / Gradle / Ivy

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

import io.ebeaninternal.server.util.DSelectColumnsParser;

import java.util.Set;

/**
 * Parses the path properties string.
 */
final class OrmQueryPropertiesParser {

  private static final Response EMPTY = new Response(false, null);
  private static final Response ALL = new Response(true, null);

  /**
   * Immutable response of the parsed properties and options.
   */
  static class Response {

    final boolean allProperties;
    final Set included;

    private Response(boolean allProperties, Set included) {
      this.allProperties = allProperties;
      this.included = included;
    }
  }

  /**
   * Parses the path properties string returning the parsed properties and options.
   * In general it is comma delimited with some special strings like +lazy(20).
   */
  static Response parse(String rawProperties) {
    if (rawProperties == null || rawProperties.isEmpty()) {
      return EMPTY;
    }
    if (rawProperties.equals("*")) {
      return ALL;
    }
    final Set included = splitRawSelect(rawProperties);
    if (included.contains("*")) {
      return ALL;
    }
    return new Response(false, included);
  }

  /**
   * Split allowing 'dynamic function based properties'.
   */
  private static Set splitRawSelect(String inputProperties) {
    return DSelectColumnsParser.parse(inputProperties);
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy