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
022/**
023 * Represents a {@linkplain System#getProperties() standard system property}.
024 *
025 * @author Kurt Alfred Kluever
026 * @since 15.0
027 */
028@Beta
029@GwtIncompatible("java.lang.System#getProperty")
030public enum StandardSystemProperty {
031
032  /** Java Runtime Environment version. */
033  JAVA_VERSION("java.version"),
034
035  /** Java Runtime Environment vendor. */
036  JAVA_VENDOR("java.vendor"),
037
038  /** Java vendor URL. */
039  JAVA_VENDOR_URL("java.vendor.url"),
040
041  /** Java installation directory. */
042  JAVA_HOME("java.home"),
043
044  /** Java Virtual Machine specification version. */
045  JAVA_VM_SPECIFICATION_VERSION("java.vm.specification.version"),
046
047  /** Java Virtual Machine specification vendor. */
048  JAVA_VM_SPECIFICATION_VENDOR("java.vm.specification.vendor"),
049
050  /** Java Virtual Machine specification name. */
051  JAVA_VM_SPECIFICATION_NAME("java.vm.specification.name"),
052
053  /** Java Virtual Machine implementation version. */
054  JAVA_VM_VERSION("java.vm.version"),
055
056  /** Java Virtual Machine implementation vendor. */
057  JAVA_VM_VENDOR("java.vm.vendor"),
058
059  /** Java Virtual Machine implementation name. */
060  JAVA_VM_NAME("java.vm.name"),
061
062  /** Java Runtime Environment specification version. */
063  JAVA_SPECIFICATION_VERSION("java.specification.version"),
064
065  /** Java Runtime Environment specification vendor. */
066  JAVA_SPECIFICATION_VENDOR("java.specification.vendor"),
067
068  /** Java Runtime Environment specification name. */
069  JAVA_SPECIFICATION_NAME("java.specification.name"),
070
071  /** Java class format version number. */
072  JAVA_CLASS_VERSION("java.class.version"),
073
074  /** Java class path. */
075  JAVA_CLASS_PATH("java.class.path"),
076
077  /** List of paths to search when loading libraries. */
078  JAVA_LIBRARY_PATH("java.library.path"),
079
080  /** Default temp file path. */
081  JAVA_IO_TMPDIR("java.io.tmpdir"),
082
083  /** Name of JIT compiler to use. */
084  JAVA_COMPILER("java.compiler"),
085
086  /** Path of extension directory or directories. */
087  JAVA_EXT_DIRS("java.ext.dirs"),
088
089  /** Operating system name. */
090  OS_NAME("os.name"),
091
092  /** Operating system architecture. */
093  OS_ARCH("os.arch"),
094
095  /** Operating system version. */
096  OS_VERSION("os.version"),
097
098  /** File separator ("/" on UNIX). */
099  FILE_SEPARATOR("file.separator"),
100
101  /** Path separator (":" on UNIX). */
102  PATH_SEPARATOR("path.separator"),
103
104  /** Line separator ("\n" on UNIX). */
105  LINE_SEPARATOR("line.separator"),
106
107  /** User's account name. */
108  USER_NAME("user.name"),
109
110  /** User's home directory. */
111  USER_HOME("user.home"),
112
113  /** User's current working directory. */
114  USER_DIR("user.dir");
115
116  private final String key;
117
118  private StandardSystemProperty(String key) {
119    this.key = key;
120  }
121
122  /**
123   * Returns the key used to lookup this system property.
124   */
125  public String key() {
126    return key;
127  }
128
129  /**
130   * Returns the current value for this system property by delegating to
131   * {@link System#getProperty(String)}.
132   */
133  public String value() {
134    return System.getProperty(key);
135  }
136
137  /**
138   * Returns a string representation of this system property.
139   */
140  @Override public String toString() {
141    return key() + "=" + value();
142  }
143}