001 002package gololang; 003 004/** 005 * A singleton class that is equals to any object. 006 * <p> 007 * Used in special matching methods to ignore a value. 008 * Note that this <strong>break the commutativity</strong> property of {@code equals}, and thus this object must be 009 * used with caution. 010 */ 011public final class Unknown { 012 013 private static final Unknown INSTANCE = new Unknown(); 014 015 private Unknown() { } 016 017 public static Unknown get() { 018 return INSTANCE; 019 } 020 021 @Override 022 public boolean equals(Object o) { 023 return o != null; 024 } 025 026 @Override 027 public int hashCode() { 028 return 0; 029 } 030}