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 class
Category.Other
-
Field Summary
Fields Modifier and Type Field Description static Category.Other
OTHER
Other things.
-
Constructor Summary
Constructors Modifier Constructor Description protected
Category(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 int
compareTo(Category c)
boolean
equals(java.lang.Object o)
int
hashCode()
java.lang.String
name()
int
order()
static Category
registerCategory(Category category)
Register a category.java.lang.String
toString()
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:
toString
in classjava.lang.Object
-
order
public final int order()
-
equals
public final boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public final int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-