You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2020/01/01 03:43:47 UTC
[commons-lang] branch master updated: [LANG-1510] Add
org.apache.commons.lang3.arch.Processor.Arch.getLabel().
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-lang.git
The following commit(s) were added to refs/heads/master by this push:
new 931101d [LANG-1510] Add org.apache.commons.lang3.arch.Processor.Arch.getLabel().
931101d is described below
commit 931101dd6528f23deadb71d21a4a06f0e8653fe4
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Tue Dec 31 22:43:43 2019 -0500
[LANG-1510] Add org.apache.commons.lang3.arch.Processor.Arch.getLabel().
---
src/changes/changes.xml | 1 +
.../org/apache/commons/lang3/arch/Processor.java | 37 +++++++++++++++++-----
.../org/apache/commons/lang3/ArchUtilsTest.java | 9 ++++++
3 files changed, 39 insertions(+), 8 deletions(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index d311e52..33b938e 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -91,6 +91,7 @@ The <action> type attribute can be add,update,fix,remove.
<action issue="LANG-1506" type="add" dev="ggregory" due-to="Gary Gregory">Allow a StopWatch to carry an optional message.</action>
<action issue="LANG-1507" type="add" dev="ggregory" due-to="Sam Kruglov, Mark Dacek, Marc Magon, Pascal Schumacher, Rob Tompkins, Bruno P. Kinoshita, Amey Jadiye, Gary Gregory">Add ComparableUtils #398.</action>
<action issue="LANG-1508" type="add" dev="ggregory" due-to="Gary Gregory">Add org.apache.commons.lang3.SystemUtils.getUserName().</action>
+ <action issue="LANG-1510" type="add" dev="ggregory" due-to="Gary Gregory">Add org.apache.commons.lang3.arch.Processor.Arch.getLabel().</action>
</release>
<release version="3.9" date="2019-04-09" description="New features and bug fixes. Requires Java 8, supports Java 9, 10, 11.">
diff --git a/src/main/java/org/apache/commons/lang3/arch/Processor.java b/src/main/java/org/apache/commons/lang3/arch/Processor.java
index 194e0cb..965c641 100644
--- a/src/main/java/org/apache/commons/lang3/arch/Processor.java
+++ b/src/main/java/org/apache/commons/lang3/arch/Processor.java
@@ -19,6 +19,7 @@ package org.apache.commons.lang3.arch;
/**
* The {@link Processor} represents a microprocessor and defines
* some properties like architecture and type of the microprocessor.
+ *
* @since 3.6
*/
public class Processor {
@@ -29,9 +30,9 @@ public class Processor {
* of the microprocessor.
* The following architectures are defined:
* <ul>
- * <li>32 bit</li>
- * <li>64 bit</li>
- * <li>unknown</li>
+ * <li>32-bit</li>
+ * <li>64-bit</li>
+ * <li>Unknown</li>
* </ul>
*/
public enum Arch {
@@ -39,17 +40,37 @@ public class Processor {
/**
* A 32-bit processor architecture.
*/
- BIT_32,
+ BIT_32("32-bit"),
/**
* A 64-bit processor architecture.
*/
- BIT_64,
+ BIT_64("64-bit"),
/**
* An unknown-bit processor architecture.
*/
- UNKNOWN
+ UNKNOWN("Unknown");
+
+ /**
+ * A label suitable for display.
+ *
+ * @since 3.10
+ */
+ private final String label;
+
+ private Arch(final String label) {
+ this.label = label;
+ }
+
+ /**
+ * Gets the label suitable for display.
+ *
+ * @return the label.
+ */
+ public String getLabel() {
+ return label;
+ }
}
/**
@@ -58,8 +79,8 @@ public class Processor {
* <ul>
* <li>x86</li>
* <li>ia64</li>
- * <li>ppc</li>
- * <li>unknown</li>
+ * <li>PPC</li>
+ * <li>Unknown</li>
* </ul>
*/
public enum Type {
diff --git a/src/test/java/org/apache/commons/lang3/ArchUtilsTest.java b/src/test/java/org/apache/commons/lang3/ArchUtilsTest.java
index c1d2a90..55724ff 100644
--- a/src/test/java/org/apache/commons/lang3/ArchUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/ArchUtilsTest.java
@@ -17,6 +17,7 @@
package org.apache.commons.lang3;
import org.apache.commons.lang3.arch.Processor;
+import org.apache.commons.lang3.arch.Processor.Arch;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -96,6 +97,14 @@ public class ArchUtilsTest {
}
@Test
+ public void testArchLabels() {
+ for (Arch arch : Arch.values()) {
+ // Only test label presence.
+ assertFalse(arch.getLabel().isEmpty());
+ }
+ }
+
+ @Test
public void testGetProcessor() {
assertNotNull(ArchUtils.getProcessor(X86));
assertNull(ArchUtils.getProcessor("NA"));