001 002/* 003 * Copyright (c) 2012-2018 Institut National des Sciences Appliquées de Lyon (INSA Lyon) and others 004 * 005 * This program and the accompanying materials are made available under the 006 * terms of the Eclipse Public License 2.0 which is available at 007 * http://www.eclipse.org/legal/epl-2.0. 008 * 009 * SPDX-License-Identifier: EPL-2.0 010 */ 011 012package gololang; 013 014/** 015 * A singleton class that is equals to any object. 016 * <p> 017 * Used in special matching methods to ignore a value. 018 * Note that this <strong>break the commutativity</strong> property of {@code equals}, and thus this object must be 019 * used with caution. 020 */ 021public final class Unknown { 022 023 private static final Unknown INSTANCE = new Unknown(); 024 025 private Unknown() { } 026 027 public static Unknown get() { 028 return INSTANCE; 029 } 030 031 @Override 032 public boolean equals(Object o) { 033 return o != null; 034 } 035 036 @Override 037 public int hashCode() { 038 return 0; 039 } 040}