package com.marinilli.b2.c12;

/**
 * Chapter 12 - This class represents an unspecified version
 *
 * @author Mauro Marinilli
 * @version 1.0
 */

public class UnspecifiedVersion extends VersionId {

  /**
   * Constructs an UnspecifiedVersion object.
   */
   public UnspecifiedVersion() {
    super(null);
  }

  /**
   * We assume an unspecified version doesn't match any other version different than unspecified
   */
  public boolean match(Versionable v) {
    if (v instanceof UnspecifiedVersion)
      return true;
    return false;
  }

  /**
   * compare a VersionId against another
   */
  public int compareToVersionId(VersionId vid) {
    return 0;//an unspecified version is assumed to always be equal to another version
  }

  /**
   * Implements the Comparable interface
   */
  public int compareTo(Object obj) {
    return 0;//an unspecified version is assumed to always be equal to another version
  }

  public String toString() {
    return "unspecified";
  }

  /**
   * In first approx. VersionIds are considered equals when they have
   * the same string representation.
   */
  public boolean equals(Object object) {
    if (object instanceof UnspecifiedVersion)
      return true;
    return false;
  }
}