001/*
002 * This file is part of McIDAS-V
003 *
004 * Copyright 2007-2023
005 * Space Science and Engineering Center (SSEC)
006 * University of Wisconsin - Madison
007 * 1225 W. Dayton Street, Madison, WI 53706, USA
008 * https://www.ssec.wisc.edu/mcidas
009 * 
010 * All Rights Reserved
011 * 
012 * McIDAS-V is built on Unidata's IDV and SSEC's VisAD libraries, and
013 * some McIDAS-V source code is based on IDV and VisAD source code.  
014 * 
015 * McIDAS-V is free software; you can redistribute it and/or modify
016 * it under the terms of the GNU Lesser Public License as published by
017 * the Free Software Foundation; either version 3 of the License, or
018 * (at your option) any later version.
019 * 
020 * McIDAS-V is distributed in the hope that it will be useful,
021 * but WITHOUT ANY WARRANTY; without even the implied warranty of
022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
023 * GNU Lesser Public License for more details.
024 * 
025 * You should have received a copy of the GNU Lesser Public License
026 * along with this program.  If not, see http://www.gnu.org/licenses.
027 */
028
029package edu.wisc.ssec.mcidasv.data.cyclone;
030
031/**
032 * Created by IntelliJ IDEA. User: yuanho Date: Apr 9, 2008 Time: 4:57:38 PM To
033 * change this template use File | Settings | File Templates.
034 */
035
036public class Way implements Comparable {
037
038        /** _more_ */
039        public static final Way OBSERVATION = new Way("Observation");
040
041        /** _more_ */
042        private String id;
043
044        /** _more_ */
045        private String name;
046
047        /**
048         * _more_
049         */
050        public Way() {
051        }
052
053        /**
054         * _more_
055         * 
056         * @param id
057         *            _more_
058         */
059        public Way(String id) {
060                this.id = id;
061        }
062
063        /**
064         * _more_
065         * 
066         * @param id
067         *            _more_
068         * @param name
069         *            _more_
070         */
071        public Way(String id, String name) {
072                this.id = id;
073                this.name = name;
074        }
075
076        /**
077         * _more_
078         * 
079         * @return _more_
080         */
081        public boolean isObservation() {
082                return this.equals(OBSERVATION);
083        }
084
085        /**
086         * _more_
087         * 
088         * @param id
089         *            _more_
090         */
091        public void setId(String id) {
092                this.id = id;
093        }
094
095        /**
096         * _more_
097         * 
098         * @return _more_
099         */
100        public String getId() {
101                return id;
102        }
103
104        /**
105         * _more_
106         * 
107         * @return _more_
108         */
109        public String toString() {
110                if (name != null) {
111                        return id + ": " + name;
112                }
113                return id;
114        }
115
116        /**
117         * _more_
118         * 
119         * @return _more_
120         */
121        public int hashCode() {
122                return id.hashCode();
123        }
124
125        /**
126         * _more_
127         * 
128         * @param o
129         *            _more_
130         * 
131         * @return _more_
132         */
133        public boolean equals(Object o) {
134                if (o == null) {
135                        return false;
136                }
137                if (!(o instanceof Way)) {
138                        return false;
139                }
140                Way other = (Way) o;
141
142                return (this.id.equals(other.id));
143        }
144
145        /**
146         * Set the Name property.
147         * 
148         * @param value
149         *            The new value for Name
150         */
151        public void setName(String value) {
152                name = value;
153        }
154
155        /**
156         * Get the Name property.
157         * 
158         * @return The Name
159         */
160        public String getName() {
161                return name;
162        }
163
164        /**
165         * _more_
166         * 
167         * @param o
168         *            _more_
169         * 
170         * @return _more_
171         */
172        public int compareTo(Object o) {
173                if (o instanceof Way) {
174                        Way that = (Way) o;
175                        return this.id.toLowerCase().compareTo(that.id.toLowerCase());
176                }
177                return toString().compareTo(o.toString());
178        }
179
180}