1 21 package com.db4o.test.collections; 22 23 24 public class ComparableContent implements Comparable { 25 26 public String _name; 27 28 public ComparableContent _child; 29 30 public ComparableContent(){ 31 32 } 33 34 public ComparableContent(String name){ 35 _name = name; 36 _child = new ComparableContent(); 37 } 38 39 public int compareTo(Object o) { 40 if(_name == null){ 41 throw new NullPointerException (); 42 } 43 if(_child == null){ 44 throw new NullPointerException (); 45 } 46 ComparableContent other = (ComparableContent) o; 47 if(other._child == null){ 48 throw new NullPointerException (); 49 } 50 return other._name.compareTo(_name); 51 } 52 53 public boolean equals(Object obj) { 54 ComparableContent other = (ComparableContent) obj; 55 return other._name.equals(_name); 56 } 57 58 } 59 | Popular Tags |