blob: 8fe3f541c57714d279b08640afe1eed72100dc92 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2007, 2013 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.command;
import java.io.Serializable;
import org.eclipse.jpt.common.utility.command.Command;
import org.eclipse.jpt.common.utility.internal.ObjectTools;
/**
* Singleton implementation of the command interface that will do nothing
* when executed.
*/
public final class NullCommand
implements Command, Serializable
{
public static final Command INSTANCE = new NullCommand();
public static Command instance() {
return INSTANCE;
}
// ensure single instance
private NullCommand() {
super();
}
public void execute() {
// do nothing
}
@Override
public String toString() {
return ObjectTools.singletonToString(this);
}
private static final long serialVersionUID = 1L;
private Object readResolve() {
// replace this object with the singleton
return INSTANCE;
}
}