File tree Expand file tree Collapse file tree
SIF3InfraREST/sif3Common/src/main/java/au/com/systemic/framework/utils Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -517,5 +517,35 @@ public static String exceptionToString(Throwable ex)
517517 ex .printStackTrace (new PrintWriter (sw ));
518518
519519 return sw .toString ();
520- }
520+ }
521+
522+ /**
523+ * Pure convenience method for pretty print of enum list. If your enum is defined as<br/>
524+ * enum MyEnum {enum1, enum2, ...}<br/>
525+ * then this method will return:<br/>
526+ * "enum1,enum2,..."<br/>
527+ * The call would be getNamesForEnum(MyEnum.class).
528+ *
529+ * @param The enum class to convert into a pretty string.
530+ *
531+ * @return See desc.
532+ */
533+ public static String getNamesForEnum (Class <? extends Enum <?>> enumClass )
534+ {
535+ StringBuffer prettyEnum = new StringBuffer ();
536+
537+ Enum <?>[] enumArray = enumClass .getEnumConstants ();
538+ for (Enum <?> enumValue : enumArray )
539+ {
540+ if (prettyEnum .length () > 0 )
541+ {
542+ prettyEnum .append ("," );
543+ }
544+ prettyEnum .append (enumValue .name ());
545+ }
546+
547+ return prettyEnum .toString ();
548+ }
549+
550+
521551}
You can’t perform that action at this time.
0 commit comments