All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.springmodules.validation.util.condition.string.AbstractStringCondition Maven / Gradle / Ivy

There is a newer version: 0.8a
Show newest version
/*
 * Copyright 2004-2005 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.springmodules.validation.util.condition.string;

import org.springmodules.validation.util.condition.Condition;
import org.springmodules.validation.util.condition.NonNullAcceptingTypeSpecificCondition;

/**
 * An abstract condition that can be applied on objects of type {@link java.lang.String}.
 *
 * @author Uri Boness
 */
public abstract class AbstractStringCondition extends NonNullAcceptingTypeSpecificCondition {

    protected final static String EMPTY_STRING = "";

    /**
     * Constructs a new AbstractStringCondition.
     */
    protected AbstractStringCondition() {
        super(String.class);
    }

    /**
     * See {@link Condition#check(Object)}
     *
     * @throws IllegalArgumentException if the given object is either null or not of a
     *         java.lang.String type.
     */
    public final boolean doCheck(Object object) {
        return checkString((String)object);
    }

    /**
     * Checks whether the given string adheres to this condition.
     *
     * @param text The string to be checked.
     * @return true if the given string adheres to this condition, false otherwise.
     */
    protected abstract boolean checkString(String text);

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy