001package gudusoft.gsqlparser.dlineage.dataflow.model.xml;
002
003import javax.xml.bind.annotation.XmlAttribute;
004import javax.xml.bind.annotation.XmlElement;
005import javax.xml.bind.annotation.XmlType;
006
007import gudusoft.gsqlparser.util.SQLUtil;
008
009import gudusoft.gsqlparser.dlineage.dataflow.model.ModelBindingManager;
010
011@XmlType(propOrder = { "type", "coordinate", "code"})
012public class transform implements Cloneable{
013
014        private String type;
015
016        private String code;
017        
018        private String coordinate;
019
020        public transform() {
021        }
022
023        @XmlAttribute(required = false)
024        public String getType() {
025                return this.type;
026        }
027
028        public void setType(String type) {
029                this.type = type;
030        }
031
032        @XmlElement(required = false)
033        public String getCode() {
034                return this.code;
035        }
036
037        public void setCode(String code) {
038                this.code = code;
039        }
040        
041        @XmlAttribute(required = false)
042        public String getCoordinate() {
043                if (ModelBindingManager.getGlobalOption()==null || !ModelBindingManager.getGlobalOption().isTransformCoordinate()) {
044                        return null;
045                }
046                return coordinate;
047        }
048        
049        public String getCoordinate(boolean showCoordinate) {
050                if (!showCoordinate) {
051                        return null;
052                }
053                return coordinate;
054        }
055
056        public void setCoordinate(String coordinate) {
057                if (ModelBindingManager.getGlobalOption()==null || !ModelBindingManager.getGlobalOption().isTransformCoordinate()) {
058                        return;
059                }
060                this.coordinate = coordinate;
061        }
062
063        @Override
064        public int hashCode() {
065                final int prime = 31;
066                int result = 1;
067                result = prime * result + ((code == null) ? 0 : code.hashCode());
068                result = prime * result + ((coordinate == null) ? 0 : coordinate.hashCode());
069                result = prime * result + ((type == null) ? 0 : type.hashCode());
070                return result;
071        }
072
073        @Override
074        public boolean equals(Object obj) {
075                if (this == obj)
076                        return true;
077                if (obj == null)
078                        return false;
079                if (getClass() != obj.getClass())
080                        return false;
081                transform other = (transform) obj;
082                if (code == null) {
083                        if (other.code != null)
084                                return false;
085                } else if (!code.equals(other.code))
086                        return false;
087                if (coordinate == null) {
088                        if (other.coordinate != null)
089                                return false;
090                } else if (!coordinate.equals(other.coordinate))
091                        return false;
092                if (type == null) {
093                        if (other.type != null)
094                                return false;
095                } else if (!type.equals(other.type))
096                        return false;
097                return true;
098        }
099        
100        @Override
101        public String toString() {
102                return code;
103        }
104
105        public String toDedupKey() {
106                StringBuilder sb = new StringBuilder(64);
107                appendDedupKey(sb);
108                return sb.toString();
109        }
110
111        public long toDedupHash() {
112                StringBuilder sb = new StringBuilder(64);
113                appendDedupKey(sb);
114                return SQLUtil.hash64(sb);
115        }
116
117        void appendDedupKey(StringBuilder sb) {
118                if (type != null) { sb.append("type=").append(type).append('|'); }
119                if (coordinate != null) { sb.append("coordinate=").append(coordinate).append('|'); }
120                if (code != null) { sb.append("code=").append(code).append('|'); }
121        }
122}