Author: julien(a)jboss.com
Date: 2007-03-20 12:58:27 -0400 (Tue, 20 Mar 2007)
New Revision: 6781
Modified:
trunk/theme/src/main/org/jboss/portal/theme/page/RegionOrientation.java
trunk/theme/src/main/org/jboss/portal/theme/tag/RegionTagHandler.java
Log:
simplified type safe enum class
Modified: trunk/theme/src/main/org/jboss/portal/theme/page/RegionOrientation.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/page/RegionOrientation.java 2007-03-20
16:39:07 UTC (rev 6780)
+++ trunk/theme/src/main/org/jboss/portal/theme/page/RegionOrientation.java 2007-03-20
16:58:27 UTC (rev 6781)
@@ -31,29 +31,31 @@
*/
public final class RegionOrientation
{
+
/** Place portlets in one region in vertical order. */
public static final RegionOrientation VERTICAL = new
RegionOrientation("vertical");
/** Place portlets in one region in horizontal order. */
public static final RegionOrientation HORIZONTAL = new
RegionOrientation("horizontal");
+ /** The default value which is vertical. */
public static final RegionOrientation DEFAULT = VERTICAL;
- private final String m_orient;
+ /** The literal value. */
+ private final String value;
- private RegionOrientation()
+ private RegionOrientation(String value)
{
- this("vertical");
+ if (value == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.value = value;
}
- private RegionOrientation(String orient)
- {
- m_orient = orient;
- }
-
public String toString()
{
- return m_orient;
+ return value;
}
public boolean equals(Object o)
@@ -62,34 +64,27 @@
{
return true;
}
- if (!(o instanceof RegionOrientation))
+ if (o instanceof RegionOrientation)
{
- return false;
+ RegionOrientation that = (RegionOrientation)o;
+ return this.value.equals(that.value);
}
-
- final RegionOrientation orientation = (RegionOrientation)o;
-
- if (m_orient != null ? !m_orient.equals(orientation.m_orient) :
orientation.m_orient != null)
- {
- return false;
- }
-
- return true;
+ return false;
}
public int hashCode()
{
- return (m_orient != null ? m_orient.hashCode() : 0);
+ return value.hashCode();
}
/**
- * parse a string representation of a region orientation into a defined type.
+ * Parse a string representation of a region orientation into a defined type.
*
* @param orientation the string representation of the orientation
* @return the defined type for the string
* @throws IllegalArgumentException if the provided orientation String is invalid
*/
- public static RegionOrientation parseOrientation(String orientation)
+ public static RegionOrientation parse(String orientation)
{
if (orientation != null)
{
@@ -103,6 +98,7 @@
}
}
- throw new IllegalArgumentException("invalid orientation: " +
orientation);
+ //
+ throw new IllegalArgumentException("Invalid orientation: " +
orientation);
}
}
Modified: trunk/theme/src/main/org/jboss/portal/theme/tag/RegionTagHandler.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/tag/RegionTagHandler.java 2007-03-20
16:39:07 UTC (rev 6780)
+++ trunk/theme/src/main/org/jboss/portal/theme/tag/RegionTagHandler.java 2007-03-20
16:58:27 UTC (rev 6781)
@@ -143,7 +143,7 @@
try
{
- this.orientation = RegionOrientation.parseOrientation(orientation);
+ this.orientation = RegionOrientation.parse(orientation);
}
catch (IllegalArgumentException e)
{