001    package org.apache.maven.settings.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    
022    import java.io.File;
023    import java.util.Properties;
024    
025    /**
026     * Collects settings that control building of effective settings.
027     * 
028     * @author Benjamin Bentmann
029     */
030    public class DefaultSettingsBuildingRequest
031        implements SettingsBuildingRequest
032    {
033    
034        private File globalSettingsFile;
035    
036        private File userSettingsFile;
037    
038        private SettingsSource globalSettingsSource;
039    
040        private SettingsSource userSettingsSource;
041    
042        private Properties systemProperties;
043    
044        private Properties userProperties;
045    
046        public File getGlobalSettingsFile()
047        {
048            return globalSettingsFile;
049        }
050    
051        public DefaultSettingsBuildingRequest setGlobalSettingsFile( File globalSettingsFile )
052        {
053            this.globalSettingsFile = globalSettingsFile;
054    
055            return this;
056        }
057    
058        public SettingsSource getGlobalSettingsSource()
059        {
060            return globalSettingsSource;
061        }
062    
063        public DefaultSettingsBuildingRequest setGlobalSettingsSource( SettingsSource globalSettingsSource )
064        {
065            this.globalSettingsSource = globalSettingsSource;
066    
067            return this;
068        }
069    
070        public File getUserSettingsFile()
071        {
072            return userSettingsFile;
073        }
074    
075        public DefaultSettingsBuildingRequest setUserSettingsFile( File userSettingsFile )
076        {
077            this.userSettingsFile = userSettingsFile;
078    
079            return this;
080        }
081    
082        public SettingsSource getUserSettingsSource()
083        {
084            return userSettingsSource;
085        }
086    
087        public DefaultSettingsBuildingRequest setUserSettingsSource( SettingsSource userSettingsSource )
088        {
089            this.userSettingsSource = userSettingsSource;
090    
091            return this;
092        }
093    
094        public Properties getSystemProperties()
095        {
096            if ( systemProperties == null )
097            {
098                systemProperties = new Properties();
099            }
100    
101            return systemProperties;
102        }
103    
104        public DefaultSettingsBuildingRequest setSystemProperties( Properties systemProperties )
105        {
106            if ( systemProperties != null )
107            {
108                this.systemProperties = new Properties();
109                this.systemProperties.putAll( systemProperties );
110            }
111            else
112            {
113                this.systemProperties = null;
114            }
115    
116            return this;
117        }
118    
119        public Properties getUserProperties()
120        {
121            if ( userProperties == null )
122            {
123                userProperties = new Properties();
124            }
125    
126            return userProperties;
127        }
128    
129        public DefaultSettingsBuildingRequest setUserProperties( Properties userProperties )
130        {
131            if ( userProperties != null )
132            {
133                this.userProperties = new Properties();
134                this.userProperties.putAll( userProperties );
135            }
136            else
137            {
138                this.userProperties = null;
139            }
140    
141            return this;
142        }
143    
144    }