public abstract class System extends Object
The meaning of system is deliberately loose. A system might be a laptop, a platform-as-a-service such as the Oracle Application Container Cloud Service or Heroku, a generic Linux-like ecosystem running as part of a Kubernetes cluster, and so on.
System instances provide access to
their environment as well as to their
properties.
In an arbitrary collection of System instances, zero or
one of them may be marked as being
authoritative. An authoritative
System holds sway, and its properties and environment
values are to be preferred over all others.
getSystems(),
getenv(),
getProperties(),
isAuthoritative()| Modifier | Constructor and Description |
|---|---|
protected |
System(String name,
boolean authoritative)
Creates a new
System. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object other)
|
Map<String,String> |
getenv()
|
String |
getName()
Returns the name of this
System. |
Properties |
getProperties()
|
static Set<System> |
getSystems()
Returns a non-
null, unchanging and unmodifiable Set
of System instances as found by the Java service provider mechanism. |
int |
hashCode()
|
boolean |
isAuthoritative()
Returns
true if this System is
authoritative. |
abstract boolean |
isEnabled()
Returns
true if this System is enabled. |
protected System(String name, boolean authoritative)
System.name - the name of the System; must not be nullauthoritative - whether the System will be
authoritativeNullPointerException - if name is nullgetName(),
isAuthoritative()public final String getName()
System.
This method never returns null.
Multiple invocations of this method will return identical
String instances.
System; never nullSystem(String, boolean)public abstract boolean isEnabled()
true if this System is enabled.
If a System is enabled, then its environment values and properties
may be used. If a System is not enabled, then usage of
its environment values and properties may result in undefined
behavior.
true if this System is enabled; false otherwiseSystem(String, boolean)public boolean isAuthoritative()
true if this System is
authoritative.
If a System is authoritative, then its environment values and properties are to be preferred over any others that might be
present.
In the presence of an authoritative System, usage of a
non-authoritative System may lead to undefined
behavior.
true if this System is authoritative;
false otherwiseSystem(String, boolean)public Map<String,String> getenv()
System as a
non-null, unchanging and unmodifiable Map.
This method never returns null.
Overrides of this method must not return null.
Overrides of this method must ensure that the Map
returned may be used without requiring the user to perform
synchronization.
Multiple invocations of this method or any overridden variants
of it are not guaranteed to return equal or identical Map
instances.
The default implementation of this method returns the result
of invoking System.getenv().
System as a
non-null, unchanging and unmodifiable Map;
never nullgetProperties(),
System.getenv()public Properties getProperties()
System as a non-null, unchanging and unmodifiable Properties object.
This method never returns null.
Overrides of this method must not return null.
Callers must not mutate the Properties object that is
returned. Attempts to do so may result in an UnsupportedOperationException.
Multiple invocations of this method or any overridden variants
of it are not guaranteed to return equal or identical Properties instances.
The default implementation of this method returns the result
of invoking System.getProperties().
System as a non-null, unchanging and unmodifiable Properties object;
never nullgetenv(),
System.getProperties()public int hashCode()
hashCode in class ObjectSystemequals(Object)public boolean equals(Object other)
true if this System is equal to the
supplied Object.
This System is deemed to be equal to an Object
passed to this method if the supplied Object is an
instance of System and has a name
equal to the name of this System
and has an enabled status equal to
that of this System and
has an authoritative status equal
to that of this
System.
public static final Set<System> getSystems()
null, unchanging and unmodifiable Set
of System instances as found by the Java service provider mechanism.
This method never returns null but may return an
empty Set.
If one of the System instances so discovered
is authoritative, then it will be
the only member of the returned Set.
Multiple invocations of this method are not guaranteed to
return equal or identical Set instances.
null unmodifiable Set
of System instances as found by the Java service provider mechanism; never nullisAuthoritative(),
ServiceLoader.load(Class)Copyright © 2018–2019 Oracle Corporation. All rights reserved.