001/*
002 * Copyright 2006-2019 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      https://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.springframework.batch.core.step.skip;
017
018/**
019 * Policy for determining whether or not some processing should be skipped.
020 * 
021 * @author Lucas Ward
022 * @author Dave Syer
023 * @author Mahmoud Ben Hassine
024 */
025public interface SkipPolicy {
026
027        /**
028         * Returns true or false, indicating whether or not processing should
029         * continue with the given throwable. Clients may use
030         * {@code skipCount<0} to probe for exception types that are skippable,
031         * so implementations should be able to handle gracefully the case where
032         * {@code skipCount<0}. Implementations should avoid throwing any
033         * undeclared exceptions.
034         * 
035         * @param t exception encountered while processing
036         * @param skipCount currently running count of skips
037         * @return true if processing should continue, false otherwise.
038         * @throws SkipLimitExceededException if a limit is breached
039         * @throws IllegalArgumentException if the exception is null
040         */
041        boolean shouldSkip(Throwable t, int skipCount) throws SkipLimitExceededException;
042
043}