1 /** 2 * Copyright (c) 2008, http://www.snakeyaml.org 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package org.yaml.snakeyaml.constructor; 17 18 public class MyWheel implements Comparable<MyWheel> { 19 private int id; 20 private String brand; 21 22 public MyWheel() { 23 brand = "Pirelli"; 24 } 25 26 public int getId() { 27 return id; 28 } 29 30 public void setId(int id) { 31 this.id = id; 32 } 33 34 @Override 35 public String toString() { 36 return "Wheel id=" + id; 37 } 38 39 @Override 40 public boolean equals(Object obj) { 41 if (obj instanceof MyWheel) { 42 MyWheel wheel = (MyWheel) obj; 43 return id == wheel.getId(); 44 } else { 45 return false; 46 } 47 } 48 49 @Override 50 public int hashCode() { 51 return new Integer(id).hashCode(); 52 } 53 54 public String getBrand() { 55 return brand; 56 } 57 58 public void setBrand(String brand) { 59 this.brand = brand; 60 } 61 62 public int compareTo(MyWheel arg0) { 63 return new Integer(id).compareTo(new Integer(arg0.id)); 64 } 65 } 66