FunctionContextsCustom.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.protocol.sdk.state;

  21. import java.util.ArrayList;
  22. import java.util.List;

  23. import org.openspcoop2.protocol.sdk.constants.IDService;

  24. /**
  25.  * URL Protocol Context
  26.  *
  27.  * @author Poli Andrea (apoli@link.it)
  28.  * @author $Author$
  29.  * @version $Rev$, $Date$
  30.  */


  31. public class FunctionContextsCustom implements java.io.Serializable {

  32.     /**
  33.      *
  34.      */
  35.     private static final long serialVersionUID = 1L;
  36.    
  37.     private List<FunctionContextCustom> contexts = new ArrayList<FunctionContextCustom>();  
  38.     public List<FunctionContextCustom> getContexts() {
  39.         return this.contexts;
  40.     }
  41.    
  42.     public boolean isMatch(String contextParam,String subContextParam) {
  43.         for (int i = 0; i < this.contexts.size(); i++) {
  44.             boolean match = this.contexts.get(i).isMatch(contextParam, subContextParam);
  45.             if(match) {
  46.                 return true;
  47.             }
  48.         }
  49.         return false;
  50.     }
  51.    
  52.     public IDService getServiceMatch(String contextParam,String subContextParam) {
  53.         for (int i = 0; i < this.contexts.size(); i++) {
  54.             IDService idService = this.contexts.get(i).getServiceMatch(contextParam, subContextParam);
  55.             if(idService!=null) {
  56.                 return idService;
  57.             }
  58.         }
  59.         return null;
  60.     }
  61.    
  62.     public String getFunctionMatch(String contextParam,String subContextParam) {
  63.         for (int i = 0; i < this.contexts.size(); i++) {
  64.             String function = this.contexts.get(i).getFunctionMatch(contextParam, subContextParam);
  65.             if(function!=null) {
  66.                 return function;
  67.             }
  68.         }
  69.         return null;
  70.     }
  71.    
  72. }