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.
15050c422c295a0ff956f79ba91c4c5a21b255f721Andrey Somov */
16050c422c295a0ff956f79ba91c4c5a21b255f721Andrey Somovpackage org.yaml.snakeyaml.immutable;
17050c422c295a0ff956f79ba91c4c5a21b255f721Andrey Somov
18050c422c295a0ff956f79ba91c4c5a21b255f721Andrey Somov/**
19050c422c295a0ff956f79ba91c4c5a21b255f721Andrey Somov * No constructors with 1 argument. These immutable objects are not supported.
20050c422c295a0ff956f79ba91c4c5a21b255f721Andrey Somov */
21050c422c295a0ff956f79ba91c4c5a21b255f721Andrey Somovpublic class Code3 {
22050c422c295a0ff956f79ba91c4c5a21b255f721Andrey Somov    private final String name;
23050c422c295a0ff956f79ba91c4c5a21b255f721Andrey Somov    private final Integer code;
24050c422c295a0ff956f79ba91c4c5a21b255f721Andrey Somov
25050c422c295a0ff956f79ba91c4c5a21b255f721Andrey Somov    public Code3(String name, Integer code) {
26050c422c295a0ff956f79ba91c4c5a21b255f721Andrey Somov        this.code = code;
27050c422c295a0ff956f79ba91c4c5a21b255f721Andrey Somov        this.name = name;
28050c422c295a0ff956f79ba91c4c5a21b255f721Andrey Somov    }
29050c422c295a0ff956f79ba91c4c5a21b255f721Andrey Somov
30050c422c295a0ff956f79ba91c4c5a21b255f721Andrey Somov    public String getData() {
31050c422c295a0ff956f79ba91c4c5a21b255f721Andrey Somov        return name + code;
32050c422c295a0ff956f79ba91c4c5a21b255f721Andrey Somov    }
33050c422c295a0ff956f79ba91c4c5a21b255f721Andrey Somov
34050c422c295a0ff956f79ba91c4c5a21b255f721Andrey Somov    @Override
35050c422c295a0ff956f79ba91c4c5a21b255f721Andrey Somov    public boolean equals(Object obj) {
36050c422c295a0ff956f79ba91c4c5a21b255f721Andrey Somov        if (obj instanceof Code3) {
37050c422c295a0ff956f79ba91c4c5a21b255f721Andrey Somov            Code3 code = (Code3) obj;
38050c422c295a0ff956f79ba91c4c5a21b255f721Andrey Somov            return code.equals(code.code);
39050c422c295a0ff956f79ba91c4c5a21b255f721Andrey Somov        } else {
40050c422c295a0ff956f79ba91c4c5a21b255f721Andrey Somov            return false;
41050c422c295a0ff956f79ba91c4c5a21b255f721Andrey Somov        }
42050c422c295a0ff956f79ba91c4c5a21b255f721Andrey Somov    }
43050c422c295a0ff956f79ba91c4c5a21b255f721Andrey Somov
44050c422c295a0ff956f79ba91c4c5a21b255f721Andrey Somov    @Override
45050c422c295a0ff956f79ba91c4c5a21b255f721Andrey Somov    public int hashCode() {
46050c422c295a0ff956f79ba91c4c5a21b255f721Andrey Somov        return code.hashCode();
47050c422c295a0ff956f79ba91c4c5a21b255f721Andrey Somov    }
48050c422c295a0ff956f79ba91c4c5a21b255f721Andrey Somov
49050c422c295a0ff956f79ba91c4c5a21b255f721Andrey Somov    @Override
50050c422c295a0ff956f79ba91c4c5a21b255f721Andrey Somov    public String toString() {
51050c422c295a0ff956f79ba91c4c5a21b255f721Andrey Somov        return "<Code3 data=" + getData() + ">";
52050c422c295a0ff956f79ba91c4c5a21b255f721Andrey Somov    }
53050c422c295a0ff956f79ba91c4c5a21b255f721Andrey Somov}
54