001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017
018 package org.apache.commons.pipeline.validation;
019
020 import org.apache.commons.pipeline.Stage;
021
022 /**
023 * This class is used to store a collection of information about a particular
024 * validation failure.
025 *
026 */
027 public class ValidationFailure {
028 /**
029 * Enumeration of possible causes of validation failure
030 */
031 public enum Type {
032 /**
033 * Indicates that a stage appears to be unable to consume the output of the previous stage
034 */
035 STAGE_CONNECT,
036 /**
037 * Indicates that a branch could not consume the output (type mismatch) of pipeline
038 * stages feeding the branch.
039 */
040 BRANCH_CONNECT,
041 /**
042 * Indicates that a branch to consume the branch output of a stage could not be found.
043 */
044 BRANCH_NOT_FOUND,
045 /**
046 * Other validation error - see detail message.
047 */
048 OTHER
049 };
050
051 private Type type;
052 private String message;
053 private Stage upstream;
054 private Stage downstream;
055
056 /**
057 * Creates a new instance of ValidationError
058 * @param type The type of problem encountered
059 * @param message A message with more detailed information about the problem
060 * @param upstream A reference to the upstream stage
061 * @param downstream A reference to a downstream stage
062 */
063 public ValidationFailure(Type type, String message, Stage upstream, Stage downstream) {
064 this.type = type;
065 this.message = message;
066 this.upstream = upstream;
067 this.downstream = downstream;
068 }
069
070 /**
071 * Type identifying what sort of problem was encountered
072 * @return the type of problem encountered
073 */
074 public Type getType() {
075 return this.type;
076 }
077
078 /**
079 * Returns the descriptive message about the error
080 * @return message describing the error
081 */
082 public String getMessage() {
083 return this.message;
084 }
085
086 /**
087 * The stage upstream of the connection that could not be validated
088 * @return reference to the upstream Stage
089 */
090 public Stage getUpstreamStage() {
091 return this.upstream;
092 }
093
094 /**
095 * The stage downstream of the connection that could not be validated
096 * @return reference to the downstream Stage
097 */
098 public Stage getDownstreamStage() {
099 return this.downstream;
100 }
101 }