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 ConstantRelationshipElement implements RelationshipElement<TableColumn>
011{
012
013        private TableColumn constant;
014
015        private ESqlClause relationLocation;
016
017        private List<Transform> transforms = new ArrayList<Transform>();
018        
019        public ConstantRelationshipElement(TableColumn constant )
020        {
021                this.constant = constant;
022        }
023
024        public ConstantRelationshipElement(TableColumn constant,
025                                                                           ESqlClause relationLocation )
026        {
027                this.constant = constant;
028                this.relationLocation = relationLocation;
029        }
030
031        @Override
032        public TableColumn getElement( )
033        {
034                return constant;
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                                + ( ( constant == null ) ? 0 : constant.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                ConstantRelationshipElement other = (ConstantRelationshipElement) obj;
067                if ( constant == null )
068                {
069                        if ( other.constant != null )
070                                return false;
071                }
072                else if ( !constant.equals( other.constant ) )
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                Transform transform = new Transform();
086                transform.setType(type);
087                transform.setCode(code);
088                transforms.add(transform);
089        }
090
091}