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