diff --git a/src/changes/changes.xml b/src/changes/changes.xml index d311e529d..33b938eab 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -91,6 +91,7 @@ The type attribute can be add,update,fix,remove. Allow a StopWatch to carry an optional message. Add ComparableUtils #398. Add org.apache.commons.lang3.SystemUtils.getUserName(). + Add org.apache.commons.lang3.arch.Processor.Arch.getLabel(). 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 194e0cbf6..965c64186 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 @@ /** * 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: * */ public enum Arch { @@ -39,17 +40,37 @@ public enum Arch { /** * 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 enum Arch { * */ 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 c1d2a904e..55724ff98 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; @@ -95,6 +96,14 @@ public void testArch() { assertTrue(processor.isPPC()); } + @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));