1 19 package org.apache.mina.example.haiku; 20 21 import java.util.Arrays ; 22 23 27 public class Haiku { 28 private final String [] phrases; 29 30 public Haiku(String ... lines) { 31 this.phrases = lines; 32 if (null == lines || lines.length != 3) { 33 throw new IllegalArgumentException ("Must pass in 3 phrases of text"); 34 } 35 } 36 37 public String [] getPhrases() { 38 return phrases; 39 } 40 41 @Override 42 public boolean equals(Object o) { 43 if (this == o) 44 return true; 45 if (o == null || getClass() != o.getClass()) 46 return false; 47 48 Haiku haiku = (Haiku) o; 49 50 return Arrays.equals(phrases, haiku.phrases); 51 } 52 53 @Override 54 public int hashCode() { 55 return Arrays.hashCode(phrases); 56 } 57 58 @Override 59 public String toString() { 60 return Arrays.toString(phrases); 61 } 62 } 63 | Popular Tags |