• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2012 The Guava Authors
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.google.common.base;
18 
19 import com.google.common.annotations.Beta;
20 import com.google.common.annotations.GwtIncompatible;
21 
22 import javax.annotation.Nullable;
23 
24 /**
25  * Represents a {@linkplain System#getProperties() standard system property}.
26  *
27  * @author Kurt Alfred Kluever
28  * @since 15.0
29  */
30 @Beta
31 @GwtIncompatible("java.lang.System#getProperty")
32 public enum StandardSystemProperty {
33 
34   /** Java Runtime Environment version. */
35   JAVA_VERSION("java.version"),
36 
37   /** Java Runtime Environment vendor. */
38   JAVA_VENDOR("java.vendor"),
39 
40   /** Java vendor URL. */
41   JAVA_VENDOR_URL("java.vendor.url"),
42 
43   /** Java installation directory. */
44   JAVA_HOME("java.home"),
45 
46   /** Java Virtual Machine specification version. */
47   JAVA_VM_SPECIFICATION_VERSION("java.vm.specification.version"),
48 
49   /** Java Virtual Machine specification vendor. */
50   JAVA_VM_SPECIFICATION_VENDOR("java.vm.specification.vendor"),
51 
52   /** Java Virtual Machine specification name. */
53   JAVA_VM_SPECIFICATION_NAME("java.vm.specification.name"),
54 
55   /** Java Virtual Machine implementation version. */
56   JAVA_VM_VERSION("java.vm.version"),
57 
58   /** Java Virtual Machine implementation vendor. */
59   JAVA_VM_VENDOR("java.vm.vendor"),
60 
61   /** Java Virtual Machine implementation name. */
62   JAVA_VM_NAME("java.vm.name"),
63 
64   /** Java Runtime Environment specification version. */
65   JAVA_SPECIFICATION_VERSION("java.specification.version"),
66 
67   /** Java Runtime Environment specification vendor. */
68   JAVA_SPECIFICATION_VENDOR("java.specification.vendor"),
69 
70   /** Java Runtime Environment specification name. */
71   JAVA_SPECIFICATION_NAME("java.specification.name"),
72 
73   /** Java class format version number. */
74   JAVA_CLASS_VERSION("java.class.version"),
75 
76   /** Java class path. */
77   JAVA_CLASS_PATH("java.class.path"),
78 
79   /** List of paths to search when loading libraries. */
80   JAVA_LIBRARY_PATH("java.library.path"),
81 
82   /** Default temp file path. */
83   JAVA_IO_TMPDIR("java.io.tmpdir"),
84 
85   /** Name of JIT compiler to use. */
86   JAVA_COMPILER("java.compiler"),
87 
88   /** Path of extension directory or directories. */
89   JAVA_EXT_DIRS("java.ext.dirs"),
90 
91   /** Operating system name. */
92   OS_NAME("os.name"),
93 
94   /** Operating system architecture. */
95   OS_ARCH("os.arch"),
96 
97   /** Operating system version. */
98   OS_VERSION("os.version"),
99 
100   /** File separator ("/" on UNIX). */
101   FILE_SEPARATOR("file.separator"),
102 
103   /** Path separator (":" on UNIX). */
104   PATH_SEPARATOR("path.separator"),
105 
106   /** Line separator ("\n" on UNIX). */
107   LINE_SEPARATOR("line.separator"),
108 
109   /** User's account name. */
110   USER_NAME("user.name"),
111 
112   /** User's home directory. */
113   USER_HOME("user.home"),
114 
115   /** User's current working directory. */
116   USER_DIR("user.dir");
117 
118   private final String key;
119 
StandardSystemProperty(String key)120   private StandardSystemProperty(String key) {
121     this.key = key;
122   }
123 
124   /**
125    * Returns the key used to lookup this system property.
126    */
key()127   public String key() {
128     return key;
129   }
130 
131   /**
132    * Returns the current value for this system property by delegating to
133    * {@link System#getProperty(String)}.
134    */
135   @Nullable
value()136   public String value() {
137     return System.getProperty(key);
138   }
139 
140   /**
141    * Returns a string representation of this system property.
142    */
toString()143   @Override public String toString() {
144     return key() + "=" + value();
145   }
146 }
147