/farmR/src/java/src/jfm/model/CropYear.java

https://code.google.com/p/javawfm/ · Java · 37 lines · 26 code · 5 blank · 6 comment · 4 complexity · 9e6eeeb0f4ab11dcfce63edf12a12687 MD5 · raw file

  1. package jfm.model;
  2. import jfm.model.Types.CropType;
  3. /** \internal Identifier class for a particular crop in a particular year.
  4. * Typically used as a key in hashmaps
  5. * <em> immutable </em>
  6. *
  7. * @author Ira Cooke */
  8. final class CropYear {
  9. public final CropType base;
  10. public final int copyYear;
  11. CropYear(CropType b,int y){
  12. base=b;
  13. copyYear=y;
  14. }
  15. public boolean equals(Object other){
  16. if ( this == other ){ return true;};
  17. if ( other instanceof CropYear){
  18. CropYear oth=(CropYear)other;
  19. if ( oth.base==base&& oth.copyYear==copyYear){
  20. return true;
  21. }
  22. }
  23. return false;
  24. }
  25. public int hashCode(){
  26. int hash=7;
  27. hash=31*hash+base.hashCode();
  28. hash=31*hash+copyYear;
  29. return hash;
  30. }
  31. }