BehaviourPropertiesUtils.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.pdd.core.behaviour;

  21. import org.openspcoop2.core.config.PortaApplicativaBehaviour;
  22. import org.openspcoop2.core.config.PortaApplicativaServizioApplicativoConnettore;
  23. import org.openspcoop2.core.config.Proprieta;

  24. /**
  25.  * PropertiesUtils
  26.  *
  27.  * @author Andrea Poli (apoli@link.it)
  28.  * @author $Author$
  29.  * @version $Rev$, $Date$
  30.  */
  31. public class BehaviourPropertiesUtils {

  32.     public static void addProprieta(PortaApplicativaBehaviour paBehaviour, String nome, String valore) {
  33.         removeProprieta(paBehaviour, nome);
  34.         paBehaviour.addProprieta(newP(nome, valore));
  35.     }
  36.    
  37.     public static void addProprieta(PortaApplicativaServizioApplicativoConnettore pasaConnnettore, String nome, String valore) {
  38.         removeProprieta(pasaConnnettore, nome);
  39.         pasaConnnettore.addProprieta(newP(nome, valore));
  40.     }
  41.    
  42.     private static Proprieta newP(String nome, String valore) {
  43.         Proprieta p = new Proprieta();
  44.         p.setNome(nome);
  45.         p.setValore(valore);
  46.         return p;
  47.     }
  48.    
  49.     public static void removeProprieta(PortaApplicativaBehaviour paBehaviour, String nome) {
  50.         if(paBehaviour.sizeProprietaList()>0) {
  51.             int index =0;
  52.             for (Proprieta p : paBehaviour.getProprietaList()) {
  53.                 if(p.getNome().equals(nome)) {
  54.                     paBehaviour.removeProprieta(index);
  55.                     break;
  56.                 }
  57.                 index++;
  58.             }
  59.         }
  60.     }
  61.     public static void removeProprieta(PortaApplicativaServizioApplicativoConnettore pasaConnnettore, String nome) {
  62.         if(pasaConnnettore.sizeProprietaList()>0) {
  63.             int index =0;
  64.             for (Proprieta p : pasaConnnettore.getProprietaList()) {
  65.                 if(p.getNome().equals(nome)) {
  66.                     pasaConnnettore.removeProprieta(index);
  67.                     break;
  68.                 }
  69.                 index++;
  70.             }
  71.         }
  72.     }
  73. }