Package jmri
Class Category
- java.lang.Object
-
- jmri.Category
-
- All Implemented Interfaces:
java.lang.Comparable<Category>
- Direct Known Subclasses:
Category.Other,LogixNG_Category
public abstract class Category extends java.lang.Object implements java.lang.Comparable<Category>
A category of something.Category was created for LogixNG actions and expressions but it can be used for everything in JMRI that needs "extendable enums".
This class is intended to be an Enum, but implemented as an abstract class to allow adding more categories later without needing to change this class. For example, external programs using JMRI as a lib might want to add their own categories.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCategory.Other
-
Field Summary
Fields Modifier and Type Field Description static Category.OtherOTHEROther things.
-
Constructor Summary
Constructors Modifier Constructor Description protectedCategory(java.lang.String name, java.lang.String description, int order)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(Category c)booleanequals(java.lang.Object o)inthashCode()java.lang.Stringname()intorder()static CategoryregisterCategory(Category category)Register a category.java.lang.StringtoString()static java.util.List<Category>values()Get all the registered Categories
-
-
-
Field Detail
-
OTHER
public static final Category.Other OTHER
Other things.
-
-
Constructor Detail
-
Category
protected Category(java.lang.String name, java.lang.String description, int order)
-
-
Method Detail
-
values
public static java.util.List<Category> values()
Get all the registered Categories- Returns:
- a list of categories
-
registerCategory
public static Category registerCategory(Category category) throws java.lang.IllegalArgumentException
Register a category. There must not exist any category with either the name or the description of this category. Otherwise an IllegalArgumentException will be thrown.- Parameters:
category- the category- Returns:
- the new category
- Throws:
java.lang.IllegalArgumentException- if the category already is registered.
-
name
public final java.lang.String name()
-
toString
public final java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
order
public final int order()
-
equals
public final boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public final int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-