From 5026ac0477c0db643b0a8d3f1d775c87d82124ac Mon Sep 17 00:00:00 2001 From: Major- Date: Sat, 15 Feb 2014 15:13:48 +0000 Subject: [PATCH] Add warnings about consistent element ordering; Use ordinal where possible. --- .../apollo/game/model/settings/Gender.java | 3 +- .../game/model/settings/PrivacyState.java | 7 +++-- .../game/model/settings/PrivilegeLevel.java | 29 +++++-------------- .../game/model/settings/ScreenBrightness.java | 27 +++++------------ .../game/model/settings/ServerStatus.java | 25 ++++------------ 5 files changed, 28 insertions(+), 63 deletions(-) diff --git a/src/org/apollo/game/model/settings/Gender.java b/src/org/apollo/game/model/settings/Gender.java index 806e22f9..81a7fac6 100644 --- a/src/org/apollo/game/model/settings/Gender.java +++ b/src/org/apollo/game/model/settings/Gender.java @@ -1,7 +1,8 @@ package org.apollo.game.model.settings; /** - * An enumeration containing the two genders (male and female). + * An enumeration containing the two genders (male and female). This enumeration relies on the ordering of the elements + * within, which should be as follows: {@code MALE}, {@code FEMALE}. * * @author Graham */ diff --git a/src/org/apollo/game/model/settings/PrivacyState.java b/src/org/apollo/game/model/settings/PrivacyState.java index 9ea02ea8..5827670c 100644 --- a/src/org/apollo/game/model/settings/PrivacyState.java +++ b/src/org/apollo/game/model/settings/PrivacyState.java @@ -1,7 +1,9 @@ package org.apollo.game.model.settings; /** - * An enumeration representing the different privacy states for public, private and trade chat. + * An enumeration representing the different privacy states for public, private and trade chat. This enumeration relies + * on the ordering of the elements within, which should be as follows: {@code ON}, {@code HIDE}, {@code FRIENDS}, + * {@code OFF}, {@code FILTERABLE}. * * @author Kyle Stevenson */ @@ -29,7 +31,8 @@ public enum PrivacyState { OFF(3), /** - * Represents the 'filterable' state - a custom state that filters 'unnecessary' server messages. + * Represents the 'filterable' state - a custom state that filters 'unnecessary' server messages. This state only + * applies to public chat. */ FILTERABLE(4); diff --git a/src/org/apollo/game/model/settings/PrivilegeLevel.java b/src/org/apollo/game/model/settings/PrivilegeLevel.java index b960723f..77a8e45d 100644 --- a/src/org/apollo/game/model/settings/PrivilegeLevel.java +++ b/src/org/apollo/game/model/settings/PrivilegeLevel.java @@ -1,7 +1,8 @@ package org.apollo.game.model.settings; /** - * An enumeration with the different privilege levels a player can have. + * An enumeration with the different privilege levels a player can have. This enumeration relies on the ordering of the + * elements within, which should be as follows: {@code STANDARD}, {@code MODERATOR}, {@code ADMINISTRATOR}. * * @author Graham */ @@ -10,17 +11,17 @@ public enum PrivilegeLevel { /** * A standard (rights 0) account. */ - STANDARD(0), + STANDARD, /** * A player moderator (rights 1) account. */ - MODERATOR(1), + MODERATOR, /** * An administrator (rights 2) account. */ - ADMINISTRATOR(2); + ADMINISTRATOR; /** * Gets the privilege level for the specified numerical value. @@ -38,26 +39,12 @@ public enum PrivilegeLevel { } /** - * The numerical level used in the protocol. - */ - private final int value; - - /** - * Creates the privilege level. + * Gets the numerical value of this privilege level. * - * @param value The numerical level. - */ - private PrivilegeLevel(int value) { - this.value = value; - } - - /** - * Gets the numerical level. - * - * @return The numerical level used in the protocol. + * @return The numerical value used in the protocol. */ public int toInteger() { - return value; + return ordinal(); } } \ No newline at end of file diff --git a/src/org/apollo/game/model/settings/ScreenBrightness.java b/src/org/apollo/game/model/settings/ScreenBrightness.java index 77d7ff44..10bddb68 100644 --- a/src/org/apollo/game/model/settings/ScreenBrightness.java +++ b/src/org/apollo/game/model/settings/ScreenBrightness.java @@ -1,7 +1,8 @@ package org.apollo.game.model.settings; /** - * An enumeration representing + * An enumeration representing the brightness of a player's screen. This enumeration relies on the ordering of the + * elements within, which should be as follows: {@code DARK}, {@code NORMAL}, {@code BRIGHT}, {@code VERY_BRIGHT}. * * @author Major */ @@ -10,22 +11,22 @@ public enum ScreenBrightness { /** * Represents the 'dark' screen brightness. */ - DARK(0), + DARK, /** * Represents the 'normal' screen brightness. */ - NORMAL(1), + NORMAL, /** * Represents the 'bright' screen brightness. */ - BRIGHT(2), + BRIGHT, /** * Represents the 'very bright' screen brightness. */ - VERY_BRIGHT(3); + VERY_BRIGHT; /** * Gets the screen brightness for the specified numerical value. @@ -42,27 +43,13 @@ public enum ScreenBrightness { return values[value]; } - /** - * The numerical value of this brightness. - */ - private final int value; - - /** - * Creates the screen brightness. - * - * @param value The numerical value. - */ - private ScreenBrightness(int value) { - this.value = value; - } - /** * Converts this screen brightness to an integer. * * @return The numerical value. */ public int toInteger() { - return value; + return ordinal(); } } \ No newline at end of file diff --git a/src/org/apollo/game/model/settings/ServerStatus.java b/src/org/apollo/game/model/settings/ServerStatus.java index d3339968..55f5fb42 100644 --- a/src/org/apollo/game/model/settings/ServerStatus.java +++ b/src/org/apollo/game/model/settings/ServerStatus.java @@ -1,7 +1,8 @@ package org.apollo.game.model.settings; /** - * Represents the status of the friend server. + * Represents the status of the friend server. This enumeration relies on the ordering of the elements within, which + * should be as follows: {@code OFFLINE}, {@code CONNECTING}, {@code ONLINE}. * * @author Major */ @@ -10,31 +11,17 @@ public enum ServerStatus { /** * Indicates the friend server is offline. */ - OFFLINE(0), + OFFLINE, /** * Indicates the friend server is being connected to. */ - CONNECTING(1), + CONNECTING, /** * Indicates the friend server is online and connected. */ - ONLINE(2); - - /** - * The code of the server status. - */ - private final int code; - - /** - * Creates a new server status. - * - * @param code The code. - */ - private ServerStatus(int code) { - this.code = code; - } + ONLINE; /** * Gets the code of this server status. @@ -42,7 +29,7 @@ public enum ServerStatus { * @return The code. */ public int getCode() { - return code; + return ordinal(); } /**