001package org.apache.maven.model.building;
002
003/*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements.  See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership.  The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License.  You may obtain a copy of the License at
011 *
012 *   http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied.  See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022import org.apache.maven.model.InputLocation;
023import org.apache.maven.model.building.ModelProblem.Severity;
024import org.apache.maven.model.building.ModelProblem.Version;
025
026/**
027 * Class to wrap request parameters to ModelProblemCollector.addProblem
028 *
029 * @author mkleint
030 */
031public final class ModelProblemCollectorRequest
032{
033
034    private final ModelProblem.Severity severity;
035    private final ModelProblem.Version version;
036    private Exception exception;
037    private String message;
038    private InputLocation location;
039    
040    /**
041     * Create a new request with mandatory parameters.
042     * @param severity
043     * @param version 
044     */
045    public ModelProblemCollectorRequest( Severity severity, Version version )
046    {
047        this.severity = severity;
048        this.version = version;
049        if ( severity == null )
050        {
051            throw new IllegalStateException( "No severity declared" );
052        }
053        if ( version == null )
054        {
055            throw new IllegalStateException( "No version declared." );
056        }
057    }
058
059    public Severity getSeverity()
060    {
061        return severity;
062    }
063
064    public Version getVersion()
065    {
066        return version;
067    }
068
069    public Exception getException()
070    {
071        return exception;
072    }
073
074    public ModelProblemCollectorRequest setException( Exception exception )
075    {
076        this.exception = exception;
077        return this;
078    }
079
080    public String getMessage()
081    {
082        return message;
083    }
084
085    public ModelProblemCollectorRequest setMessage( String message )
086    {
087        this.message = message;
088        return this;
089    }
090
091    public InputLocation getLocation()
092    {
093        return location;
094    }
095
096    public ModelProblemCollectorRequest setLocation( InputLocation location )
097    {
098        this.location = location;
099        return this;
100    }
101}