001/*
002 * Copyright (C) 2012 The Guava Authors
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package com.google.common.base;
018
019import com.google.common.annotations.Beta;
020import com.google.common.annotations.GwtIncompatible;
021
022import javax.annotation.Nullable;
023
024/**
025 * Represents a {@linkplain System#getProperties() standard system property}.
026 *
027 * @author Kurt Alfred Kluever
028 * @since 15.0
029 */
030@Beta
031@GwtIncompatible("java.lang.System#getProperty")
032public enum StandardSystemProperty {
033
034  /** Java Runtime Environment version. */
035  JAVA_VERSION("java.version"),
036
037  /** Java Runtime Environment vendor. */
038  JAVA_VENDOR("java.vendor"),
039
040  /** Java vendor URL. */
041  JAVA_VENDOR_URL("java.vendor.url"),
042
043  /** Java installation directory. */
044  JAVA_HOME("java.home"),
045
046  /** Java Virtual Machine specification version. */
047  JAVA_VM_SPECIFICATION_VERSION("java.vm.specification.version"),
048
049  /** Java Virtual Machine specification vendor. */
050  JAVA_VM_SPECIFICATION_VENDOR("java.vm.specification.vendor"),
051
052  /** Java Virtual Machine specification name. */
053  JAVA_VM_SPECIFICATION_NAME("java.vm.specification.name"),
054
055  /** Java Virtual Machine implementation version. */
056  JAVA_VM_VERSION("java.vm.version"),
057
058  /** Java Virtual Machine implementation vendor. */
059  JAVA_VM_VENDOR("java.vm.vendor"),
060
061  /** Java Virtual Machine implementation name. */
062  JAVA_VM_NAME("java.vm.name"),
063
064  /** Java Runtime Environment specification version. */
065  JAVA_SPECIFICATION_VERSION("java.specification.version"),
066
067  /** Java Runtime Environment specification vendor. */
068  JAVA_SPECIFICATION_VENDOR("java.specification.vendor"),
069
070  /** Java Runtime Environment specification name. */
071  JAVA_SPECIFICATION_NAME("java.specification.name"),
072
073  /** Java class format version number. */
074  JAVA_CLASS_VERSION("java.class.version"),
075
076  /** Java class path. */
077  JAVA_CLASS_PATH("java.class.path"),
078
079  /** List of paths to search when loading libraries. */
080  JAVA_LIBRARY_PATH("java.library.path"),
081
082  /** Default temp file path. */
083  JAVA_IO_TMPDIR("java.io.tmpdir"),
084
085  /** Name of JIT compiler to use. */
086  JAVA_COMPILER("java.compiler"),
087
088  /** Path of extension directory or directories. */
089  JAVA_EXT_DIRS("java.ext.dirs"),
090
091  /** Operating system name. */
092  OS_NAME("os.name"),
093
094  /** Operating system architecture. */
095  OS_ARCH("os.arch"),
096
097  /** Operating system version. */
098  OS_VERSION("os.version"),
099
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
120  private StandardSystemProperty(String key) {
121    this.key = key;
122  }
123
124  /**
125   * Returns the key used to lookup this system property.
126   */
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
136  public String value() {
137    return System.getProperty(key);
138  }
139
140  /**
141   * Returns a string representation of this system property.
142   */
143  @Override public String toString() {
144    return key() + "=" + value();
145  }
146}