001    /*
002     * Copyright 2012 The Apache Software Foundation.
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     *      http://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     */
016    package org.apache.maven.model.building;
017    
018    import org.apache.maven.model.InputLocation;
019    import org.apache.maven.model.building.ModelProblem.Severity;
020    import org.apache.maven.model.building.ModelProblem.Version;
021    
022    /**
023     * Class to wrap request parameters to ModelProblemCollector.addProblem
024     *
025     * @author mkleint
026     */
027    public final class ModelProblemCollectorRequest
028    {
029    
030        private final ModelProblem.Severity severity;
031        private final ModelProblem.Version version;
032        private Exception exception;
033        private String message;
034        private InputLocation location;
035        
036        /**
037         * Create a new request with mandatory parameters.
038         * @param severity
039         * @param version 
040         */
041        public ModelProblemCollectorRequest(Severity severity, Version version)
042        {
043            this.severity = severity;
044            this.version = version;
045            if (severity == null)
046            {
047                throw new IllegalStateException("No severity declared");
048            }
049            if (version == null)
050            {
051                throw new IllegalStateException("No version declared.");
052            }
053        }
054    
055        public Severity getSeverity()
056        {
057            return severity;
058        }
059    
060        public Version getVersion()
061        {
062            return version;
063        }
064    
065        public Exception getException()
066        {
067            return exception;
068        }
069    
070        public ModelProblemCollectorRequest setException(Exception exception)
071        {
072            this.exception = exception;
073            return this;
074        }
075    
076        public String getMessage()
077        {
078            return message;
079        }
080    
081        public ModelProblemCollectorRequest setMessage(String message)
082        {
083            this.message = message;
084            return this;
085        }
086    
087        public InputLocation getLocation()
088        {
089            return location;
090        }
091    
092        public ModelProblemCollectorRequest setLocation(InputLocation location)
093        {
094            this.location = location;
095            return this;
096        }
097    }