Replaced SystemInfo.getMachineArchitecture() with getArchitecture() and getArchitectureName().
This commit is contained in:
@@ -21,6 +21,8 @@ package net.rubygrapefruit.platform;
|
||||
*/
|
||||
@ThreadSafe
|
||||
public interface SystemInfo extends NativeIntegration {
|
||||
enum Architecture { i386, amd64 }
|
||||
|
||||
/**
|
||||
* Returns the name of the kernel for the current operating system.
|
||||
*/
|
||||
@@ -33,9 +35,15 @@ public interface SystemInfo extends NativeIntegration {
|
||||
@ThreadSafe
|
||||
String getKernelVersion();
|
||||
|
||||
/**
|
||||
* Returns the machine architecture name, as reported by the operating system.
|
||||
*/
|
||||
@ThreadSafe
|
||||
String getArchitectureName();
|
||||
|
||||
/**
|
||||
* Returns the machine architecture, as reported by the operating system.
|
||||
*/
|
||||
@ThreadSafe
|
||||
String getMachineArchitecture();
|
||||
Architecture getArchitecture();
|
||||
}
|
||||
|
||||
@@ -32,18 +32,19 @@ public class DefaultSystemInfo implements SystemInfo {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKernelName() {
|
||||
return systemInfo.getKernelName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKernelVersion() {
|
||||
return systemInfo.getKernelVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMachineArchitecture() {
|
||||
return systemInfo.getMachineArchitecture();
|
||||
public String getArchitectureName() {
|
||||
return systemInfo.getArchitectureName();
|
||||
}
|
||||
|
||||
public Architecture getArchitecture() {
|
||||
return systemInfo.getArchitecture();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package net.rubygrapefruit.platform.internal;
|
||||
|
||||
import net.rubygrapefruit.platform.NativeException;
|
||||
import net.rubygrapefruit.platform.SystemInfo;
|
||||
|
||||
public class MutableSystemInfo implements SystemInfo {
|
||||
@@ -32,10 +33,21 @@ public class MutableSystemInfo implements SystemInfo {
|
||||
return osVersion;
|
||||
}
|
||||
|
||||
public String getMachineArchitecture() {
|
||||
public String getArchitectureName() {
|
||||
return machineArchitecture;
|
||||
}
|
||||
|
||||
public Architecture getArchitecture() {
|
||||
if (machineArchitecture.equals("amd64") || machineArchitecture.equals("x86_64")) {
|
||||
return Architecture.amd64;
|
||||
}
|
||||
if (machineArchitecture.equals("i386") || machineArchitecture.equals("x86")) {
|
||||
return Architecture.i386;
|
||||
}
|
||||
throw new NativeException(String.format("Cannot determine architecture from kernel architecture name '%s'.",
|
||||
machineArchitecture));
|
||||
}
|
||||
|
||||
// Called from native code
|
||||
void windows(int major, int minor, int build, boolean workstation, String arch) {
|
||||
osName = toWindowsVersionName(major, minor, workstation);
|
||||
|
||||
@@ -33,6 +33,7 @@ class SystemInfoTest extends Specification {
|
||||
expect:
|
||||
systemInfo.kernelName
|
||||
systemInfo.kernelVersion
|
||||
systemInfo.machineArchitecture
|
||||
systemInfo.architectureName
|
||||
systemInfo.architecture
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user