1 //
2 // ========================================================================
3 // Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
4 // ------------------------------------------------------------------------
5 // All rights reserved. This program and the accompanying materials
6 // are made available under the terms of the Eclipse Public License v1.0
7 // and Apache License v2.0 which accompanies this distribution.
8 //
9 // The Eclipse Public License is available at
10 // http://www.eclipse.org/legal/epl-v10.html
11 //
12 // The Apache License v2.0 is available at
13 // http://www.opensource.org/licenses/apache2.0.php
14 //
15 // You may elect to redistribute this code under either of these licenses.
16 // ========================================================================
17 //
18
19 package org.eclipse.jetty.maven.plugin;
20
21 import java.util.ArrayList;
22 import java.util.HashMap;
23 import java.util.List;
24 import java.util.Map;
25
26 /**
27 * SystemProperties
28 *
29 * Map of name to SystemProperty.
30 *
31 * When a SystemProperty instance is added, if it has not
32 * been already set (eg via the command line java system property)
33 * then it will be set.
34 */
35 public class SystemProperties
36 {
37 private final Map<String, SystemProperty> properties;
38 private boolean force;
39
40 public SystemProperties()
41 {
42 properties = new HashMap<>();
43 }
44
45 public void setForce (boolean force)
46 {
47 this.force = force;
48 }
49
50 public boolean getForce ()
51 {
52 return this.force;
53 }
54
55
56 public void setSystemProperty (SystemProperty prop)
57 {
58 properties.put(prop.getName(), prop);
59 if (!force)
60 prop.setIfNotSetAlready();
61 else
62 prop.setAnyway();
63 }
64
65 public SystemProperty getSystemProperty(String name)
66 {
67 return properties.get(name);
68 }
69
70 public boolean containsSystemProperty(String name)
71 {
72 return properties.containsKey(name);
73 }
74
75 public List<SystemProperty> getSystemProperties ()
76 {
77 return new ArrayList<>(properties.values());
78 }
79 }