Skip to content

Commit

Permalink
Removed try/catch blocks from calls to valueForString on enums
Browse files Browse the repository at this point in the history
Signed-off-by: Mike Burke <[email protected]>
  • Loading branch information
Mike Burke committed Feb 18, 2015
1 parent 0f79215 commit 3028ec4
Show file tree
Hide file tree
Showing 52 changed files with 127 additions and 877 deletions.
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

0 comments on commit 3028ec4

Please sign in to comment.