diff options
Diffstat (limited to 'common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/predicate/int_/True.java')
-rw-r--r-- | common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/predicate/int_/True.java | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/predicate/int_/True.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/predicate/int_/True.java new file mode 100644 index 0000000000..d0c1951f62 --- /dev/null +++ b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/predicate/int_/True.java @@ -0,0 +1,52 @@ +/******************************************************************************* + * Copyright (c) 2005, 2015 Oracle. All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0, which accompanies this distribution + * and is available at http://www.eclipse.org/legal/epl-v10.html. + * + * Contributors: + * Oracle - initial API and implementation + ******************************************************************************/ +package org.eclipse.jpt.common.utility.internal.predicate.int_; + +import java.io.Serializable; +import org.eclipse.jpt.common.utility.predicate.IntPredicate; + +/** + * Singleton predicate that always evaluates to + * <code>true</code>. + * + * @see False + */ +public final class True + implements IntPredicate, Serializable +{ + public static final IntPredicate INSTANCE = new True(); + + public static IntPredicate instance() { + return INSTANCE; + } + + // ensure single instance + private True() { + super(); + } + + /** + * Return <code>true</code>. + */ + public boolean evaluate(int variable) { + return true; + } + + @Override + public String toString() { + return this.getClass().getSimpleName(); + } + + private static final long serialVersionUID = 1L; + private Object readResolve() { + // replace this object with the singleton + return INSTANCE; + } +} |