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 java.util.ArrayList;
023import java.util.List;
024
025import org.apache.maven.model.Model;
026
027
028/**
029 * A simple model problem collector for testing the model building components.
030 * 
031 * @author Benjamin Bentmann
032 */
033public class SimpleProblemCollector
034    implements ModelProblemCollector
035{
036    private Model model;
037
038    private List<String> warnings = new ArrayList<String>();
039
040    private List<String> errors = new ArrayList<String>();
041
042    private List<String> fatals = new ArrayList<String>();
043
044    public SimpleProblemCollector()
045    {
046    }
047
048    public SimpleProblemCollector( Model model )
049    {
050        this.model = model;
051    }
052
053    public Model getModel()
054    {
055        return model;
056    }
057
058    public List<String> getWarnings()
059    {
060        return warnings;
061    }
062
063    public List<String> getErrors()
064    {
065        return errors;
066    }
067
068    public List<String> getFatals()
069    {
070        return fatals;
071    }
072
073    public void add( ModelProblemCollectorRequest req )
074    {
075        switch ( req.getSeverity() )
076        {
077            case FATAL:
078                fatals.add( req.getMessage() );
079                break;
080            case ERROR:
081                errors.add( req.getMessage() );
082                break;
083            case WARNING:
084                warnings.add( req.getMessage() );
085                break;
086        }
087
088    }
089}