You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "Peter (JIRA)" <ji...@apache.org> on 2013/08/12 02:22:48 UTC

[jira] [Created] (CB-4566) Code should use PluginResult.Status as an enum instead of int ordinal

Peter created CB-4566:
-------------------------

             Summary: Code should use PluginResult.Status as an enum instead of int ordinal
                 Key: CB-4566
                 URL: https://issues.apache.org/jira/browse/CB-4566
             Project: Apache Cordova
          Issue Type: Improvement
          Components: Android
    Affects Versions: 2.9.0
            Reporter: Peter
            Assignee: Joe Bowser
            Priority: Minor


Since PluginResult.Status is an enum, it would be better to use it as enum wherever it is used instead of referring to .ordinal() everywhere.
* code will be easier to read
* code will be shorter
* debugging of status value will be easier

For example, PluginResult.java member status should be enum:
{code}
//private final int status;
private final Status status;
{code}

PluginResult.java method should return enum:
{code}
//public int getStatus() {
public Status getStatus() {
    return status;
}
{code}

Then the only places that actually need to use .ordinal() are those encoding methods in NativeToJsMessageQueue.java. For example:
{code}
PluginResult.Status status = pluginResult.getStatus();
boolean noResult = status == PluginResult.Status.NO_RESULT;
boolean resultOk = status == PluginResult.Status.OK;
boolean keepCallback = pluginResult.getKeepCallback();

sb.append((noResult || resultOk) ? 'S' : 'F')
    .append(keepCallback ? '1' : '0')
    .append(status.ordinal())
    .append(' ')
...
{code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira