001 002package gudusoft.gsqlparser.dlineage.dataflow.model; 003 004import java.util.ArrayList; 005import java.util.List; 006 007import gudusoft.gsqlparser.ESqlClause; 008import gudusoft.gsqlparser.nodes.TParseTreeNode; 009 010public class TableRelationshipElement implements RelationshipElement<Table> 011{ 012 013 private Table table; 014 015 private ESqlClause relationLocation; 016 017 private List<Transform> transforms = new ArrayList<Transform>(); 018 019 public TableRelationshipElement(Table table ) 020 { 021 this.table = table; 022 } 023 024 public TableRelationshipElement(Table table, 025 ESqlClause relationLocation ) 026 { 027 this.table = table; 028 this.relationLocation = relationLocation; 029 } 030 031 @Override 032 public Table getElement( ) 033 { 034 return table; 035 } 036 037 public ESqlClause getRelationLocation( ) 038 { 039 return relationLocation; 040 } 041 042 @Override 043 public int hashCode( ) 044 { 045 final int prime = 31; 046 int result = 1; 047 result = prime 048 * result 049 + ( ( table == null ) ? 0 : table.hashCode( ) ); 050 result = prime 051 * result 052 + ( ( relationLocation == null ) ? 0 053 : relationLocation.hashCode( ) ); 054 return result; 055 } 056 057 @Override 058 public boolean equals( Object obj ) 059 { 060 if ( this == obj ) 061 return true; 062 if ( obj == null ) 063 return false; 064 if ( getClass( ) != obj.getClass( ) ) 065 return false; 066 TableRelationshipElement other = (TableRelationshipElement) obj; 067 if ( table == null ) 068 { 069 if ( other.table != null ) 070 return false; 071 } 072 else if ( !table.equals( other.table ) ) 073 return false; 074 if ( relationLocation != other.relationLocation ) 075 return false; 076 return true; 077 } 078 079 @Override 080 public List<Transform> getTransforms() { 081 return transforms; 082 } 083 084 public void addTransform(String type, TParseTreeNode code) { 085 if (ModelBindingManager.getGlobalOption()!=null && !ModelBindingManager.getGlobalOption().isTransform()) { 086 return; 087 } 088 Transform transform = new Transform(); 089 transform.setType(type); 090 transform.setCode(code); 091 transforms.add(transform); 092 } 093}