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

com.google.cloud.spanner.hibernate.hints.ScanMethodHint Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2019-2024 Google LLC
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
 */

package com.google.cloud.spanner.hibernate.hints;

import static com.google.cloud.spanner.hibernate.hints.Hints.fromTableHint;
import static com.google.cloud.spanner.hibernate.hints.Hints.joinTableHint;

import com.google.cloud.spanner.hibernate.hints.Hints.ScanMethod;
import com.google.common.collect.ImmutableList;

class ScanMethodHint extends ReplaceQueryPartsHint {

  private static final String HINT = "SCAN_METHOD";

  static ScanMethodHint from(String table, ScanMethod scanMethod, ReplaceMode replaceMode) {
    return new ScanMethodHint(
        ImmutableList.of(
            new Replacement(Hints.from(table), scanMethodFrom(table, scanMethod), replaceMode)));
  }

  static ScanMethodHint join(String table, ScanMethod scanMethod, ReplaceMode replaceMode) {
    return new ScanMethodHint(
        ImmutableList.of(
            new Replacement(Hints.join(table), scanMethodJoin(table, scanMethod), replaceMode)));
  }

  private ScanMethodHint(ImmutableList replacements) {
    super(replacements);
  }

  private static String scanMethodFrom(String table, ScanMethod scanMethod) {
    return fromTableHint(table, HINT, scanMethod.name());
  }

  private static String scanMethodJoin(String table, ScanMethod scanMethod) {
    return joinTableHint(table, HINT, scanMethod.name());
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy