AliasTableComplexField.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.generic_project.beans;

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

  29.     private String aliasTable;
  30.     private ComplexField complexField;
  31.    
  32.     @Override
  33.     public String getAliasTable() {
  34.         return this.aliasTable;
  35.     }
  36.     @Override
  37.     public IField getField(){
  38.         return this.complexField;
  39.     }

  40.     public AliasTableComplexField(ComplexField iField, String aliasTable){
  41.         super(iField.getFather(), iField.getFieldName(), iField.getFieldType(), iField.getClassName(), iField.getClassType());
  42.         this.aliasTable = aliasTable;
  43.         this.complexField = iField;
  44.     }
  45.    
  46.     // Ridefinisco l'equals, altrimenti nei Converter, gli if che precendono la chiamata al metodo AbstractSQLFieldConverter.toColumn o toTable
  47.     // vengono soddisfatti, e quindi non viene usato l'alias
  48.     @Override
  49.     public boolean equals(Object o){
  50.         boolean superEquals = super.equals(o);
  51.         if(superEquals){
  52.             if(o instanceof AliasTableComplexField){
  53.                 AliasTableComplexField af = (AliasTableComplexField) o;
  54.                 return af.getAliasTable().equals(this.aliasTable);
  55.             }
  56.             else{
  57.                 return false;
  58.             }
  59.         }
  60.         else{
  61.             return false;
  62.         }
  63.     }
  64.    
  65.     @Override
  66.     public int hashCode() {
  67.         return super.hashCode();
  68.     }
  69.    
  70.     @Override
  71.     public String toString(){
  72.         return toString(0);
  73.     }
  74.     @Override
  75.     public String toString(int indent){
  76.        
  77.         StringBuilder indentBuffer = new StringBuilder();
  78.         for (int i = 0; i < indent; i++) {
  79.             indentBuffer.append("   ");
  80.         }
  81.        
  82.         StringBuilder bf = new StringBuilder(this.complexField.toString(indent));
  83.        
  84.         bf.append(indentBuffer.toString());
  85.         bf.append("- aliasTable(Complex): "+this.aliasTable);
  86.         bf.append("\n");
  87.                
  88.         return bf.toString();
  89.     }
  90. }