LikeConfig.java

  1. /*
  2.  * GovWay - A customizable API Gateway
  3.  * https://govway.org
  4.  *
  5.  * Copyright (c) 2005-2025 Link.it srl (https://link.it).
  6.  *
  7.  * This program is free software: you can redistribute it and/or modify
  8.  * it under the terms of the GNU General Public License version 3, as published by
  9.  * the Free Software Foundation.
  10.  *
  11.  * This program is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18.  *
  19.  */

  20. package org.openspcoop2.utils.sql;

  21. /**
  22.  * LikeConfig
  23.  *
  24.  * @author Poli Andrea (apoli@link.it)
  25.  * @author $Author$
  26.  * @version $Rev$, $Date$
  27.  */
  28. public class LikeConfig {

  29.     public static LikeConfig contains(boolean caseInsensitive) {
  30.         return contains(true, caseInsensitive);
  31.     }
  32.     public static LikeConfig contains(boolean escape, boolean caseInsensitive) {
  33.         LikeConfig config = new LikeConfig();
  34.         config.setEscape(escape);
  35.         config.setCaseInsensitive(caseInsensitive);
  36.         config.setContains(true);
  37.         return config;
  38.     }
  39.    
  40.     public static LikeConfig startsWith(boolean caseInsensitive) {
  41.         return startsWith(true, caseInsensitive);
  42.     }
  43.     public static LikeConfig startsWith(boolean escape, boolean caseInsensitive) {
  44.         LikeConfig config = new LikeConfig();
  45.         config.setEscape(escape);
  46.         config.setCaseInsensitive(caseInsensitive);
  47.         config.setStartsWith(true);
  48.         return config;
  49.     }
  50.    
  51.     public static LikeConfig endsWith(boolean caseInsensitive) {
  52.         return endsWith(true, caseInsensitive);
  53.     }
  54.     public static LikeConfig endsWith(boolean escape, boolean caseInsensitive) {
  55.         LikeConfig config = new LikeConfig();
  56.         config.setEscape(escape);
  57.         config.setCaseInsensitive(caseInsensitive);
  58.         config.setEndsWith(true);
  59.         return config;
  60.     }
  61.    
  62.     private boolean escape = true;
  63.    
  64.     private boolean contains = false;
  65.     private boolean startsWith = false;
  66.     private boolean endsWith = false;
  67.    
  68.     private boolean caseInsensitive = false;
  69.    
  70.     public boolean isEscape() {
  71.         return this.escape;
  72.     }

  73.     public void setEscape(boolean escape) {
  74.         this.escape = escape;
  75.     }

  76.     public boolean isContains() {
  77.         return this.contains;
  78.     }

  79.     public void setContains(boolean contains) {
  80.         this.contains = contains;
  81.     }

  82.     public boolean isStartsWith() {
  83.         return this.startsWith;
  84.     }

  85.     public void setStartsWith(boolean startsWith) {
  86.         this.startsWith = startsWith;
  87.     }

  88.     public boolean isEndsWith() {
  89.         return this.endsWith;
  90.     }

  91.     public void setEndsWith(boolean endsWith) {
  92.         this.endsWith = endsWith;
  93.     }

  94.     public boolean isCaseInsensitive() {
  95.         return this.caseInsensitive;
  96.     }

  97.     public void setCaseInsensitive(boolean caseInsensitive) {
  98.         this.caseInsensitive = caseInsensitive;
  99.     }
  100. }