blob: 6ad918135c0d780ef7badb25d4d10715d49c8716 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2011, 2012 Oracle and/or its affiliates. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* Oracle - initial API and implementation
*
******************************************************************************/
package org.eclipse.persistence.tools.utility;
import java.io.Serializable;
/**
* This filter accepts only non-<code>null</code>, non-empty,
* non-whitespace-only strings.
*/
public class NonEmptyStringFilter
implements Filter<String>, Serializable
{
public static final Filter<String> INSTANCE = new NonEmptyStringFilter();
public static Filter<String> instance() {
return INSTANCE;
}
// ensure single instance
private NonEmptyStringFilter() {
super();
}
// accept only non-null objects
@Override
public boolean accept(String string) {
return StringTools.stringIsNotEmpty(string);
}
@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;
}
}