11adf3a94fce500e0bda933e4b495a004d5789bd7Andrey Somov/**
211a89b445f3bde56bf07e6a0d04f0b0256dcb215Andrey Somov * Copyright (c) 2008, http://www.snakeyaml.org
31adf3a94fce500e0bda933e4b495a004d5789bd7Andrey Somov *
41adf3a94fce500e0bda933e4b495a004d5789bd7Andrey Somov * Licensed under the Apache License, Version 2.0 (the "License");
51adf3a94fce500e0bda933e4b495a004d5789bd7Andrey Somov * you may not use this file except in compliance with the License.
61adf3a94fce500e0bda933e4b495a004d5789bd7Andrey Somov * You may obtain a copy of the License at
71adf3a94fce500e0bda933e4b495a004d5789bd7Andrey Somov *
81adf3a94fce500e0bda933e4b495a004d5789bd7Andrey Somov *     http://www.apache.org/licenses/LICENSE-2.0
91adf3a94fce500e0bda933e4b495a004d5789bd7Andrey Somov *
101adf3a94fce500e0bda933e4b495a004d5789bd7Andrey Somov * Unless required by applicable law or agreed to in writing, software
111adf3a94fce500e0bda933e4b495a004d5789bd7Andrey Somov * distributed under the License is distributed on an "AS IS" BASIS,
121adf3a94fce500e0bda933e4b495a004d5789bd7Andrey Somov * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
131adf3a94fce500e0bda933e4b495a004d5789bd7Andrey Somov * See the License for the specific language governing permissions and
141adf3a94fce500e0bda933e4b495a004d5789bd7Andrey Somov * limitations under the License.
15ca2b4b3ee7101957d97334631216f6b52b030c1bAndrey Somov */
16ca2b4b3ee7101957d97334631216f6b52b030c1bAndrey Somovpackage org.yaml.snakeyaml.immutable;
17ca2b4b3ee7101957d97334631216f6b52b030c1bAndrey Somov
18ca2b4b3ee7101957d97334631216f6b52b030c1bAndrey Somovpublic class Color {
19ca2b4b3ee7101957d97334631216f6b52b030c1bAndrey Somov    private final String name;
20ca2b4b3ee7101957d97334631216f6b52b030c1bAndrey Somov
21ca2b4b3ee7101957d97334631216f6b52b030c1bAndrey Somov    public Color(String name) {
22ca2b4b3ee7101957d97334631216f6b52b030c1bAndrey Somov        this.name = name;
23ca2b4b3ee7101957d97334631216f6b52b030c1bAndrey Somov    }
24ca2b4b3ee7101957d97334631216f6b52b030c1bAndrey Somov
25ca2b4b3ee7101957d97334631216f6b52b030c1bAndrey Somov    public String getName() {
26ca2b4b3ee7101957d97334631216f6b52b030c1bAndrey Somov        return name;
27ca2b4b3ee7101957d97334631216f6b52b030c1bAndrey Somov    }
28ca2b4b3ee7101957d97334631216f6b52b030c1bAndrey Somov
29ca2b4b3ee7101957d97334631216f6b52b030c1bAndrey Somov    @Override
30ca2b4b3ee7101957d97334631216f6b52b030c1bAndrey Somov    public boolean equals(Object obj) {
31ca2b4b3ee7101957d97334631216f6b52b030c1bAndrey Somov        if (obj instanceof Color) {
32ca2b4b3ee7101957d97334631216f6b52b030c1bAndrey Somov            Color color = (Color) obj;
33ca2b4b3ee7101957d97334631216f6b52b030c1bAndrey Somov            return name.equals(color.name);
34ca2b4b3ee7101957d97334631216f6b52b030c1bAndrey Somov        } else {
35ca2b4b3ee7101957d97334631216f6b52b030c1bAndrey Somov            return false;
36ca2b4b3ee7101957d97334631216f6b52b030c1bAndrey Somov        }
37ca2b4b3ee7101957d97334631216f6b52b030c1bAndrey Somov    }
38ca2b4b3ee7101957d97334631216f6b52b030c1bAndrey Somov
39ca2b4b3ee7101957d97334631216f6b52b030c1bAndrey Somov    @Override
40ca2b4b3ee7101957d97334631216f6b52b030c1bAndrey Somov    public int hashCode() {
41ca2b4b3ee7101957d97334631216f6b52b030c1bAndrey Somov        return name.hashCode();
42ca2b4b3ee7101957d97334631216f6b52b030c1bAndrey Somov    }
43ca2b4b3ee7101957d97334631216f6b52b030c1bAndrey Somov
44ca2b4b3ee7101957d97334631216f6b52b030c1bAndrey Somov    @Override
45ca2b4b3ee7101957d97334631216f6b52b030c1bAndrey Somov    public String toString() {
46050c422c295a0ff956f79ba91c4c5a21b255f721Andrey Somov        return "<Color id=" + name + ">";
47ca2b4b3ee7101957d97334631216f6b52b030c1bAndrey Somov    }
48ca2b4b3ee7101957d97334631216f6b52b030c1bAndrey Somov}
49