Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enum improvements #118

Merged
merged 4 commits into from
Feb 23, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions sdl_android_lib/src/com/smartdevicelink/proxy/RPCResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
package com.smartdevicelink.proxy;

import java.util.Hashtable;

import com.smartdevicelink.proxy.rpc.enums.Result;
import com.smartdevicelink.util.DebugTool;

/**
* Result sent by SDL after an RPC is processed, consists of four parts:
Expand Down Expand Up @@ -130,13 +130,7 @@ public Result getResultCode() {
if (obj instanceof Result) {
return (Result) obj;
} else if (obj instanceof String) {
Result theCode = null;
try {
theCode = Result.valueForString((String) obj);
} catch (Exception e) {
DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + RPCResponse.KEY_RESULT_CODE, e);
}
return theCode;
return Result.valueForString((String) obj);
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import com.smartdevicelink.proxy.RPCStruct;
import com.smartdevicelink.proxy.rpc.enums.VehicleDataEventStatus;
import com.smartdevicelink.util.DebugTool;

public class AirbagStatus extends RPCStruct {
public static final String KEY_DRIVER_AIRBAG_DEPLOYED = "driverAirbagDeployed";
Expand Down Expand Up @@ -33,13 +32,7 @@ public VehicleDataEventStatus getDriverAirbagDeployed() {
if (obj instanceof VehicleDataEventStatus) {
return (VehicleDataEventStatus) obj;
} else if (obj instanceof String) {
VehicleDataEventStatus theCode = null;
try {
theCode = VehicleDataEventStatus.valueForString((String) obj);
} catch (Exception e) {
DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_DRIVER_AIRBAG_DEPLOYED, e);
}
return theCode;
return VehicleDataEventStatus.valueForString((String) obj);
}
return null;
}
Expand All @@ -55,13 +48,7 @@ public VehicleDataEventStatus getDriverSideAirbagDeployed() {
if (obj instanceof VehicleDataEventStatus) {
return (VehicleDataEventStatus) obj;
} else if (obj instanceof String) {
VehicleDataEventStatus theCode = null;
try {
theCode = VehicleDataEventStatus.valueForString((String) obj);
} catch (Exception e) {
DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_DRIVER_SIDE_AIRBAG_DEPLOYED, e);
}
return theCode;
return VehicleDataEventStatus.valueForString((String) obj);
}
return null;
}
Expand All @@ -77,13 +64,7 @@ public VehicleDataEventStatus getDriverCurtainAirbagDeployed() {
if (obj instanceof VehicleDataEventStatus) {
return (VehicleDataEventStatus) obj;
} else if (obj instanceof String) {
VehicleDataEventStatus theCode = null;
try {
theCode = VehicleDataEventStatus.valueForString((String) obj);
} catch (Exception e) {
DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_DRIVER_CURTAIN_AIRBAG_DEPLOYED, e);
}
return theCode;
return VehicleDataEventStatus.valueForString((String) obj);
}
return null;
}
Expand All @@ -99,13 +80,7 @@ public VehicleDataEventStatus getPassengerAirbagDeployed() {
if (obj instanceof VehicleDataEventStatus) {
return (VehicleDataEventStatus) obj;
} else if (obj instanceof String) {
VehicleDataEventStatus theCode = null;
try {
theCode = VehicleDataEventStatus.valueForString((String) obj);
} catch (Exception e) {
DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_PASSENGER_AIRBAG_DEPLOYED, e);
}
return theCode;
return VehicleDataEventStatus.valueForString((String) obj);
}
return null;
}
Expand All @@ -121,13 +96,7 @@ public VehicleDataEventStatus getPassengerCurtainAirbagDeployed() {
if (obj instanceof VehicleDataEventStatus) {
return (VehicleDataEventStatus) obj;
} else if (obj instanceof String) {
VehicleDataEventStatus theCode = null;
try {
theCode = VehicleDataEventStatus.valueForString((String) obj);
} catch (Exception e) {
DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_PASSENGER_CURTAIN_AIRBAG_DEPLOYED, e);
}
return theCode;
return VehicleDataEventStatus.valueForString((String) obj);
}
return null;
}
Expand All @@ -143,13 +112,7 @@ public VehicleDataEventStatus getDriverKneeAirbagDeployed() {
if (obj instanceof VehicleDataEventStatus) {
return (VehicleDataEventStatus) obj;
} else if (obj instanceof String) {
VehicleDataEventStatus theCode = null;
try {
theCode = VehicleDataEventStatus.valueForString((String) obj);
} catch (Exception e) {
DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_DRIVER_KNEE_AIRBAG_DEPLOYED, e);
}
return theCode;
return VehicleDataEventStatus.valueForString((String) obj);
}
return null;
}
Expand All @@ -165,13 +128,7 @@ public VehicleDataEventStatus getPassengerSideAirbagDeployed() {
if (obj instanceof VehicleDataEventStatus) {
return (VehicleDataEventStatus) obj;
} else if (obj instanceof String) {
VehicleDataEventStatus theCode = null;
try {
theCode = VehicleDataEventStatus.valueForString((String) obj);
} catch (Exception e) {
DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_PASSENGER_SIDE_AIRBAG_DEPLOYED, e);
}
return theCode;
return VehicleDataEventStatus.valueForString((String) obj);
}
return null;
}
Expand All @@ -187,13 +144,7 @@ public VehicleDataEventStatus getPassengerKneeAirbagDeployed() {
if (obj instanceof VehicleDataEventStatus) {
return (VehicleDataEventStatus) obj;
} else if (obj instanceof String) {
VehicleDataEventStatus theCode = null;
try {
theCode = VehicleDataEventStatus.valueForString((String) obj);
} catch (Exception e) {
DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_PASSENGER_KNEE_AIRBAG_DEPLOYED, e);
}
return theCode;
return VehicleDataEventStatus.valueForString((String) obj);
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.smartdevicelink.proxy.rpc.enums.AudioType;
import com.smartdevicelink.proxy.rpc.enums.BitsPerSample;
import com.smartdevicelink.proxy.rpc.enums.SamplingRate;
import com.smartdevicelink.util.DebugTool;

/**
* Describes different audio type configurations for PerformAudioPassThru, e.g. {8kHz,8-bit,PCM}
Expand Down Expand Up @@ -81,13 +80,7 @@ public SamplingRate getSamplingRate() {
if (obj instanceof SamplingRate) {
return (SamplingRate) obj;
} else if (obj instanceof String) {
SamplingRate theCode = null;
try {
theCode = SamplingRate.valueForString((String) obj);
} catch (Exception e) {
DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_SAMPLING_RATE, e);
}
return theCode;
return SamplingRate.valueForString((String) obj);
}
return null;
}
Expand All @@ -113,13 +106,7 @@ public BitsPerSample getBitsPerSample() {
if (obj instanceof BitsPerSample) {
return (BitsPerSample) obj;
} else if (obj instanceof String) {
BitsPerSample theCode = null;
try {
theCode = BitsPerSample.valueForString((String) obj);
} catch (Exception e) {
DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_BITS_PER_SAMPLE, e);
}
return theCode;
return BitsPerSample.valueForString((String) obj);
}
return null;
}
Expand All @@ -145,13 +132,7 @@ public AudioType getAudioType() {
if (obj instanceof AudioType) {
return (AudioType) obj;
} else if (obj instanceof String) {
AudioType theCode = null;
try {
theCode = AudioType.valueForString((String) obj);
} catch (Exception e) {
DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_AUDIO_TYPE, e);
}
return theCode;
return AudioType.valueForString((String) obj);
}
return null;
}
Expand Down
Loading