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