diff options
author | Markos Rapitis <mrapitis@ford.com> | 2015-08-12 09:29:13 -0400 |
---|---|---|
committer | Markos Rapitis <mrapitis@ford.com> | 2015-08-12 09:29:13 -0400 |
commit | 7c334095a2653a2d2f9d13c0994f0836d8ce9290 (patch) | |
tree | 946bf367507698137b5d7d5344bdb692884e9bf2 | |
parent | c32603cc2ce187c4c120270b57077bf1b33c7b20 (diff) | |
parent | d8afcf22414fd5e2afe2fa8f255a83291f707d33 (diff) | |
download | sdl_android-7c334095a2653a2d2f9d13c0994f0836d8ce9290.tar.gz |
Merge branch 'github/develop' into feature/UpdatedDocs
37 files changed, 633 insertions, 2846 deletions
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/RPCRequestFactory.java b/sdl_android_lib/src/com/smartdevicelink/proxy/RPCRequestFactory.java index 6a6b628a4..2bce96d86 100644 --- a/sdl_android_lib/src/com/smartdevicelink/proxy/RPCRequestFactory.java +++ b/sdl_android_lib/src/com/smartdevicelink/proxy/RPCRequestFactory.java @@ -77,10 +77,6 @@ public class RPCRequestFactory { if(data == null) return null;
- for (String item : data) {
- if (item == null) return null;
- }
-
SystemRequest msg = new SystemRequest(true);
msg.setCorrelationID(correlationID);
msg.setLegacyData(data);
@@ -94,22 +90,7 @@ public class RPCRequestFactory { AddCommand msg = new AddCommand();
msg.setCorrelationID(correlationID);
msg.setCmdID(commandID);
-
- if (vrCommands != null) {
- boolean isValid = true;
- for (String item : vrCommands) {
- if (item == null) {
- msg.setVrCommands(null);
- isValid = false;
- }
- }
- if (isValid) {
- msg.setVrCommands(vrCommands);
- }
- } else {
- msg.setVrCommands(null);
- }
-
+ msg.setVrCommands(vrCommands);
if (cmdIcon != null) msg.setCmdIcon(cmdIcon);
@@ -131,20 +112,7 @@ public class RPCRequestFactory { msg.setCorrelationID(correlationID);
msg.setCmdID(commandID);
- if (vrCommands != null) {
- boolean isValid = true;
- for (String item : vrCommands) {
- if (item == null) {
- msg.setVrCommands(null);
- isValid = false;
- }
- }
- if (isValid) {
- msg.setVrCommands(vrCommands);
- }
- } else {
- msg.setVrCommands(null);
- }
+ if (vrCommands != null) msg.setVrCommands(vrCommands);
Image cmdIcon = null;
@@ -175,21 +143,7 @@ public class RPCRequestFactory { AddCommand msg = new AddCommand();
msg.setCorrelationID(correlationID);
msg.setCmdID(commandID);
-
- if (vrCommands != null) {
- boolean isValid = true;
- for (String item : vrCommands) {
- if (item == null) {
- msg.setVrCommands(null);
- isValid = false;
- }
- }
- if (isValid) {
- msg.setVrCommands(vrCommands);
- }
- } else {
- msg.setVrCommands(null);
- }
+ msg.setVrCommands(vrCommands);
if(menuText != null || parentID != null || position != null) {
MenuParams menuParams = new MenuParams();
@@ -214,21 +168,7 @@ public class RPCRequestFactory { AddCommand msg = new AddCommand();
msg.setCorrelationID(correlationID);
msg.setCmdID(commandID);
-
- if (vrCommands != null) {
- boolean isValid = true;
- for (String item : vrCommands) {
- if (item == null) {
- msg.setVrCommands(null);
- isValid = false;
- }
- }
- if (isValid) {
- msg.setVrCommands(vrCommands);
- }
- } else {
- msg.setVrCommands(null);
- }
+ msg.setVrCommands(vrCommands);
return msg;
}
@@ -293,40 +233,14 @@ public class RPCRequestFactory { msg.setAlertText3(alertText3);
msg.setDuration(duration);
msg.setPlayTone(playTone);
-
- if (ttsChunks != null) {
- boolean isValid = true;
- for (TTSChunk item : ttsChunks) {
- if (item == null) {
- msg.setTtsChunks(null);
- isValid = false;
- }
- }
- if (isValid) {
- msg.setTtsChunks(ttsChunks);
- }
- } else {
- msg.setTtsChunks(null);
- }
-
- if (softButtons != null) {
- boolean isValid = true;
- for (SoftButton item : softButtons) {
- if (item == null) {
- msg.setSoftButtons(null);
- isValid = false;
- }
- }
- if (isValid) {
- msg.setTtsChunks(ttsChunks);
- }
- } else {
- msg.setSoftButtons(null);
- }
+ msg.setTtsChunks(ttsChunks);
+ msg.setSoftButtons(softButtons);
return msg;
}
+
+
public static Alert buildAlert(String ttsText, Boolean playTone,
Integer correlationID) {
Vector<TTSChunk> chunks = TTSChunkFactory
@@ -369,21 +283,7 @@ public class RPCRequestFactory { msg.setAlertText2(alertText2);
msg.setDuration(duration);
msg.setPlayTone(playTone);
-
- if (ttsChunks != null) {
- boolean isValid = true;
- for (TTSChunk item : ttsChunks) {
- if (item == null) {
- msg.setTtsChunks(null);
- isValid = false;
- }
- }
- if (isValid) {
- msg.setTtsChunks(ttsChunks);
- }
- } else {
- msg.setTtsChunks(null);
- }
+ msg.setTtsChunks(ttsChunks);
return msg;
}
@@ -392,24 +292,9 @@ public class RPCRequestFactory { Vector<Choice> choiceSet, Integer interactionChoiceSetID,
Integer correlationID) {
CreateInteractionChoiceSet msg = new CreateInteractionChoiceSet();
+ msg.setChoiceSet(choiceSet);
msg.setInteractionChoiceSetID(interactionChoiceSetID);
msg.setCorrelationID(correlationID);
-
- if (choiceSet != null) {
- boolean isValid = true;
- for (Choice item : choiceSet) {
- if (item == null) {
- msg.setChoiceSet(null);
- isValid = false;
- }
- }
- if (isValid) {
- msg.setChoiceSet(choiceSet);
- }
- } else {
- msg.setChoiceSet(null);
- }
-
return msg;
}
@@ -461,86 +346,16 @@ public class RPCRequestFactory { InteractionMode interactionMode, Integer timeout, Vector<VrHelpItem> vrHelp,
Integer correlationID) {
PerformInteraction msg = new PerformInteraction();
+ msg.setInitialPrompt(initChunks);
msg.setInitialText(displayText);
+ msg.setInteractionChoiceSetIDList(interactionChoiceSetIDList);
msg.setInteractionMode(interactionMode);
msg.setTimeout(timeout);
+ msg.setHelpPrompt(helpChunks);
+ msg.setTimeoutPrompt(timeoutChunks);
+ msg.setVrHelp(vrHelp);
msg.setCorrelationID(correlationID);
- if (interactionChoiceSetIDList != null) {
- boolean isValid = true;
- for (Integer item : interactionChoiceSetIDList) {
- if (item == null) {
- msg.setInteractionChoiceSetIDList(null);
- isValid = false;
- }
- }
- if (isValid) {
- msg.setInteractionChoiceSetIDList(interactionChoiceSetIDList);
- }
- } else {
- msg.setInteractionChoiceSetIDList(null);
- }
-
- if (vrHelp != null) {
- boolean isValid = true;
- for (VrHelpItem item : vrHelp) {
- if (item == null) {
- msg.setVrHelp(null);
- isValid = false;
- }
- }
- if (isValid) {
- msg.setVrHelp(vrHelp);
- }
- } else {
- msg.setVrHelp(null);
- }
-
- if (timeoutChunks != null) {
- boolean isValid = true;
- for (TTSChunk item : timeoutChunks) {
- if (item == null) {
- msg.setTimeoutPrompt(null);
- isValid = false;
- }
- }
- if (isValid) {
- msg.setTimeoutPrompt(timeoutChunks);
- }
- } else {
- msg.setTimeoutPrompt(null);
- }
-
- if (initChunks != null) {
- boolean isValid = true;
- for (TTSChunk item : initChunks) {
- if (item == null) {
- msg.setInitialPrompt(null);
- isValid = false;
- }
- }
- if (isValid) {
- msg.setInitialPrompt(initChunks);
- }
- } else {
- msg.setInitialPrompt(null);
- }
-
- if (helpChunks != null) {
- boolean isValid = true;
- for (TTSChunk item : helpChunks) {
- if (item == null) {
- msg.setHelpPrompt(null);
- isValid = false;
- }
- }
- if (isValid) {
- msg.setHelpPrompt(helpChunks);
- }
- } else {
- msg.setHelpPrompt(null);
- }
-
return msg;
}
@@ -593,71 +408,15 @@ public class RPCRequestFactory { InteractionMode interactionMode, Integer timeout,
Integer correlationID) {
PerformInteraction msg = new PerformInteraction();
+ msg.setInitialPrompt(initChunks);
msg.setInitialText(displayText);
+ msg.setInteractionChoiceSetIDList(interactionChoiceSetIDList);
msg.setInteractionMode(interactionMode);
msg.setTimeout(timeout);
+ msg.setHelpPrompt(helpChunks);
+ msg.setTimeoutPrompt(timeoutChunks);
msg.setCorrelationID(correlationID);
- if (interactionChoiceSetIDList != null) {
- boolean isValid = true;
- for (Integer item : interactionChoiceSetIDList) {
- if (item == null) {
- msg.setInteractionChoiceSetIDList(null);
- isValid = false;
- }
- }
- if (isValid) {
- msg.setInteractionChoiceSetIDList(interactionChoiceSetIDList);
- }
- } else {
- msg.setInteractionChoiceSetIDList(null);
- }
-
- if (timeoutChunks != null) {
- boolean isValid = true;
- for (TTSChunk item : timeoutChunks) {
- if (item == null) {
- msg.setTimeoutPrompt(null);
- isValid = false;
- }
- }
- if (isValid) {
- msg.setTimeoutPrompt(timeoutChunks);
- }
- } else {
- msg.setTimeoutPrompt(null);
- }
-
- if (initChunks != null) {
- boolean isValid = true;
- for (TTSChunk item : initChunks) {
- if (item == null) {
- msg.setInitialPrompt(null);
- isValid = false;
- }
- }
- if (isValid) {
- msg.setInitialPrompt(initChunks);
- }
- } else {
- msg.setInitialPrompt(null);
- }
-
- if (helpChunks != null) {
- boolean isValid = true;
- for (TTSChunk item : helpChunks) {
- if (item == null) {
- msg.setHelpPrompt(null);
- isValid = false;
- }
- }
- if (isValid) {
- msg.setHelpPrompt(helpChunks);
- }
- } else {
- msg.setHelpPrompt(null);
- }
-
return msg;
}
@@ -716,52 +475,6 @@ public class RPCRequestFactory { msg.setTimeout(timeout);
msg.setHelpPrompt(helpChunks);
msg.setCorrelationID(correlationID);
-
- if (interactionChoiceSetIDList != null) {
- boolean isValid = true;
- for (Integer item : interactionChoiceSetIDList) {
- if (item == null) {
- msg.setInteractionChoiceSetIDList(null);
- isValid = false;
- }
- }
- if (isValid) {
- msg.setInteractionChoiceSetIDList(interactionChoiceSetIDList);
- }
- } else {
- msg.setInteractionChoiceSetIDList(null);
- }
-
- if (initChunks != null) {
- boolean isValid = true;
- for (TTSChunk item : initChunks) {
- if (item == null) {
- msg.setInitialPrompt(null);
- isValid = false;
- }
- }
- if (isValid) {
- msg.setInitialPrompt(initChunks);
- }
- } else {
- msg.setInitialPrompt(null);
- }
-
- if (helpChunks != null) {
- boolean isValid = true;
- for (TTSChunk item : helpChunks) {
- if (item == null) {
- msg.setHelpPrompt(null);
- isValid = false;
- }
- }
- if (isValid) {
- msg.setHelpPrompt(helpChunks);
- }
- } else {
- msg.setHelpPrompt(null);
- }
-
return msg;
}
@@ -896,20 +609,7 @@ public class RPCRequestFactory { msg.setAppName(appName);
- if (ttsName != null) {
- boolean isValid = true;
- for (TTSChunk item : ttsName) {
- if (item == null) {
- msg.setTtsName(null);
- isValid = false;
- }
- }
- if (isValid) {
- msg.setTtsName(ttsName);
- }
- } else {
- msg.setTtsName(null);
- }
+ msg.setTtsName(ttsName);
if (ngnMediaScreenAppName == null) {
ngnMediaScreenAppName = appName;
@@ -917,20 +617,11 @@ public class RPCRequestFactory { msg.setNgnMediaScreenAppName(ngnMediaScreenAppName);
- if (vrSynonyms != null) {
- boolean isValid = true;
- for (String item : vrSynonyms) {
- if (item == null) {
- msg.setVrSynonyms(new Vector<String>());
- isValid = false;
- }
- }
- if (isValid) {
- msg.setVrSynonyms(vrSynonyms);
- }
- } else {
- msg.setVrSynonyms(new Vector<String>());
+ if (vrSynonyms == null) {
+ vrSynonyms = new Vector<String>();
+ vrSynonyms.add(appName);
}
+ msg.setVrSynonyms(vrSynonyms);
msg.setIsMediaApplication(isMediaApp);
@@ -945,20 +636,7 @@ public class RPCRequestFactory { msg.setHmiDisplayLanguageDesired(hmiDisplayLanguageDesired);
- if (appType != null) {
- boolean isValid = true;
- for (AppHMIType item : appType) {
- if (item == null) {
- msg.setAppHMIType(null);
- isValid = false;
- }
- }
- if (isValid) {
- msg.setAppHMIType(appType);
- }
- } else {
- msg.setAppHMIType(null);
- }
+ msg.setAppHMIType(appType);
msg.setAppID(appID);
@@ -985,36 +663,9 @@ public class RPCRequestFactory { Integer correlationID) {
SetGlobalProperties req = new SetGlobalProperties();
req.setCorrelationID(correlationID);
-
- if (helpChunks != null) {
- boolean isValid = true;
- for (TTSChunk item : helpChunks) {
- if (item == null) {
- req.setHelpPrompt(null);
- isValid = false;
- }
- }
- if (isValid) {
- req.setHelpPrompt(helpChunks);
- }
- } else {
- req.setHelpPrompt(null);
- }
-
- if (timeoutChunks != null) {
- boolean isValid = true;
- for (TTSChunk item : timeoutChunks) {
- if (item == null) {
- req.setTimeoutPrompt(null);
- isValid = false;
- }
- }
- if (isValid) {
- req.setTimeoutPrompt(timeoutChunks);
- }
- } else {
- req.setTimeoutPrompt(null);
- }
+
+ req.setHelpPrompt(helpChunks);
+ req.setTimeoutPrompt(timeoutChunks);
return req;
}
@@ -1036,53 +687,11 @@ public class RPCRequestFactory { SetGlobalProperties req = new SetGlobalProperties();
req.setCorrelationID(correlationID);
- if (helpChunks != null) {
- boolean isValid = true;
- for (TTSChunk item : helpChunks) {
- if (item == null) {
- req.setHelpPrompt(null);
- isValid = false;
- }
- }
- if (isValid) {
- req.setHelpPrompt(helpChunks);
- }
- } else {
- req.setHelpPrompt(null);
- }
-
- if (timeoutChunks != null) {
- boolean isValid = true;
- for (TTSChunk item : timeoutChunks) {
- if (item == null) {
- req.setTimeoutPrompt(null);
- isValid = false;
- }
- }
- if (isValid) {
- req.setTimeoutPrompt(timeoutChunks);
- }
- } else {
- req.setTimeoutPrompt(null);
- }
-
- req.setVrHelpTitle(vrHelpTitle);
+ req.setHelpPrompt(helpChunks);
+ req.setTimeoutPrompt(timeoutChunks);
+ req.setVrHelpTitle(vrHelpTitle);
req.setVrHelp(vrHelp);
- if (vrHelp != null) {
- boolean isValid = true;
- for (VrHelpItem item : vrHelp) {
- if (item == null) {
- req.setVrHelp(null);
- isValid = false;
- }
- }
- if (isValid) {
- req.setVrHelp(vrHelp);
- }
- } else {
- req.setVrHelp(null);
- }
return req;
}
@@ -1134,23 +743,9 @@ public class RPCRequestFactory { msg.setAlignment(alignment);
msg.setMainField3(mainText3);
msg.setMainField4(mainText4);
- msg.setGraphic(graphic);
- msg.setCustomPresets(customPresets);
-
- if (softButtons != null) {
- boolean isValid = true;
- for (SoftButton item : softButtons) {
- if (item == null) {
- msg.setSoftButtons(null);
- isValid = false;
- }
- }
- if (isValid) {
- msg.setSoftButtons(softButtons);
- }
- } else {
- msg.setSoftButtons(null);
- }
+ msg.setGraphic(graphic);
+ msg.setSoftButtons(softButtons);
+ msg.setCustomPresets(customPresets);
return msg;
}
@@ -1197,20 +792,7 @@ public class RPCRequestFactory { Speak msg = new Speak();
msg.setCorrelationID(correlationID);
- if (ttsChunks != null) {
- boolean isValid = true;
- for (TTSChunk item : ttsChunks) {
- if (item == null) {
- msg.setTtsChunks(null);
- isValid = false;
- }
- }
- if (isValid) {
- msg.setTtsChunks(ttsChunks);
- }
- } else {
- msg.setTtsChunks(null);
- }
+ msg.setTtsChunks(ttsChunks);
return msg;
}
@@ -1329,21 +911,7 @@ public class RPCRequestFactory { msg.setCorrelationID(correlationID);
msg.setScrollableMessageBody(scrollableMessageBody);
msg.setTimeout(timeout);
-
- if (softButtons != null) {
- boolean isValid = true;
- for (SoftButton item : softButtons) {
- if (item == null) {
- msg.setSoftButtons(null);
- isValid = false;
- }
- }
- if (isValid) {
- msg.setSoftButtons(softButtons);
- }
- } else {
- msg.setSoftButtons(null);
- }
+ msg.setSoftButtons(softButtons);
return msg;
}
@@ -1355,23 +923,9 @@ public class RPCRequestFactory { msg.setNumTicks(numTicks);
msg.setPosition(position);
msg.setSliderHeader(sliderHeader);
+ msg.setSliderFooter(sliderFooter);
msg.setTimeout(timeout);
- if (sliderFooter != null) {
- boolean isValid = true;
- for (String item : sliderFooter) {
- if (item == null) {
- msg.setSliderFooter(null);
- isValid = false;
- }
- }
- if (isValid) {
- msg.setSliderFooter(sliderFooter);
- }
- } else {
- msg.setSliderFooter(null);
- }
-
return msg;
}
@@ -1413,6 +967,7 @@ public class RPCRequestFactory { {
PerformAudioPassThru msg = new PerformAudioPassThru();
msg.setCorrelationID(correlationID);
+ msg.setInitialPrompt(initialPrompt);
msg.setAudioPassThruDisplayText1(audioPassThruDisplayText1);
msg.setAudioPassThruDisplayText2(audioPassThruDisplayText2);
msg.setSamplingRate(samplingRate);
@@ -1420,21 +975,6 @@ public class RPCRequestFactory { msg.setBitsPerSample(bitsPerSample);
msg.setAudioType(audioType);
msg.setMuteAudio(muteAudio);
-
- if (initialPrompt != null) {
- boolean isValid = true;
- for (TTSChunk item : initialPrompt) {
- if (item == null) {
- msg.setInitialPrompt(null);
- isValid = false;
- }
- }
- if (isValid) {
- msg.setInitialPrompt(initialPrompt);
- }
- } else {
- msg.setInitialPrompt(null);
- }
return msg;
}
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/AddCommand.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/AddCommand.java index c2ef59b86..9c91c7ee3 100644 --- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/AddCommand.java +++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/AddCommand.java @@ -192,12 +192,10 @@ public class AddCommand extends RPCRequest { if (parameters.get(KEY_VR_COMMANDS) instanceof List<?>) {
List<?> list = (List<?>)parameters.get(KEY_VR_COMMANDS);
if (list != null && list.size() > 0) {
- for( Object obj : list ) {
- if (!(obj instanceof String)) {
- return null;
- }
+ Object obj = list.get(0);
+ if (obj instanceof String) {
+ return (List<String>)list;
}
- return (List<String>) list;
}
}
return null;
@@ -220,16 +218,7 @@ public class AddCommand extends RPCRequest { * not zero-length, not whitespace only) element
*/
public void setVrCommands( List<String> vrCommands ) {
-
- boolean valid = true;
-
- for ( String item : vrCommands ) {
- if (item == null) {
- valid = false;
- }
- }
-
- if ( (vrCommands != null) && (vrCommands.size() > 0) && valid) {
+ if (vrCommands != null) {
parameters.put(KEY_VR_COMMANDS, vrCommands );
} else {
parameters.remove(KEY_VR_COMMANDS);
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/Alert.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/Alert.java index 973dc281d..02ee592a4 100644 --- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/Alert.java +++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/Alert.java @@ -257,43 +257,16 @@ public class Alert extends RPCRequest { if (parameters.get(KEY_TTS_CHUNKS) instanceof List<?>) {
List<?> list = (List<?>)parameters.get(KEY_TTS_CHUNKS);
if (list != null && list.size() > 0) {
-
- List<TTSChunk> ttsChunkList = new ArrayList<TTSChunk>();
-
- boolean flagRaw = false;
- boolean flagHash = false;
-
- for ( Object obj : list ) {
-
- // This does not currently allow for a mixing of types, meaning
- // there cannot be a raw TTSChunk and a Hashtable value in the
- // same same list. It will not be considered valid currently.
- if (obj instanceof TTSChunk) {
- if (flagHash) {
- return null;
- }
-
- flagRaw = true;
-
- } else if (obj instanceof Hashtable) {
- if (flagRaw) {
- return null;
- }
-
- flagHash = true;
- ttsChunkList.add(new TTSChunk((Hashtable<String, Object>) obj));
-
- } else {
- return null;
- }
-
- }
-
- if (flagRaw) {
- return (List<TTSChunk>) list;
- } else if (flagHash) {
- return ttsChunkList;
- }
+ Object obj = list.get(0);
+ if (obj instanceof TTSChunk) {
+ return (List<TTSChunk>) list;
+ } else if (obj instanceof Hashtable) {
+ List<TTSChunk> newList = new ArrayList<TTSChunk>();
+ for (Object hashObj : list) {
+ newList.add(new TTSChunk((Hashtable<String, Object>)hashObj));
+ }
+ return newList;
+ }
}
}
return null;
@@ -307,16 +280,7 @@ public class Alert extends RPCRequest { * <b>Notes: </b>Array must have a least one element
*/
public void setTtsChunks(List<TTSChunk> ttsChunks) {
-
- boolean valid = true;
-
- for ( TTSChunk item : ttsChunks ) {
- if (item == null) {
- valid = false;
- }
- }
-
- if ( (ttsChunks != null) && (ttsChunks.size() > 0) && valid) {
+ if (ttsChunks != null) {
parameters.put(KEY_TTS_CHUNKS, ttsChunks);
} else {
parameters.remove(KEY_TTS_CHUNKS);
@@ -394,43 +358,16 @@ public class Alert extends RPCRequest { if (parameters.get(KEY_SOFT_BUTTONS) instanceof List<?>) {
List<?> list = (List<?>)parameters.get(KEY_SOFT_BUTTONS);
if (list != null && list.size() > 0) {
-
- List<SoftButton> softButtonList = new ArrayList<SoftButton>();
-
- boolean flagRaw = false;
- boolean flagHash = false;
-
- for ( Object obj : list ) {
-
- // This does not currently allow for a mixing of types, meaning
- // there cannot be a raw SoftButton and a Hashtable value in the
- // same same list. It will not be considered valid currently.
- if (obj instanceof SoftButton) {
- if (flagHash) {
- return null;
- }
-
- flagRaw = true;
-
- } else if (obj instanceof Hashtable) {
- if (flagRaw) {
- return null;
- }
-
- flagHash = true;
- softButtonList.add(new SoftButton((Hashtable<String, Object>) obj));
-
- } else {
- return null;
- }
-
- }
-
- if (flagRaw) {
- return (List<SoftButton>) list;
- } else if (flagHash) {
- return softButtonList;
- }
+ Object obj = list.get(0);
+ if (obj instanceof SoftButton) {
+ return (List<SoftButton>) list;
+ } else if (obj instanceof Hashtable) {
+ List<SoftButton> newList = new ArrayList<SoftButton>();
+ for (Object hashObj : list) {
+ newList.add(new SoftButton((Hashtable<String, Object>)hashObj));
+ }
+ return newList;
+ }
}
}
return null;
@@ -453,16 +390,7 @@ public class Alert extends RPCRequest { */
public void setSoftButtons(List<SoftButton> softButtons) {
-
- boolean valid = true;
-
- for ( SoftButton item : softButtons ) {
- if (item == null) {
- valid = false;
- }
- }
-
- if ( (softButtons != null) && (softButtons.size() > 0) && valid) {
+ if (softButtons != null) {
parameters.put(KEY_SOFT_BUTTONS, softButtons);
} else {
parameters.remove(KEY_SOFT_BUTTONS);
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/AlertManeuver.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/AlertManeuver.java index 6bc897ae7..9aab52589 100644 --- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/AlertManeuver.java +++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/AlertManeuver.java @@ -54,43 +54,17 @@ public class AlertManeuver extends RPCRequest{ if(parameters.get(KEY_SOFT_BUTTONS) instanceof List<?>){ List<?> list = (List<?>) parameters.get(KEY_SOFT_BUTTONS); if(list != null && list.size() > 0){ - - List<SoftButton> softButtonList = new ArrayList<SoftButton>(); - - boolean flagRaw = false; - boolean flagHash = false; - - for ( Object obj : list ) { - - // This does not currently allow for a mixing of types, meaning - // there cannot be a raw SoftButton and a Hashtable value in the - // same same list. It will not be considered valid currently. - if (obj instanceof SoftButton) { - if (flagHash) { - return null; - } - - flagRaw = true; - - } else if (obj instanceof Hashtable) { - if (flagRaw) { - return null; - } - - flagHash = true; - softButtonList.add(new SoftButton((Hashtable<String, Object>) obj)); - - } else { - return null; - } - - } - - if (flagRaw) { - return (List<SoftButton>) list; - } else if (flagHash) { - return softButtonList; - } + Object obj = list.get(0); + if(obj instanceof SoftButton){ + return (List<SoftButton>) list; + } + else if(obj instanceof Hashtable){ + List<SoftButton> newList = new ArrayList<SoftButton>(); + for(Object hashObj : list){ + newList.add(new SoftButton((Hashtable<String, Object>) hashObj)); + } + return newList; + } } } return null; @@ -112,16 +86,7 @@ public class AlertManeuver extends RPCRequest{ */ public void setSoftButtons(List<SoftButton> softButtons){ - - boolean valid = true; - - for ( SoftButton item : softButtons ) { - if (item == null) { - valid = false; - } - } - - if ( (softButtons != null) && (softButtons.size() > 0) && valid) { + if(softButtons != null){ parameters.put(KEY_SOFT_BUTTONS, softButtons); } else{ @@ -139,43 +104,17 @@ public class AlertManeuver extends RPCRequest{ if(parameters.get(KEY_TTS_CHUNKS) instanceof List<?>){ List<?> list = (List<?>) parameters.get(KEY_TTS_CHUNKS); if(list != null && list.size() > 0){ - - List<TTSChunk> ttsChunkList = new ArrayList<TTSChunk>(); - - boolean flagRaw = false; - boolean flagHash = false; - - for ( Object obj : list ) { - - // This does not currently allow for a mixing of types, meaning - // there cannot be a raw TTSChunk and a Hashtable value in the - // same same list. It will not be considered valid currently. - if (obj instanceof TTSChunk) { - if (flagHash) { - return null; - } - - flagRaw = true; - - } else if (obj instanceof Hashtable) { - if (flagRaw) { - return null; - } - - flagHash = true; - ttsChunkList.add(new TTSChunk((Hashtable<String, Object>) obj)); - - } else { - return null; - } - - } - - if (flagRaw) { - return (List<TTSChunk>) list; - } else if (flagHash) { - return ttsChunkList; - } + Object obj = list.get(0); + if(obj instanceof TTSChunk){ + return (List<TTSChunk>) list; + } + else if(obj instanceof Hashtable){ + List<TTSChunk> newList = new ArrayList<TTSChunk>(); + for(Object hashObj : list){ + newList.add(new TTSChunk((Hashtable<String, Object>) hashObj)); + } + return newList; + } } } return null; @@ -189,16 +128,7 @@ public class AlertManeuver extends RPCRequest{ * <b>Notes: </b>Array must have a least one element */ public void setTtsChunks(List<TTSChunk> ttsChunks){ - - boolean valid = true; - - for ( TTSChunk item : ttsChunks ) { - if (item == null) { - valid = false; - } - } - - if ( (ttsChunks != null) && (ttsChunks.size() > 0) && valid) { + if(ttsChunks != null){ parameters.put(KEY_TTS_CHUNKS, ttsChunks); } else{ diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ChangeRegistration.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ChangeRegistration.java index a9e7ea7b7..7877d7a2e 100644 --- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ChangeRegistration.java +++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ChangeRegistration.java @@ -236,16 +236,7 @@ public class ChangeRegistration extends RPCRequest { * @param ttsName The TTS name to set
*/
public void setTtsName(List<TTSChunk> ttsName){
-
- boolean valid = true;
-
- for ( TTSChunk item : ttsName ) {
- if (item == null) {
- valid = false;
- }
- }
-
- if ( (ttsName != null) && (ttsName.size() > 0) && valid) {
+ if(ttsName != null){
parameters.put(KEY_TTS_NAME, ttsName);
}
else{
@@ -263,43 +254,16 @@ public class ChangeRegistration extends RPCRequest { if (parameters.get(KEY_TTS_NAME) instanceof List<?>) {
List<?> list = (List<?>)parameters.get(KEY_TTS_NAME);
if (list != null && list.size() > 0) {
-
- List<TTSChunk> ttsChunkList = new ArrayList<TTSChunk>();
-
- boolean flagRaw = false;
- boolean flagHash = false;
-
- for ( Object obj : list ) {
-
- // This does not currently allow for a mixing of types, meaning
- // there cannot be a raw TTSChunk and a Hashtable value in the
- // same same list. It will not be considered valid currently.
- if (obj instanceof TTSChunk) {
- if (flagHash) {
- return null;
- }
-
- flagRaw = true;
-
- } else if (obj instanceof Hashtable) {
- if (flagRaw) {
- return null;
- }
-
- flagHash = true;
- ttsChunkList.add(new TTSChunk((Hashtable<String, Object>) obj));
-
- } else {
- return null;
- }
-
- }
-
- if (flagRaw) {
- return (List<TTSChunk>) list;
- } else if (flagHash) {
- return ttsChunkList;
- }
+ Object obj = list.get(0);
+ if (obj instanceof TTSChunk) {
+ return (List<TTSChunk>) list;
+ } else if (obj instanceof Hashtable) {
+ List<TTSChunk> newList = new ArrayList<TTSChunk>();
+ for (Object hashObj : list) {
+ newList.add(new TTSChunk((Hashtable<String, Object>)hashObj));
+ }
+ return newList;
+ }
}
}
return null;
@@ -316,14 +280,12 @@ public class ChangeRegistration extends RPCRequest { @SuppressWarnings("unchecked")
public List<String> getVrSynonyms() {
if (parameters.get(KEY_VR_SYNONYMS) instanceof List<?>) {
- List<?> list = (List<?>) parameters.get(KEY_VR_SYNONYMS);
- if (list != null && list.size() > 0) {
- for( Object obj : list ) {
- if (!(obj instanceof String)) {
- return null;
- }
- }
- return (List<String>) list;
+ List<?> list = (List<?>)parameters.get(KEY_VR_SYNONYMS);
+ if (list != null && list.size()>0) {
+ Object obj = list.get(0);
+ if (obj instanceof String) {
+ return (List<String>) list;
+ }
}
}
return null;
@@ -347,16 +309,7 @@ public class ChangeRegistration extends RPCRequest { * </ul>
*/
public void setVrSynonyms(List<String> vrSynonyms) {
-
- boolean valid = true;
-
- for ( String item : vrSynonyms ) {
- if (item == null) {
- valid = false;
- }
- }
-
- if ( (vrSynonyms != null) && (vrSynonyms.size() > 0) && valid) {
+ if (vrSynonyms != null) {
parameters.put(KEY_VR_SYNONYMS, vrSynonyms);
} else {
parameters.remove(KEY_VR_SYNONYMS);
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/Choice.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/Choice.java index 7448c8b25..ffb85760a 100644 --- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/Choice.java +++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/Choice.java @@ -124,12 +124,10 @@ public class Choice extends RPCStruct { if (store.get(KEY_VR_COMMANDS) instanceof List<?>) {
List<?> list = (List<?>)store.get( KEY_VR_COMMANDS);
if (list != null && list.size() > 0) {
- for( Object obj : list ) {
- if (!(obj instanceof String)) {
- return null;
- }
+ Object obj = list.get(0);
+ if (obj instanceof String) {
+ return (List<String>) list;
}
- return (List<String>) list;
}
}
return null;
@@ -140,16 +138,7 @@ public class Choice extends RPCStruct { * @since SmartDeviceLink 2.0
*/
public void setVrCommands(List<String> vrCommands) {
-
- boolean valid = true;
-
- for ( String item : vrCommands ) {
- if (item == null) {
- valid = false;
- }
- }
-
- if ( (vrCommands != null) && (vrCommands.size() > 0) && valid) {
+ if (vrCommands != null) {
store.put(KEY_VR_COMMANDS, vrCommands);
} else {
store.remove(KEY_VR_COMMANDS);
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/CreateInteractionChoiceSet.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/CreateInteractionChoiceSet.java index e51a138de..6dc9d1b74 100644 --- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/CreateInteractionChoiceSet.java +++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/CreateInteractionChoiceSet.java @@ -128,43 +128,16 @@ public class CreateInteractionChoiceSet extends RPCRequest { if (parameters.get(KEY_CHOICE_SET) instanceof List<?>) {
List<?> list = (List<?>)parameters.get(KEY_CHOICE_SET);
if (list != null && list.size() > 0) {
-
- List<Choice> choiceList = new ArrayList<Choice>();
-
- boolean flagRaw = false;
- boolean flagHash = false;
-
- for ( Object obj : list ) {
-
- // This does not currently allow for a mixing of types, meaning
- // there cannot be a raw SoftButton and a Hashtable value in the
- // same same list. It will not be considered valid currently.
- if (obj instanceof Choice) {
- if (flagHash) {
- return null;
- }
-
- flagRaw = true;
-
- } else if (obj instanceof Hashtable) {
- if (flagRaw) {
- return null;
- }
-
- flagHash = true;
- choiceList.add(new Choice((Hashtable<String, Object>) obj));
-
- } else {
- return null;
- }
-
- }
-
- if (flagRaw) {
- return (List<Choice>) list;
- } else if (flagHash) {
- return choiceList;
- }
+ Object obj = list.get(0);
+ if (obj instanceof Choice) {
+ return (List<Choice>) list;
+ } else if (obj instanceof Hashtable) {
+ List<Choice> newList = new ArrayList<Choice>();
+ for (Object hashObj : list) {
+ newList.add(new Choice((Hashtable<String, Object>)hashObj));
+ }
+ return newList;
+ }
}
}
return null;
@@ -179,16 +152,7 @@ public class CreateInteractionChoiceSet extends RPCRequest { * <b>Notes: </b>Min Value: 1; Max Value: 100
*/
public void setChoiceSet( List<Choice> choiceSet ) {
-
- boolean valid = true;
-
- for ( Choice item : choiceSet ) {
- if (item == null) {
- valid = false;
- }
- }
-
- if ( (choiceSet != null) && (choiceSet.size() > 0) && valid) {
+ if (choiceSet != null) {
parameters.put(KEY_CHOICE_SET, choiceSet );
} else {
parameters.remove(KEY_CHOICE_SET);
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DiagnosticMessage.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DiagnosticMessage.java index 320875e48..4bbeacb1a 100644 --- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DiagnosticMessage.java +++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DiagnosticMessage.java @@ -115,29 +115,18 @@ public class DiagnosticMessage extends RPCRequest { public List<Integer> getMessageData() {
if(parameters.get(KEY_MESSAGE_DATA) instanceof List<?>){
List<?> list = (List<?>)parameters.get(KEY_MESSAGE_DATA);
- if(list != null && list.size() > 0){
- for( Object obj : list ) {
- if (!(obj instanceof Integer)) {
- return null;
- }
+ if(list != null && list.size()>0){
+ Object obj = list.get(0);
+ if(obj instanceof Integer){
+ return (List<Integer>) list;
}
- return (List<Integer>) list;
}
}
return null;
}
public void setMessageData(List<Integer> messageData) {
-
- boolean valid = true;
-
- for ( Integer item : messageData ) {
- if (item == null) {
- valid = false;
- }
- }
-
- if ( (messageData != null) && (messageData.size() > 0) && valid) {
+ if (messageData != null) {
parameters.put(KEY_MESSAGE_DATA, messageData);
} else {
parameters.remove(KEY_MESSAGE_DATA);
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DiagnosticMessageResponse.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DiagnosticMessageResponse.java index 94c724e5a..8cb0bc8d4 100644 --- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DiagnosticMessageResponse.java +++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DiagnosticMessageResponse.java @@ -27,28 +27,17 @@ public class DiagnosticMessageResponse extends RPCResponse { if(parameters.get(KEY_MESSAGE_DATA_RESULT) instanceof List<?>){
List<?> list = (List<?>)parameters.get(KEY_MESSAGE_DATA_RESULT);
if(list != null && list.size()>0){
- for( Object obj : list ) {
- if (!(obj instanceof Integer)) {
- return null;
- }
+ Object obj = list.get(0);
+ if(obj instanceof Integer){
+ return (List<Integer>) list;
}
- return (List<Integer>) list;
}
}
return null;
}
public void setMessageDataResult(List<Integer> messageDataResult) {
-
- boolean valid = true;
-
- for ( Integer item : messageDataResult ) {
- if (item == null) {
- valid = false;
- }
- }
-
- if ( (messageDataResult != null) && (messageDataResult.size() > 0) && valid) {
+ if (messageDataResult != null) {
parameters.put(KEY_MESSAGE_DATA_RESULT, messageDataResult);
} else {
parameters.remove(KEY_MESSAGE_DATA_RESULT);
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DisplayCapabilities.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DisplayCapabilities.java index 198807558..e6b17cf24 100644 --- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DisplayCapabilities.java +++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DisplayCapabilities.java @@ -82,13 +82,7 @@ public class DisplayCapabilities extends RPCStruct { if (obj instanceof DisplayType) {
return (DisplayType) obj;
} else if (obj instanceof String) {
- DisplayType theCode = null;
- try {
- theCode = DisplayType.valueForString((String) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_DISPLAY_TYPE, e);
- }
- return theCode;
+ return DisplayType.valueForString((String) obj);
}
return null;
}
@@ -113,43 +107,16 @@ public class DisplayCapabilities extends RPCStruct { if (store.get(KEY_TEXT_FIELDS) instanceof List<?>) {
List<?> list = (List<?>)store.get(KEY_TEXT_FIELDS);
if (list != null && list.size() > 0) {
-
- List<TextField> textFieldList = new ArrayList<TextField>();
-
- boolean flagRaw = false;
- boolean flagHash = false;
-
- for ( Object obj : list ) {
-
- // This does not currently allow for a mixing of types, meaning
- // there cannot be a raw TextField and a Hashtable value in the
- // same same list. It will not be considered valid currently.
- if (obj instanceof TextField) {
- if (flagHash) {
- return null;
- }
-
- flagRaw = true;
-
- } else if (obj instanceof Hashtable) {
- if (flagRaw) {
- return null;
- }
-
- flagHash = true;
- textFieldList.add(new TextField((Hashtable<String, Object>) obj));
-
- } else {
- return null;
- }
-
- }
-
- if (flagRaw) {
- return (List<TextField>) list;
- } else if (flagHash) {
- return textFieldList;
- }
+ Object obj = list.get(0);
+ if (obj instanceof TextField) {
+ return (List<TextField>) list;
+ } else if (obj instanceof Hashtable) {
+ List<TextField> newList = new ArrayList<TextField>();
+ for (Object hashObj : list) {
+ newList.add(new TextField((Hashtable<String, Object>)hashObj));
+ }
+ return newList;
+ }
}
}
return null;
@@ -160,16 +127,7 @@ public class DisplayCapabilities extends RPCStruct { * @param textFields the List of textFields
*/
public void setTextFields( List<TextField> textFields ) {
-
- boolean valid = true;
-
- for ( TextField item : textFields ) {
- if (item == null) {
- valid = false;
- }
- }
-
- if ( (textFields != null) && (textFields.size() > 0) && valid) {
+ if (textFields != null) {
store.put(KEY_TEXT_FIELDS, textFields );
} else {
store.remove(KEY_TEXT_FIELDS);
@@ -183,59 +141,23 @@ public class DisplayCapabilities extends RPCStruct { if (store.get(KEY_IMAGE_FIELDS) instanceof List<?>) {
List<?> list = (List<?>)store.get(KEY_IMAGE_FIELDS);
if (list != null && list.size() > 0) {
-
- List<ImageField> imageFieldList = new ArrayList<ImageField>();
-
- boolean flagRaw = false;
- boolean flagHash = false;
-
- for ( Object obj : list ) {
-
- // This does not currently allow for a mixing of types, meaning
- // there cannot be a raw ImageField and a Hashtable value in the
- // same same list. It will not be considered valid currently.
- if (obj instanceof ImageField) {
- if (flagHash) {
- return null;
- }
-
- flagRaw = true;
-
- } else if (obj instanceof Hashtable) {
- if (flagRaw) {
- return null;
- }
-
- flagHash = true;
- imageFieldList.add(new ImageField((Hashtable<String, Object>) obj));
-
- } else {
- return null;
- }
-
- }
-
- if (flagRaw) {
- return (List<ImageField>) list;
- } else if (flagHash) {
- return imageFieldList;
- }
+ Object obj = list.get(0);
+ if (obj instanceof ImageField) {
+ return (List<ImageField>) list;
+ } else if (obj instanceof Hashtable) {
+ List<ImageField> newList = new ArrayList<ImageField>();
+ for (Object hashObj : list) {
+ newList.add(new ImageField((Hashtable<String, Object>)hashObj));
+ }
+ return newList;
+ }
}
}
return null;
}
public void setImageFields( List<ImageField> imageFields ) {
-
- boolean valid = true;
-
- for ( ImageField item : imageFields ) {
- if (item == null) {
- valid = false;
- }
- }
-
- if ( (imageFields != null) && (imageFields.size() > 0) && valid) {
+ if (imageFields != null) {
store.put(KEY_IMAGE_FIELDS, imageFields );
}
else
@@ -267,52 +189,20 @@ public class DisplayCapabilities extends RPCStruct { if (store.get(KEY_MEDIA_CLOCK_FORMATS) instanceof List<?>) {
List<?> list = (List<?>)store.get(KEY_MEDIA_CLOCK_FORMATS);
if (list != null && list.size() > 0) {
-
- List<MediaClockFormat> mediaClockFormatList = new ArrayList<MediaClockFormat>();
-
- boolean flagRaw = false;
- boolean flagHash = false;
-
- for ( Object obj : list ) {
-
- // This does not currently allow for a mixing of types, meaning
- // there cannot be a raw MediaClockFormat and a String value in the
- // same same list. It will not be considered valid currently.
- if (obj instanceof MediaClockFormat) {
- if (flagHash) {
- return null;
- }
-
- flagRaw = true;
-
- } else if (obj instanceof String) {
- if (flagRaw) {
- return null;
- }
-
- flagHash = true;
- String strFormat = (String) obj;
- MediaClockFormat toAdd = null;
- try {
- toAdd = MediaClockFormat.valueForString(strFormat);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse MediaClockFormat from " + getClass().getSimpleName() + "." + KEY_MEDIA_CLOCK_FORMATS, e);
- }
+ Object obj = list.get(0);
+ if (obj instanceof MediaClockFormat) {
+ return (List<MediaClockFormat>) list;
+ } else if (obj instanceof String) {
+ List<MediaClockFormat> newList = new ArrayList<MediaClockFormat>();
+ for (Object hashObj : list) {
+ String strFormat = (String)hashObj;
+ MediaClockFormat toAdd = MediaClockFormat.valueForString(strFormat);
if (toAdd != null) {
- mediaClockFormatList.add(toAdd);
+ newList.add(toAdd);
}
-
- } else {
- return null;
- }
-
- }
-
- if (flagRaw) {
- return (List<MediaClockFormat>) list;
- } else if (flagHash) {
- return mediaClockFormatList;
- }
+ }
+ return newList;
+ }
}
}
return null;
@@ -322,16 +212,7 @@ public class DisplayCapabilities extends RPCStruct { * @param mediaClockFormats the List of MediaClockFormat
*/
public void setMediaClockFormats( List<MediaClockFormat> mediaClockFormats ) {
-
- boolean valid = true;
-
- for ( MediaClockFormat item : mediaClockFormats ) {
- if (item == null) {
- valid = false;
- }
- }
-
- if ( (mediaClockFormats != null) && (mediaClockFormats.size() > 0) && valid) {
+ if (mediaClockFormats != null) {
store.put(KEY_MEDIA_CLOCK_FORMATS, mediaClockFormats );
} else {
store.remove(KEY_MEDIA_CLOCK_FORMATS);
@@ -365,28 +246,17 @@ public class DisplayCapabilities extends RPCStruct { if (store.get(KEY_TEMPLATES_AVAILABLE) instanceof List<?>) {
List<?> list = (List<?>)store.get( KEY_TEMPLATES_AVAILABLE);
if (list != null && list.size() > 0) {
- for( Object obj : list ) {
- if (!(obj instanceof String)) {
- return null;
- }
+ Object obj = list.get(0);
+ if (obj instanceof String) {
+ return (List<String>) list;
}
- return (List<String>) list;
}
}
return null;
}
public void setTemplatesAvailable(List<String> templatesAvailable) {
-
- boolean valid = true;
-
- for ( String item : templatesAvailable ) {
- if (item == null) {
- valid = false;
- }
- }
-
- if ( (templatesAvailable != null) && (templatesAvailable.size() > 0) && valid) {
+ if (templatesAvailable != null) {
store.put(KEY_TEMPLATES_AVAILABLE, templatesAvailable);
}
else
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/GetDTCsResponse.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/GetDTCsResponse.java index fcca3c606..b3c49b251 100644 --- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/GetDTCsResponse.java +++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/GetDTCsResponse.java @@ -29,28 +29,17 @@ public class GetDTCsResponse extends RPCResponse{ if(parameters.get(KEY_DTC) instanceof List<?>){
List<?> list = (List<?>) parameters.get(KEY_DTC);
if(list != null && list.size() > 0){
- for( Object obj : list ) {
- if (!(obj instanceof String)) {
- return null;
- }
- }
- return (List<String>) list;
+ Object obj = list.get(0);
+ if(obj instanceof String){
+ return (List<String>) list;
+ }
}
}
return null;
}
public void setDtc(List<String> dtc){
-
- boolean valid = true;
-
- for ( String item : dtc ) {
- if (item == null) {
- valid = false;
- }
- }
-
- if ( (dtc != null) && (dtc.size() > 0) && valid) {
+ if(dtc != null){
parameters.put(KEY_DTC, dtc);
}
else{
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/HMIPermissions.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/HMIPermissions.java index 63e22638b..bf9f6ca59 100644 --- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/HMIPermissions.java +++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/HMIPermissions.java @@ -6,7 +6,6 @@ import java.util.List; import com.smartdevicelink.proxy.RPCStruct;
import com.smartdevicelink.proxy.rpc.enums.HMILevel;
-import com.smartdevicelink.util.DebugTool;
/**
* Defining sets of HMI levels, which are permitted or prohibited for a given RPC.
* <p><b>Parameter List</b>
@@ -66,55 +65,21 @@ public class HMIPermissions extends RPCStruct { public List<HMILevel> getAllowed() {
if (store.get(KEY_ALLOWED) instanceof List<?>) {
List<?> list = (List<?>)store.get(KEY_ALLOWED);
- if (list != null && list.size() > 0) { -
- List<HMILevel> hmiLevelList = new ArrayList<HMILevel>();
-
- boolean flagRaw = false;
- boolean flagStr = false;
-
- for ( Object obj : list ) {
-
- // This does not currently allow for a mixing of types, meaning
- // there cannot be a raw HMILevel and a String value in the
- // same same list. It will not be considered valid currently.
- if (obj instanceof HMILevel) {
- if (flagStr) {
- return null;
- }
-
- flagRaw = true;
-
- } else if (obj instanceof String) {
- if (flagRaw) {
- return null;
- }
-
- flagStr = true;
-
- String strFormat = (String) obj;
- HMILevel toAdd = null;
- try {
- toAdd = HMILevel.valueForString(strFormat);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_ALLOWED, e);
- }
- + if (list != null && list.size() > 0) {
+ Object obj = list.get(0);
+ if (obj instanceof HMILevel) {
+ return (List<HMILevel>) list;
+ } else if (obj instanceof String) {
+ List<HMILevel> newList = new ArrayList<HMILevel>();
+ for (Object hashObj : list) {
+ String strFormat = (String)hashObj;
+ HMILevel toAdd = HMILevel.valueForString(strFormat);
if (toAdd != null) {
- hmiLevelList.add(toAdd);
+ newList.add(toAdd);
}
-
- } else {
- return null;
- }
-
- }
-
- if (flagRaw) {
- return (List<HMILevel>) list;
- } else if (flagStr) {
- return hmiLevelList;
- }
+ }
+ return newList;
+ }
}
}
return null;
@@ -125,16 +90,7 @@ public class HMIPermissions extends RPCStruct { * @param allowed HMI level that is permitted for this given RPC
*/
public void setAllowed(List<HMILevel> allowed) {
-
- boolean valid = true;
-
- for ( HMILevel item : allowed ) {
- if (item == null) {
- valid = false;
- }
- }
-
- if ( (allowed != null) && (allowed.size() > 0) && valid) {
+ if (allowed != null) {
store.put(KEY_ALLOWED, allowed);
} else {
store.remove(KEY_ALLOWED);
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ImageField.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ImageField.java index 9580a0d37..b2bb6304e 100644 --- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ImageField.java +++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ImageField.java @@ -87,71 +87,28 @@ public class ImageField extends RPCStruct { @SuppressWarnings("unchecked")
public List<FileType> getImageTypeSupported() {
if (store.get(KEY_IMAGE_TYPE_SUPPORTED) instanceof List<?>) {
- List<?> list = (List<?>)store.get(KEY_IMAGE_TYPE_SUPPORTED); - if (list != null && list.size() > 0) {
-
- List<FileType> fileTypeList = new ArrayList<FileType>();
-
- boolean flagRaw = false;
- boolean flagStr = false;
-
- for ( Object obj : list ) {
-
- // This does not currently allow for a mixing of types, meaning
- // there cannot be a raw FileType and a String value in the
- // same same list. It will not be considered valid currently.
- if (obj instanceof FileType) {
- if (flagStr) {
- return null;
- }
-
- flagRaw = true;
-
- } else if (obj instanceof String) {
- if (flagRaw) {
- return null;
- }
-
- flagStr = true;
-
- String strFormat = (String) obj;
- FileType theCode = null;
- try {
- theCode = FileType.valueForString(strFormat);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_IMAGE_TYPE_SUPPORTED, e);
- }
- if (theCode != null) {
- fileTypeList.add(theCode);
- }
-
- } else {
- return null;
- }
-
- }
-
- if (flagRaw) {
- return (List<FileType>) list;
- } else if (flagStr) {
- return fileTypeList;
- }
- } + List<?> list = (List<?>)store.get(KEY_IMAGE_TYPE_SUPPORTED);
+ if (list != null && list.size() > 0) {
+ Object obj = list.get(0);
+ if (obj instanceof FileType) {
+ return (List<FileType>) list;
+ } else if (obj instanceof String) {
+ List<FileType> newList = new ArrayList<FileType>();
+ for (Object hashObj : list) {
+ String strFormat = (String)hashObj;
+ FileType theCode = FileType.valueForString(strFormat);
+ if (theCode != null) {
+ newList.add(theCode);
+ }
+ }
+ return newList;
+ }
+ }
}
return null;
}
-
public void setImageTypeSupported( List<FileType> imageTypeSupported ) {
-
- boolean valid = true;
-
- for ( FileType item : imageTypeSupported ) {
- if (item == null) {
- valid = false;
- }
- }
-
- if ( (imageTypeSupported != null) && (imageTypeSupported.size() > 0) && valid) {
+ if (imageTypeSupported != null) {
store.put(KEY_IMAGE_TYPE_SUPPORTED, imageTypeSupported );
}
else {
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/KeyboardProperties.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/KeyboardProperties.java index f9b7ddee3..0d784016b 100644 --- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/KeyboardProperties.java +++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/KeyboardProperties.java @@ -148,28 +148,17 @@ public class KeyboardProperties extends RPCStruct { if (listObj instanceof List<?>) {
List<?> list = (List<?>) listObj;
if (list != null && list.size() > 0) {
- for( Object obj : list ) {
- if (!(obj instanceof String)) {
- return null;
- }
- }
- return (List<String>) list;
+ Object obj = list.get(0);
+ if (obj instanceof String) {
+ return (List<String>) list;
+ }
}
}
return null;
}
public void setLimitedCharacterList(List<String> limitedCharacterList) {
-
- boolean valid = true;
-
- for ( String item : limitedCharacterList ) {
- if (item == null) {
- valid = false;
- }
- }
-
- if ( (limitedCharacterList != null) && (limitedCharacterList.size() > 0) && valid) {
+ if (limitedCharacterList != null) {
store.put(KEY_LIMITED_CHARACTER_LIST, limitedCharacterList);
} else {
store.remove(KEY_LIMITED_CHARACTER_LIST);
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ListFilesResponse.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ListFilesResponse.java index 18c4ecd3b..2c7a62e3e 100644 --- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ListFilesResponse.java +++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ListFilesResponse.java @@ -24,35 +24,22 @@ public class ListFilesResponse extends RPCResponse { public ListFilesResponse(Hashtable<String, Object> hash) {
super(hash);
}
-
public void setFilenames(List<String> filenames) {
-
- boolean valid = true;
-
- for ( String item : filenames ) {
- if (item == null) {
- valid = false;
- }
- }
-
- if ( (filenames != null) && (filenames.size() > 0) && valid) {
+ if (filenames != null) {
parameters.put(KEY_FILENAMES, filenames);
} else {
parameters.remove(KEY_FILENAMES);
}
}
-
@SuppressWarnings("unchecked")
public List<String> getFilenames() {
if (parameters.get(KEY_FILENAMES) instanceof List<?>) {
List<?> list = (List<?>)parameters.get(KEY_FILENAMES);
- if (list != null && list.size() > 0) {
- for( Object obj : list ) {
- if (!(obj instanceof String)) {
- return null;
- }
+ if (list != null && list.size()>0) {
+ Object obj = list.get(0);
+ if (obj instanceof String) {
+ return (List<String>) list;
}
- return (List<String>) list;
}
}
return null;
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnPermissionsChange.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnPermissionsChange.java index bb1ca7ca5..4c88c9baa 100644 --- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnPermissionsChange.java +++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnPermissionsChange.java @@ -71,43 +71,16 @@ public class OnPermissionsChange extends RPCNotification { public List<PermissionItem> getPermissionItem() {
List<?> list = (List<?>)parameters.get(KEY_PERMISSION_ITEM);
if (list != null && list.size()>0) {
-
- List<PermissionItem> permissionItemList = new ArrayList<PermissionItem>();
-
- boolean flagRaw = false;
- boolean flagHash = false;
-
- for ( Object obj : list ) {
-
- // This does not currently allow for a mixing of types, meaning
- // there cannot be a raw PermissionItem and a Hashtable value in the
- // same same list. It will not be considered valid currently.
- if (obj instanceof PermissionItem) {
- if (flagHash) {
- return null;
- }
-
- flagRaw = true;
-
- } else if (obj instanceof Hashtable) {
- if (flagRaw) {
- return null;
- }
-
- flagHash = true;
- permissionItemList.add(new PermissionItem((Hashtable<String, Object>) obj));
-
- } else {
- return null;
- }
-
- }
-
- if (flagRaw) {
- return (List<PermissionItem>) list;
- } else if (flagHash) {
- return permissionItemList;
- }
+ Object obj = list.get(0);
+ if(obj instanceof PermissionItem){
+ return (List<PermissionItem>) list;
+ } else if(obj instanceof Hashtable) {
+ List<PermissionItem> newList = new ArrayList<PermissionItem>();
+ for (Object hash:list) {
+ newList.add(new PermissionItem((Hashtable<String, Object>)hash));
+ }
+ return newList;
+ }
}
return null;
}
@@ -116,16 +89,7 @@ public class OnPermissionsChange extends RPCNotification { * @param permissionItem an List of PermissionItem describing change in permissions for a given set of RPCs
*/
public void setPermissionItem(List<PermissionItem> permissionItem) {
-
- boolean valid = true;
-
- for ( PermissionItem item : permissionItem ) {
- if (item == null) {
- valid = false;
- }
- }
-
- if ( (permissionItem != null) && (permissionItem.size() > 0) && valid) {
+ if (permissionItem != null) {
parameters.put(KEY_PERMISSION_ITEM, permissionItem);
} else {
parameters.remove(KEY_PERMISSION_ITEM);
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnSystemRequest.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnSystemRequest.java index 88e8fc2ba..7776a6916 100644 --- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnSystemRequest.java +++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnSystemRequest.java @@ -189,12 +189,10 @@ public class OnSystemRequest extends RPCNotification { if (parameters.get(KEY_DATA) instanceof List<?>) {
List<?> list = (List<?>)parameters.get(KEY_DATA);
if (list != null && list.size()>0) {
- for( Object obj : list ) {
- if (!(obj instanceof String)) {
- return null;
- }
+ Object obj = list.get(0);
+ if (obj instanceof String) {
+ return (List<String>)list;
}
- return (List<String>) list;
}
}
return null;
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnTouchEvent.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnTouchEvent.java index 9905675f7..8e6969d95 100644 --- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnTouchEvent.java +++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnTouchEvent.java @@ -87,16 +87,7 @@ public class OnTouchEvent extends RPCNotification { }
public void setEvent(List<TouchEvent> event) {
-
- boolean valid = true;
-
- for ( TouchEvent item : event ) {
- if (item == null) {
- valid = false;
- }
- }
-
- if ( (event != null) && (event.size() > 0) && valid) {
+ if (event != null) {
parameters.put(KEY_EVENT, event);
} else {
parameters.remove(KEY_EVENT);
@@ -108,43 +99,16 @@ public class OnTouchEvent extends RPCNotification { if (parameters.get(KEY_EVENT) instanceof List<?>) {
List<?> list = (List<?>)parameters.get(KEY_EVENT);
if (list != null && list.size() > 0) {
-
- List<TouchEvent> touchEventList = new ArrayList<TouchEvent>();
-
- boolean flagRaw = false;
- boolean flagHash = false;
-
- for ( Object obj : list ) {
-
- // This does not currently allow for a mixing of types, meaning
- // there cannot be a raw TouchEvent and a Hashtable value in the
- // same same list. It will not be considered valid currently.
- if (obj instanceof TouchEvent) {
- if (flagHash) {
- return null;
- }
-
- flagRaw = true;
-
- } else if (obj instanceof Hashtable) {
- if (flagRaw) {
- return null;
- }
-
- flagHash = true;
- touchEventList.add(new TouchEvent((Hashtable<String, Object>) obj));
-
- } else {
- return null;
- }
-
- }
-
- if (flagRaw) {
- return (List<TouchEvent>) list;
- } else if (flagHash) {
- return touchEventList;
- }
+ Object obj = list.get(0);
+ if (obj instanceof TouchEvent) {
+ return (List<TouchEvent>) list;
+ } else if (obj instanceof Hashtable) {
+ List<TouchEvent> newList = new ArrayList<TouchEvent>();
+ for (Object hashObj : list) {
+ newList.add(new TouchEvent((Hashtable<String, Object>) hashObj));
+ }
+ return newList;
+ }
}
}
return null;
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ParameterPermissions.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ParameterPermissions.java index 9bacb6ab2..24ffdf4d8 100644 --- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ParameterPermissions.java +++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ParameterPermissions.java @@ -68,12 +68,10 @@ public class ParameterPermissions extends RPCStruct { if (store.get(KEY_ALLOWED) instanceof List<?>) {
List<?> list = (List<?>)store.get( KEY_ALLOWED);
if (list != null && list.size() > 0) {
- for( Object obj : list ) {
- if (!(obj instanceof String)) {
- return null;
- }
+ Object obj = list.get(0);
+ if (obj instanceof String) {
+ return (List<String>) list;
}
- return (List<String>) list;
}
}
return null;
@@ -84,16 +82,7 @@ public class ParameterPermissions extends RPCStruct { * @param allowed parameter that is permitted for this given RPC
*/
public void setAllowed(List<String> allowed) {
-
- boolean valid = true;
-
- for ( String item : allowed ) {
- if (item == null) {
- valid = false;
- }
- }
-
- if ( (allowed != null) && (allowed.size() > 0) && valid) {
+ if (allowed != null) {
store.put(KEY_ALLOWED, allowed);
} else {
store.remove(KEY_ALLOWED);
@@ -109,12 +98,10 @@ public class ParameterPermissions extends RPCStruct { if (store.get(KEY_USER_DISALLOWED) instanceof List<?>) {
List<?> list = (List<?>)store.get( KEY_USER_DISALLOWED);
if (list != null && list.size() > 0) {
- for( Object obj : list ) {
- if (!(obj instanceof String)) {
- return null;
- }
+ Object obj = list.get(0);
+ if (obj instanceof String) {
+ return (List<String>) list;
}
- return (List<String>) list;
}
}
return null;
@@ -125,16 +112,7 @@ public class ParameterPermissions extends RPCStruct { * @param userDisallowed paramter that is prohibited for this given RPC
*/
public void setUserDisallowed(List<String> userDisallowed) {
-
- boolean valid = true;
-
- for ( String item : userDisallowed ) {
- if (item == null) {
- valid = false;
- }
- }
-
- if ( (userDisallowed != null) && (userDisallowed.size() > 0) && valid) {
+ if (userDisallowed != null) {
store.put(KEY_USER_DISALLOWED, userDisallowed);
} else {
store.remove(KEY_USER_DISALLOWED);
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/PerformAudioPassThru.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/PerformAudioPassThru.java index 71b4d90b9..67085ea7d 100644 --- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/PerformAudioPassThru.java +++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/PerformAudioPassThru.java @@ -142,16 +142,7 @@ public class PerformAudioPassThru extends RPCRequest { * </ul>
*/
public void setInitialPrompt(List<TTSChunk> initialPrompt) {
-
- boolean valid = true;
-
- for ( TTSChunk item : initialPrompt ) {
- if (item == null) {
- valid = false;
- }
- }
-
- if ( (initialPrompt != null) && (initialPrompt.size() > 0) && valid) {
+ if (initialPrompt != null) {
parameters.put(KEY_INITIAL_PROMPT, initialPrompt);
} else {
parameters.remove(KEY_INITIAL_PROMPT);
@@ -171,43 +162,16 @@ public class PerformAudioPassThru extends RPCRequest { if (parameters.get(KEY_INITIAL_PROMPT) instanceof List<?>) {
List<?> list = (List<?>)parameters.get(KEY_INITIAL_PROMPT);
if (list != null && list.size() > 0) {
-
- List<TTSChunk> ttsChunkList = new ArrayList<TTSChunk>();
-
- boolean flagRaw = false;
- boolean flagHash = false;
-
- for ( Object obj : list ) {
-
- // This does not currently allow for a mixing of types, meaning
- // there cannot be a raw TTSChunk and a Hashtable value in the
- // same same list. It will not be considered valid currently.
- if (obj instanceof TTSChunk) {
- if (flagHash) {
- return null;
- }
-
- flagRaw = true;
-
- } else if (obj instanceof Hashtable) {
- if (flagRaw) {
- return null;
- }
-
- flagHash = true;
- ttsChunkList.add(new TTSChunk((Hashtable<String, Object>) obj));
-
- } else {
- return null;
- }
-
- }
-
- if (flagRaw) {
- return (List<TTSChunk>) list;
- } else if (flagHash) {
- return ttsChunkList;
- }
+ Object obj = list.get(0);
+ if (obj instanceof TTSChunk) {
+ return (List<TTSChunk>) list;
+ } else if (obj instanceof Hashtable) {
+ List<TTSChunk> newList = new ArrayList<TTSChunk>();
+ for (Object hashObj : list) {
+ newList.add(new TTSChunk((Hashtable<String, Object>)hashObj));
+ }
+ return newList;
+ }
}
}
return null;
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/PerformInteraction.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/PerformInteraction.java index c3c75f396..fc4154a2c 100644 --- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/PerformInteraction.java +++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/PerformInteraction.java @@ -174,43 +174,16 @@ public class PerformInteraction extends RPCRequest { if (parameters.get(KEY_INITIAL_PROMPT) instanceof List<?>) {
List<?> list = (List<?>)parameters.get(KEY_INITIAL_PROMPT);
if (list != null && list.size() > 0) {
-
- List<TTSChunk> ttsChunkList = new ArrayList<TTSChunk>();
-
- boolean flagRaw = false;
- boolean flagHash = false;
-
- for ( Object obj : list ) {
-
- // This does not currently allow for a mixing of types, meaning
- // there cannot be a raw TTSChunk and a Hashtable value in the
- // same same list. It will not be considered valid currently.
- if (obj instanceof TTSChunk) {
- if (flagHash) {
- return null;
- }
-
- flagRaw = true;
-
- } else if (obj instanceof Hashtable) {
- if (flagRaw) {
- return null;
- }
-
- flagHash = true;
- ttsChunkList.add(new TTSChunk((Hashtable<String, Object>) obj));
-
- } else {
- return null;
- }
-
- }
-
- if (flagRaw) {
- return (List<TTSChunk>) list;
- } else if (flagHash) {
- return ttsChunkList;
- }
+ Object obj = list.get(0);
+ if (obj instanceof TTSChunk) {
+ return (List<TTSChunk>) list;
+ } else if (obj instanceof Hashtable) {
+ List<TTSChunk> newList = new ArrayList<TTSChunk>();
+ for (Object hashObj : list) {
+ newList.add(new TTSChunk((Hashtable<String, Object>)hashObj));
+ }
+ return newList;
+ }
}
}
return null;
@@ -224,16 +197,7 @@ public class PerformInteraction extends RPCRequest { * user at the start of an interaction
*/
public void setInitialPrompt(List<TTSChunk> initialPrompt) {
-
- boolean valid = true;
-
- for ( TTSChunk item : initialPrompt ) {
- if (item == null) {
- valid = false;
- }
- }
-
- if ( (initialPrompt != null) && (initialPrompt.size() > 0) && valid) {
+ if (initialPrompt != null) {
parameters.put(KEY_INITIAL_PROMPT, initialPrompt);
} else {
parameters.remove(KEY_INITIAL_PROMPT);
@@ -285,12 +249,10 @@ public class PerformInteraction extends RPCRequest { if(parameters.get(KEY_INTERACTION_CHOICE_SET_ID_LIST) instanceof List<?>){
List<?> list = (List<?>)parameters.get(KEY_INTERACTION_CHOICE_SET_ID_LIST);
if(list != null && list.size()>0){
- for( Object obj : list ) {
- if (!(obj instanceof Integer)) {
- return null;
- }
+ Object obj = list.get(0);
+ if(obj instanceof Integer){
+ return (List<Integer>) list;
}
- return (List<Integer>) list;
}
}
return null;
@@ -307,16 +269,7 @@ public class PerformInteraction extends RPCRequest { * <b>Notes: </b>Min Value: 0; Max Vlaue: 2000000000
*/
public void setInteractionChoiceSetIDList(List<Integer> interactionChoiceSetIDList) {
-
- boolean valid = true;
-
- for ( Integer item : interactionChoiceSetIDList ) {
- if (item == null) {
- valid = false;
- }
- }
-
- if ( (interactionChoiceSetIDList != null) && (interactionChoiceSetIDList.size() > 0) && valid) {
+ if (interactionChoiceSetIDList != null) {
parameters.put(KEY_INTERACTION_CHOICE_SET_ID_LIST, interactionChoiceSetIDList);
} else {
parameters.remove(KEY_INTERACTION_CHOICE_SET_ID_LIST);
@@ -335,43 +288,16 @@ public class PerformInteraction extends RPCRequest { if(parameters.get(KEY_HELP_PROMPT) instanceof List<?>){
List<?> list = (List<?>)parameters.get(KEY_HELP_PROMPT);
if (list != null && list.size() > 0) {
-
- List<TTSChunk> ttsChunkList = new ArrayList<TTSChunk>();
-
- boolean flagRaw = false;
- boolean flagHash = false;
-
- for ( Object obj : list ) {
-
- // This does not currently allow for a mixing of types, meaning
- // there cannot be a raw TTSChunk and a Hashtable value in the
- // same same list. It will not be considered valid currently.
- if (obj instanceof TTSChunk) {
- if (flagHash) {
- return null;
- }
-
- flagRaw = true;
-
- } else if (obj instanceof Hashtable) {
- if (flagRaw) {
- return null;
- }
-
- flagHash = true;
- ttsChunkList.add(new TTSChunk((Hashtable<String, Object>) obj));
-
- } else {
- return null;
- }
-
- }
-
- if (flagRaw) {
- return (List<TTSChunk>) list;
- } else if (flagHash) {
- return ttsChunkList;
- }
+ Object obj = list.get(0);
+ if (obj instanceof TTSChunk) {
+ return (List<TTSChunk>) list;
+ } else if (obj instanceof Hashtable) {
+ List<TTSChunk> newList = new ArrayList<TTSChunk>();
+ for (Object hashObj : list) {
+ newList.add(new TTSChunk((Hashtable<String, Object>)hashObj));
+ }
+ return newList;
+ }
}
}
return null;
@@ -393,16 +319,7 @@ public class PerformInteraction extends RPCRequest { * session
*/
public void setHelpPrompt(List<TTSChunk> helpPrompt) {
-
- boolean valid = true;
-
- for ( TTSChunk item : helpPrompt ) {
- if (item == null) {
- valid = false;
- }
- }
-
- if ( (helpPrompt != null) && (helpPrompt.size() > 0) && valid) {
+ if (helpPrompt != null) {
parameters.put(KEY_HELP_PROMPT, helpPrompt);
} else {
parameters.remove(KEY_HELP_PROMPT);
@@ -420,43 +337,16 @@ public class PerformInteraction extends RPCRequest { if (parameters.get(KEY_TIMEOUT_PROMPT) instanceof List<?>) {
List<?> list = (List<?>)parameters.get(KEY_TIMEOUT_PROMPT);
if (list != null && list.size() > 0) {
-
- List<TTSChunk> ttsChunkList = new ArrayList<TTSChunk>();
-
- boolean flagRaw = false;
- boolean flagHash = false;
-
- for ( Object obj : list ) {
-
- // This does not currently allow for a mixing of types, meaning
- // there cannot be a raw TTSChunk and a Hashtable value in the
- // same same list. It will not be considered valid currently.
- if (obj instanceof TTSChunk) {
- if (flagHash) {
- return null;
- }
-
- flagRaw = true;
-
- } else if (obj instanceof Hashtable) {
- if (flagRaw) {
- return null;
- }
-
- flagHash = true;
- ttsChunkList.add(new TTSChunk((Hashtable<String, Object>) obj));
-
- } else {
- return null;
- }
-
- }
-
- if (flagRaw) {
- return (List<TTSChunk>) list;
- } else if (flagHash) {
- return ttsChunkList;
- }
+ Object obj = list.get(0);
+ if (obj instanceof TTSChunk) {
+ return (List<TTSChunk>) list;
+ } else if (obj instanceof Hashtable) {
+ List<TTSChunk> newList = new ArrayList<TTSChunk>();
+ for (Object hashObj : list) {
+ newList.add(new TTSChunk((Hashtable<String, Object>)hashObj));
+ }
+ return newList;
+ }
}
}
return null;
@@ -473,16 +363,7 @@ public class PerformInteraction extends RPCRequest { * listen times out during the VR session
*/
public void setTimeoutPrompt(List<TTSChunk> timeoutPrompt) {
-
- boolean valid = true;
-
- for ( TTSChunk item : timeoutPrompt ) {
- if (item == null) {
- valid = false;
- }
- }
-
- if ( (timeoutPrompt != null) && (timeoutPrompt.size() > 0) && valid) {
+ if (timeoutPrompt != null) {
parameters.put(KEY_TIMEOUT_PROMPT, timeoutPrompt);
} else {
parameters.remove(KEY_TIMEOUT_PROMPT);
@@ -536,43 +417,16 @@ public class PerformInteraction extends RPCRequest { if (parameters.get(KEY_VR_HELP) instanceof List<?>) {
List<?> list = (List<?>)parameters.get(KEY_VR_HELP);
if (list != null && list.size() > 0) {
-
- List<VrHelpItem> vrHelpItemList = new ArrayList<VrHelpItem>();
-
- boolean flagRaw = false;
- boolean flagHash = false;
-
- for ( Object obj : list ) {
-
- // This does not currently allow for a mixing of types, meaning
- // there cannot be a raw VrHelpItem and a Hashtable value in the
- // same same list. It will not be considered valid currently.
- if (obj instanceof VrHelpItem) {
- if (flagHash) {
- return null;
- }
-
- flagRaw = true;
-
- } else if (obj instanceof Hashtable) {
- if (flagRaw) {
- return null;
- }
-
- flagHash = true;
- vrHelpItemList.add(new VrHelpItem((Hashtable<String, Object>) obj));
-
- } else {
- return null;
- }
-
- }
-
- if (flagRaw) {
- return (List<VrHelpItem>) list;
- } else if (flagHash) {
- return vrHelpItemList;
- }
+ Object obj = list.get(0);
+ if (obj instanceof VrHelpItem) {
+ return (List<VrHelpItem>) list;
+ } else if (obj instanceof Hashtable) {
+ List<VrHelpItem> newList = new ArrayList<VrHelpItem>();
+ for (Object hashObj : list) {
+ newList.add(new VrHelpItem((Hashtable<String, Object>)hashObj));
+ }
+ return newList;
+ }
}
}
return null;
@@ -590,16 +444,7 @@ public class PerformInteraction extends RPCRequest { * @since SmartDeviceLink 2.0
*/
public void setVrHelp(List<VrHelpItem> vrHelp) {
-
- boolean valid = true;
-
- for ( VrHelpItem item : vrHelp ) {
- if (item == null) {
- valid = false;
- }
- }
-
- if ( (vrHelp != null) && (vrHelp.size() > 0) && valid) {
+ if (vrHelp != null) {
parameters.put(KEY_VR_HELP, vrHelp);
} else {
parameters.remove(KEY_VR_HELP);
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ReadDID.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ReadDID.java index a9a6ab775..b358d95ba 100644 --- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ReadDID.java +++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ReadDID.java @@ -129,16 +129,7 @@ public class ReadDID extends RPCRequest { * </ul>
*/
public void setDidLocation(List<Integer> didLocation) {
-
- boolean valid = true;
-
- for ( Integer item : didLocation ) {
- if (item == null) {
- valid = false;
- }
- }
-
- if ( (didLocation != null) && (didLocation.size() > 0) && valid) {
+ if (didLocation != null) {
parameters.put(KEY_DID_LOCATION, didLocation);
} else {
parameters.remove(KEY_DID_LOCATION);
@@ -156,14 +147,12 @@ public class ReadDID extends RPCRequest { if (parameters.get(KEY_DID_LOCATION) instanceof List<?>) {
List<?> list = (List<?>)parameters.get(KEY_DID_LOCATION);
if (list != null && list.size() > 0) {
- for( Object obj : list ) {
- if (!(obj instanceof Integer)) {
- return null;
- }
+ Object obj = list.get(0);
+ if (obj instanceof Integer) {
+ return (List<Integer>) list;
}
- return (List<Integer>) list;
}
}
return null;
}
-} +}
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ReadDIDResponse.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ReadDIDResponse.java index 0e797dda7..b21395b48 100644 --- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ReadDIDResponse.java +++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ReadDIDResponse.java @@ -22,16 +22,7 @@ public class ReadDIDResponse extends RPCResponse { super(hash);
}
public void setDidResult(List<DIDResult> didResult) {
-
- boolean valid = true;
-
- for ( DIDResult item : didResult ) {
- if (item == null) {
- valid = false;
- }
- }
-
- if ( (didResult != null) && (didResult.size() > 0) && valid) {
+ if (didResult != null) {
parameters.put(KEY_DID_RESULT, didResult);
} else {
parameters.remove(KEY_DID_RESULT);
@@ -42,43 +33,16 @@ public class ReadDIDResponse extends RPCResponse { if (parameters.get(KEY_DID_RESULT) instanceof List<?>) {
List<?> list = (List<?>)parameters.get(KEY_DID_RESULT);
if (list != null && list.size() > 0) {
-
- List<DIDResult> didResultList = new ArrayList<DIDResult>();
-
- boolean flagRaw = false;
- boolean flagHash = false;
-
- for ( Object obj : list ) {
-
- // This does not currently allow for a mixing of types, meaning
- // there cannot be a raw DIDResult and a Hashtable value in the
- // same same list. It will not be considered valid currently.
- if (obj instanceof DIDResult) {
- if (flagHash) {
- return null;
- }
-
- flagRaw = true;
-
- } else if (obj instanceof Hashtable) {
- if (flagRaw) {
- return null;
- }
-
- flagHash = true;
- didResultList.add(new DIDResult((Hashtable<String, Object>) obj));
-
- } else {
- return null;
- }
-
- }
-
- if (flagRaw) {
- return (List<DIDResult>) list;
- } else if (flagHash) {
- return didResultList;
- }
+ Object obj = list.get(0);
+ if (obj instanceof DIDResult) {
+ return (List<DIDResult>) list;
+ } else if (obj instanceof Hashtable) {
+ List<DIDResult> newList = new ArrayList<DIDResult>();
+ for (Object hashObj : list) {
+ newList.add(new DIDResult((Hashtable<String, Object>)hashObj));
+ }
+ return newList;
+ }
}
}
return null;
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/RegisterAppInterface.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/RegisterAppInterface.java index b5709f911..21efd91be 100644 --- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/RegisterAppInterface.java +++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/RegisterAppInterface.java @@ -8,7 +8,6 @@ import com.smartdevicelink.protocol.enums.FunctionID; import com.smartdevicelink.proxy.RPCRequest;
import com.smartdevicelink.proxy.rpc.enums.AppHMIType;
import com.smartdevicelink.proxy.rpc.enums.Language;
-import com.smartdevicelink.util.DebugTool;
/**
* Registers the application's interface with SDL®, declaring properties of
* the registration, including the messaging interface version, the app name,
@@ -323,43 +322,16 @@ public class RegisterAppInterface extends RPCRequest { if (parameters.get(KEY_TTS_NAME) instanceof List<?>) {
List<?> list = (List<?>)parameters.get(KEY_TTS_NAME);
if (list != null && list.size() > 0) {
-
- List<TTSChunk> ttsChunkList = new ArrayList<TTSChunk>();
-
- boolean flagRaw = false;
- boolean flagHash = false;
-
- for ( Object obj : list ) {
-
- // This does not currently allow for a mixing of types, meaning
- // there cannot be a raw TTSChunk and a Hashtable value in the
- // same same list. It will not be considered valid currently.
- if (obj instanceof TTSChunk) {
- if (flagHash) {
- return null;
- }
-
- flagRaw = true;
-
- } else if (obj instanceof Hashtable) {
- if (flagRaw) {
- return null;
- }
-
- flagHash = true;
- ttsChunkList.add(new TTSChunk((Hashtable<String, Object>) obj));
-
- } else {
- return null;
- }
-
- }
-
- if (flagRaw) {
- return (List<TTSChunk>) list;
- } else if (flagHash) {
- return ttsChunkList;
- }
+ Object obj = list.get(0);
+ if (obj instanceof TTSChunk) {
+ return (List<TTSChunk>) list;
+ } else if (obj instanceof Hashtable) {
+ List<TTSChunk> newList = new ArrayList<TTSChunk>();
+ for (Object hashObj : list) {
+ newList.add(new TTSChunk((Hashtable<String, Object>) hashObj));
+ }
+ return newList;
+ }
}
}
return null;
@@ -384,16 +356,7 @@ public class RegisterAppInterface extends RPCRequest { * @since SmartDeviceLink 2.0
*/
public void setTtsName(List<TTSChunk> ttsName) {
-
- boolean valid = true;
-
- for ( TTSChunk item : ttsName ) {
- if (item == null) {
- valid = false;
- }
- }
-
- if ( (ttsName != null) && (ttsName.size() > 0) && valid) {
+ if (ttsName != null) {
parameters.put(KEY_TTS_NAME, ttsName);
} else {
parameters.remove(KEY_TTS_NAME);
@@ -446,12 +409,10 @@ public class RegisterAppInterface extends RPCRequest { if (parameters.get(KEY_VR_SYNONYMS) instanceof List<?>) {
List<?> list = (List<?>)parameters.get(KEY_VR_SYNONYMS);
if (list != null && list.size()>0) {
- for( Object obj : list ) {
- if (!(obj instanceof String)) {
- return null;
- }
- }
- return (List<String>) list;
+ Object obj = list.get(0);
+ if (obj instanceof String) {
+ return (List<String>) list;
+ }
}
}
return null;
@@ -474,16 +435,7 @@ public class RegisterAppInterface extends RPCRequest { * </ul>
*/
public void setVrSynonyms(List<String> vrSynonyms) {
-
- boolean valid = true;
-
- for ( String item : vrSynonyms ) {
- if (item == null) {
- valid = false;
- }
- }
-
- if ( (vrSynonyms != null) && (vrSynonyms.size() > 0) && valid) {
+ if (vrSynonyms != null) {
parameters.put(KEY_VR_SYNONYMS, vrSynonyms);
} else {
parameters.remove(KEY_VR_SYNONYMS);
@@ -592,54 +544,21 @@ public class RegisterAppInterface extends RPCRequest { public List<AppHMIType> getAppHMIType() {
if (parameters.get(KEY_APP_HMI_TYPE) instanceof List<?>) {
List<?> list = (List<?>)parameters.get(KEY_APP_HMI_TYPE);
- if (list != null && list.size() > 0) { -
- List<AppHMIType> appHMITypeList = new ArrayList<AppHMIType>();
-
- boolean flagRaw = false;
- boolean flagHash = false;
-
- for ( Object obj : list ) {
-
- // This does not currently allow for a mixing of types, meaning
- // there cannot be a raw AppHMIType and a Hashtable value in the
- // same same list. It will not be considered valid currently.
- if (obj instanceof AppHMIType) {
- if (flagHash) {
- return null;
- }
-
- flagRaw = true;
-
- } else if (obj instanceof Hashtable) {
- if (flagRaw) {
- return null;
- }
-
- flagHash = true;
- String strFormat = (String) obj;
- AppHMIType toAdd = null;
- try {
- toAdd = AppHMIType.valueForString(strFormat);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_APP_HMI_TYPE, e);
- }
- + if (list != null && list.size() > 0) {
+ Object obj = list.get(0);
+ if (obj instanceof AppHMIType) {
+ return (List<AppHMIType>) list;
+ } else if (obj instanceof String) {
+ List<AppHMIType> newList = new ArrayList<AppHMIType>();
+ for (Object hashObj : list) {
+ String strFormat = (String)hashObj;
+ AppHMIType toAdd = AppHMIType.valueForString(strFormat);
if (toAdd != null) {
- appHMITypeList.add(toAdd);
+ newList.add(toAdd);
}
-
- } else {
- return null;
- }
-
- }
-
- if (flagRaw) {
- return (List<AppHMIType>) list;
- } else if (flagHash) {
- return appHMITypeList;
- }
+ }
+ return newList;
+ }
}
}
return null;
@@ -661,16 +580,7 @@ public class RegisterAppInterface extends RPCRequest { * @since SmartDeviceLink 2.0
*/
public void setAppHMIType(List<AppHMIType> appHMIType) {
-
- boolean valid = true;
-
- for ( AppHMIType item : appHMIType ) {
- if (item == null) {
- valid = false;
- }
- }
-
- if ( (appHMIType != null) && (appHMIType.size() > 0) && valid) {
+ if (appHMIType != null) {
parameters.put(KEY_APP_HMI_TYPE, appHMIType);
} else {
parameters.remove(KEY_APP_HMI_TYPE);
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/RegisterAppInterfaceResponse.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/RegisterAppInterfaceResponse.java index c7e719c35..05a96160c 100644 --- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/RegisterAppInterfaceResponse.java +++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/RegisterAppInterfaceResponse.java @@ -12,7 +12,6 @@ import com.smartdevicelink.proxy.rpc.enums.Language; import com.smartdevicelink.proxy.rpc.enums.PrerecordedSpeech;
import com.smartdevicelink.proxy.rpc.enums.SpeechCapabilities;
import com.smartdevicelink.proxy.rpc.enums.VrCapabilities;
-import com.smartdevicelink.util.DebugTool;
/**
* Register AppInterface Response is sent, when RegisterAppInterface has been called
@@ -113,13 +112,7 @@ public class RegisterAppInterfaceResponse extends RPCResponse { if (obj instanceof Language) {
return (Language) obj;
} else if (obj instanceof String) {
- Language theCode = null;
- try {
- theCode = Language.valueForString((String) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_LANGUAGE, e);
- }
- return theCode;
+ return Language.valueForString((String) obj);
}
return null;
}
@@ -155,13 +148,7 @@ public class RegisterAppInterfaceResponse extends RPCResponse { if (obj instanceof Language) {
return (Language) obj;
} else if (obj instanceof String) {
- Language theCode = null;
- try {
- theCode = Language.valueForString((String) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_HMI_DISPLAY_LANGUAGE, e);
- }
- return theCode;
+ return Language.valueForString((String) obj);
}
return null;
}
@@ -218,43 +205,16 @@ public class RegisterAppInterfaceResponse extends RPCResponse { if (parameters.get(KEY_BUTTON_CAPABILITIES) instanceof List<?>) {
List<?> list = (List<?>)parameters.get(KEY_BUTTON_CAPABILITIES);
if (list != null && list.size() > 0) {
-
- List<ButtonCapabilities> buttonCapabilitiesList = new ArrayList<ButtonCapabilities>();
-
- boolean flagRaw = false;
- boolean flagHash = false;
-
- for ( Object obj : list ) {
-
- // This does not currently allow for a mixing of types, meaning
- // there cannot be a raw ButtonCapabilities and a Hashtable value in the
- // same same list. It will not be considered valid currently.
- if (obj instanceof ButtonCapabilities) {
- if (flagHash) {
- return null;
- }
-
- flagRaw = true;
-
- } else if (obj instanceof Hashtable) {
- if (flagRaw) {
- return null;
- }
-
- flagHash = true;
- buttonCapabilitiesList.add(new ButtonCapabilities((Hashtable<String, Object>) obj));
-
- } else {
- return null;
- }
-
- }
-
- if (flagRaw) {
- return (List<ButtonCapabilities>) list;
- } else if (flagHash) {
- return buttonCapabilitiesList;
- }
+ Object obj = list.get(0);
+ if (obj instanceof ButtonCapabilities) {
+ return (List<ButtonCapabilities>) list;
+ } else if (obj instanceof Hashtable) {
+ List<ButtonCapabilities> newList = new ArrayList<ButtonCapabilities>();
+ for (Object hashObj : list) {
+ newList.add(new ButtonCapabilities((Hashtable<String, Object>)hashObj));
+ }
+ return newList;
+ }
}
}
return null;
@@ -264,16 +224,7 @@ public class RegisterAppInterfaceResponse extends RPCResponse { * @param buttonCapabilities
*/
public void setButtonCapabilities(List<ButtonCapabilities> buttonCapabilities) {
-
- boolean valid = true;
-
- for (ButtonCapabilities item : buttonCapabilities ) {
- if (item == null) {
- valid = false;
- }
- }
-
- if ( (buttonCapabilities != null) && (buttonCapabilities.size() > 0) && valid) {
+ if (buttonCapabilities != null) {
parameters.put(KEY_BUTTON_CAPABILITIES, buttonCapabilities);
} else {
parameters.remove(KEY_BUTTON_CAPABILITIES);
@@ -289,43 +240,16 @@ public class RegisterAppInterfaceResponse extends RPCResponse { if (parameters.get(KEY_SOFT_BUTTON_CAPABILITIES) instanceof List<?>) {
List<?> list = (List<?>)parameters.get(KEY_SOFT_BUTTON_CAPABILITIES);
if (list != null && list.size() > 0) {
-
- List<SoftButtonCapabilities> softButtonCapabilitiesList = new ArrayList<SoftButtonCapabilities>();
-
- boolean flagRaw = false;
- boolean flagHash = false;
-
- for ( Object obj : list ) {
-
- // This does not currently allow for a mixing of types, meaning
- // there cannot be a raw SoftButtonCapabilities and a Hashtable value in the
- // same same list. It will not be considered valid currently.
- if (obj instanceof SoftButtonCapabilities) {
- if (flagHash) {
- return null;
- }
-
- flagRaw = true;
-
- } else if (obj instanceof Hashtable) {
- if (flagRaw) {
- return null;
- }
-
- flagHash = true;
- softButtonCapabilitiesList.add(new SoftButtonCapabilities((Hashtable<String, Object>) obj));
-
- } else {
- return null;
- }
-
- }
-
- if (flagRaw) {
- return (List<SoftButtonCapabilities>) list;
- } else if (flagHash) {
- return softButtonCapabilitiesList;
- }
+ Object obj = list.get(0);
+ if (obj instanceof SoftButtonCapabilities) {
+ return (List<SoftButtonCapabilities>) list;
+ } else if (obj instanceof Hashtable) {
+ List<SoftButtonCapabilities> newList = new ArrayList<SoftButtonCapabilities>();
+ for (Object hashObj : list) {
+ newList.add(new SoftButtonCapabilities((Hashtable<String, Object>)hashObj));
+ }
+ return newList;
+ }
}
}
return null;
@@ -335,16 +259,7 @@ public class RegisterAppInterfaceResponse extends RPCResponse { * @param softButtonCapabilities
*/
public void setSoftButtonCapabilities(List<SoftButtonCapabilities> softButtonCapabilities) {
-
- boolean valid = true;
-
- for (SoftButtonCapabilities item : softButtonCapabilities ) {
- if (item == null) {
- valid = false;
- }
- }
-
- if ( (softButtonCapabilities != null) && (softButtonCapabilities.size() > 0) && valid) {
+ if (softButtonCapabilities != null) {
parameters.put(KEY_SOFT_BUTTON_CAPABILITIES, softButtonCapabilities);
} else {
parameters.remove(KEY_SOFT_BUTTON_CAPABILITIES);
@@ -387,53 +302,21 @@ public class RegisterAppInterfaceResponse extends RPCResponse { public List<HmiZoneCapabilities> getHmiZoneCapabilities() {
if (parameters.get(KEY_HMI_ZONE_CAPABILITIES) instanceof List<?>) {
List<?> list = (List<?>)parameters.get(KEY_HMI_ZONE_CAPABILITIES);
- if (list != null && list.size() > 0) {
-
- List<HmiZoneCapabilities> hmiZoneCapabilitiesList = new ArrayList<HmiZoneCapabilities>();
-
- boolean flagRaw = false;
- boolean flagHash = false;
-
- for ( Object obj : list ) {
-
- // This does not currently allow for a mixing of types, meaning
- // there cannot be a raw HmiZoneCapabilities and a String value in the
- // same same list. It will not be considered valid currently.
- if (obj instanceof HmiZoneCapabilities) {
- if (flagHash) {
- return null;
- }
-
- flagRaw = true;
-
- } else if (obj instanceof String) {
- if (flagRaw) {
- return null;
- }
-
- flagHash = true;
- String strFormat = (String) obj;
- HmiZoneCapabilities toAdd = null;
- try {
- toAdd = HmiZoneCapabilities.valueForString(strFormat);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_HMI_ZONE_CAPABILITIES, e);
- }
+ if (list != null && list.size() > 0) {
+ Object obj = list.get(0);
+ if (obj instanceof HmiZoneCapabilities) {
+ return (List<HmiZoneCapabilities>) list;
+ } else if (obj instanceof String) {
+ List<HmiZoneCapabilities> newList = new ArrayList<HmiZoneCapabilities>();
+ for (Object hashObj : list) {
+ String strFormat = (String)hashObj;
+ HmiZoneCapabilities toAdd = HmiZoneCapabilities.valueForString(strFormat);
if (toAdd != null) {
- hmiZoneCapabilitiesList.add(toAdd);
+ newList.add(toAdd);
}
-
- } else {
- return null;
- }
-
- }
-
- if (flagRaw) {
- return (List<HmiZoneCapabilities>) list;
- } else if (flagHash) {
- return hmiZoneCapabilitiesList;
- }
+ }
+ return newList;
+ }
}
}
return null;
@@ -443,16 +326,7 @@ public class RegisterAppInterfaceResponse extends RPCResponse { * @param hmiZoneCapabilities
*/
public void setHmiZoneCapabilities(List<HmiZoneCapabilities> hmiZoneCapabilities) {
-
- boolean valid = true;
-
- for (HmiZoneCapabilities item : hmiZoneCapabilities ) {
- if (item == null) {
- valid = false;
- }
- }
-
- if ( (hmiZoneCapabilities != null) && (hmiZoneCapabilities.size() > 0) && valid) {
+ if (hmiZoneCapabilities != null) {
parameters.put(KEY_HMI_ZONE_CAPABILITIES, hmiZoneCapabilities);
} else {
parameters.remove(KEY_HMI_ZONE_CAPABILITIES);
@@ -468,53 +342,21 @@ public class RegisterAppInterfaceResponse extends RPCResponse { public List<SpeechCapabilities> getSpeechCapabilities() {
if (parameters.get(KEY_SPEECH_CAPABILITIES) instanceof List<?>) {
List<?> list = (List<?>)parameters.get(KEY_SPEECH_CAPABILITIES);
- if (list != null && list.size() > 0) {
-
- List<SpeechCapabilities> speechCapabilitiesList = new ArrayList<SpeechCapabilities>();
-
- boolean flagRaw = false;
- boolean flagStr = false;
-
- for ( Object obj : list ) {
-
- // This does not currently allow for a mixing of types, meaning
- // there cannot be a raw SpeechCapabilities and a String value in the
- // same same list. It will not be considered valid currently.
- if (obj instanceof SpeechCapabilities) {
- if (flagStr) {
- return null;
- }
-
- flagRaw = true;
-
- } else if (obj instanceof String) {
- if (flagRaw) {
- return null;
- }
-
- flagStr = true;
- String strFormat = (String) obj;
- SpeechCapabilities toAdd = null;
- try {
- toAdd = SpeechCapabilities.valueForString(strFormat);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_SPEECH_CAPABILITIES, e);
- }
+ if (list != null && list.size() > 0) {
+ Object obj = list.get(0);
+ if (obj instanceof SpeechCapabilities) {
+ return (List<SpeechCapabilities>) list;
+ } else if (obj instanceof String) {
+ List<SpeechCapabilities> newList = new ArrayList<SpeechCapabilities>();
+ for (Object hashObj : list) {
+ String strFormat = (String)hashObj;
+ SpeechCapabilities toAdd = SpeechCapabilities.valueForString(strFormat);
if (toAdd != null) {
- speechCapabilitiesList.add(toAdd);
+ newList.add(toAdd);
}
-
- } else {
- return null;
- }
-
- }
-
- if (flagRaw) {
- return (List<SpeechCapabilities>) list;
- } else if (flagStr) {
- return speechCapabilitiesList;
- }
+ }
+ return newList;
+ }
}
}
return null;
@@ -524,16 +366,7 @@ public class RegisterAppInterfaceResponse extends RPCResponse { * @param speechCapabilities
*/
public void setSpeechCapabilities(List<SpeechCapabilities> speechCapabilities) {
-
- boolean valid = true;
-
- for (SpeechCapabilities item : speechCapabilities ) {
- if (item == null) {
- valid = false;
- }
- }
-
- if ( (speechCapabilities != null) && (speechCapabilities.size() > 0) && valid) {
+ if (speechCapabilities != null) {
parameters.put(KEY_SPEECH_CAPABILITIES, speechCapabilities);
} else {
parameters.remove(KEY_SPEECH_CAPABILITIES);
@@ -546,68 +379,27 @@ public class RegisterAppInterfaceResponse extends RPCResponse { if (parameters.get(KEY_PRERECORDED_SPEECH) instanceof List<?>) {
List<?> list = (List<?>)parameters.get(KEY_PRERECORDED_SPEECH);
if (list != null && list.size() > 0) {
-
- List<PrerecordedSpeech> prerecordedSpeechList = new ArrayList<PrerecordedSpeech>();
-
- boolean flagRaw = false;
- boolean flagStr = false;
-
- for ( Object obj : list ) {
-
- // This does not currently allow for a mixing of types, meaning
- // there cannot be a raw PrerecordedSpeech and a String value in the
- // same same list. It will not be considered valid currently.
- if (obj instanceof PrerecordedSpeech) {
- if (flagStr) {
- return null;
- }
-
- flagRaw = true;
-
- } else if (obj instanceof String) {
- if (flagRaw) {
- return null;
- }
-
- flagStr = true;
- String strFormat = (String) obj;
- PrerecordedSpeech toAdd = null;
- try {
- toAdd = PrerecordedSpeech.valueForString(strFormat);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_PRERECORDED_SPEECH, e);
- }
+ Object obj = list.get(0);
+ if (obj instanceof PrerecordedSpeech) {
+ return (List<PrerecordedSpeech>) list;
+ } else if (obj instanceof String) {
+ List<PrerecordedSpeech> newList = new ArrayList<PrerecordedSpeech>();
+ for (Object hashObj : list) {
+ String strFormat = (String)hashObj;
+ PrerecordedSpeech toAdd = PrerecordedSpeech.valueForString(strFormat);
if (toAdd != null) {
- prerecordedSpeechList.add(toAdd);
+ newList.add(toAdd);
}
-
- } else {
- return null;
- }
-
- }
-
- if (flagRaw) {
- return (List<PrerecordedSpeech>) list;
- } else if (flagStr) {
- return prerecordedSpeechList;
- }
+ }
+ return newList;
+ }
}
}
return null;
}
public void setPrerecordedSpeech(List<PrerecordedSpeech> prerecordedSpeech) {
-
- boolean valid = true;
-
- for ( PrerecordedSpeech item : prerecordedSpeech ) {
- if (item == null) {
- valid = false;
- }
- }
-
- if ( (prerecordedSpeech != null) && (prerecordedSpeech.size() > 0) && valid) {
+ if (prerecordedSpeech != null) {
parameters.put(KEY_PRERECORDED_SPEECH, prerecordedSpeech);
} else {
parameters.remove(KEY_PRERECORDED_SPEECH);
@@ -625,52 +417,20 @@ public class RegisterAppInterfaceResponse extends RPCResponse { if (parameters.get(KEY_VR_CAPABILITIES) instanceof List<?>) {
List<?> list = (List<?>)parameters.get(KEY_VR_CAPABILITIES);
if (list != null && list.size() > 0) {
-
- List<VrCapabilities> vrCapabilitiesList = new ArrayList<VrCapabilities>();
-
- boolean flagRaw = false;
- boolean flagStr = false;
-
- for ( Object obj : list ) {
-
- // This does not currently allow for a mixing of types, meaning
- // there cannot be a raw VrCapabilities and a String value in the
- // same same list. It will not be considered valid currently.
- if (obj instanceof VrCapabilities) {
- if (flagStr) {
- return null;
- }
-
- flagRaw = true;
-
- } else if (obj instanceof String) {
- if (flagRaw) {
- return null;
- }
-
- flagStr = true;
- String strFormat = (String) obj;
- VrCapabilities toAdd = null;
- try {
- toAdd = VrCapabilities.valueForString(strFormat);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_VR_CAPABILITIES, e);
- }
+ Object obj = list.get(0);
+ if (obj instanceof VrCapabilities) {
+ return (List<VrCapabilities>) list;
+ } else if (obj instanceof String) {
+ List<VrCapabilities> newList = new ArrayList<VrCapabilities>();
+ for (Object hashObj : list) {
+ String strFormat = (String)hashObj;
+ VrCapabilities toAdd = VrCapabilities.valueForString(strFormat);
if (toAdd != null) {
- vrCapabilitiesList.add(toAdd);
+ newList.add(toAdd);
}
-
- } else {
- return null;
- }
-
- }
-
- if (flagRaw) {
- return (List<VrCapabilities>) list;
- } else if (flagStr) {
- return vrCapabilitiesList;
- }
+ }
+ return newList;
+ }
}
}
return null;
@@ -680,16 +440,7 @@ public class RegisterAppInterfaceResponse extends RPCResponse { * @param vrCapabilities
*/
public void setVrCapabilities(List<VrCapabilities> vrCapabilities) {
-
- boolean valid = true;
-
- for ( VrCapabilities item : vrCapabilities ) {
- if (item == null) {
- valid = false;
- }
- }
-
- if ( (vrCapabilities != null) && (vrCapabilities.size() > 0) && valid) {
+ if (vrCapabilities != null) {
parameters.put(KEY_VR_CAPABILITIES, vrCapabilities);
} else {
parameters.remove(KEY_VR_CAPABILITIES);
@@ -733,43 +484,16 @@ public class RegisterAppInterfaceResponse extends RPCResponse { if (parameters.get(KEY_AUDIO_PASS_THRU_CAPABILITIES) instanceof List<?>) {
List<?> list = (List<?>)parameters.get(KEY_AUDIO_PASS_THRU_CAPABILITIES);
if (list != null && list.size() > 0) {
-
- List<AudioPassThruCapabilities> audioPassThruCapabilitiesList = new ArrayList<AudioPassThruCapabilities>();
-
- boolean flagRaw = false;
- boolean flagHash = false;
-
- for ( Object obj : list ) {
-
- // This does not currently allow for a mixing of types, meaning
- // there cannot be a raw AudioPassThruCapabilities and a Hashtable value in the
- // same same list. It will not be considered valid currently.
- if (obj instanceof AudioPassThruCapabilities) {
- if (flagHash) {
- return null;
- }
-
- flagRaw = true;
-
- } else if (obj instanceof Hashtable) {
- if (flagRaw) {
- return null;
- }
-
- flagHash = true;
- audioPassThruCapabilitiesList.add(new AudioPassThruCapabilities((Hashtable<String, Object>) obj));
-
- } else {
- return null;
- }
-
- }
-
- if (flagRaw) {
- return (List<AudioPassThruCapabilities>) list;
- } else if (flagHash) {
- return audioPassThruCapabilitiesList;
- }
+ Object obj = list.get(0);
+ if (obj instanceof AudioPassThruCapabilities) {
+ return (List<AudioPassThruCapabilities>) list;
+ } else if (obj instanceof Hashtable) {
+ List<AudioPassThruCapabilities> newList = new ArrayList<AudioPassThruCapabilities>();
+ for (Object hashObj : list) {
+ newList.add(new AudioPassThruCapabilities((Hashtable<String, Object>)hashObj));
+ }
+ return newList;
+ }
}
}
return null;
@@ -779,16 +503,7 @@ public class RegisterAppInterfaceResponse extends RPCResponse { * @param audioPassThruCapabilities
*/
public void setAudioPassThruCapabilities(List<AudioPassThruCapabilities> audioPassThruCapabilities) {
-
- boolean valid = true;
-
- for ( AudioPassThruCapabilities item : audioPassThruCapabilities ) {
- if (item == null) {
- valid = false;
- }
- }
-
- if ( (audioPassThruCapabilities != null) && (audioPassThruCapabilities.size() > 0) && valid) {
+ if (audioPassThruCapabilities != null) {
parameters.put(KEY_AUDIO_PASS_THRU_CAPABILITIES, audioPassThruCapabilities);
} else {
parameters.remove(KEY_AUDIO_PASS_THRU_CAPABILITIES);
@@ -801,16 +516,7 @@ public class RegisterAppInterfaceResponse extends RPCResponse { return null;
}
public void setSupportedDiagModes(List<Integer> supportedDiagModes) {
-
- boolean valid = true;
-
- for ( Integer item : supportedDiagModes ) {
- if (item == null) {
- valid = false;
- }
- }
-
- if ( (supportedDiagModes != null) && (supportedDiagModes.size() > 0) && valid) {
+ if (supportedDiagModes != null) {
parameters.put(KEY_SUPPORTED_DIAG_MODES, supportedDiagModes);
}
else
@@ -825,12 +531,10 @@ public class RegisterAppInterfaceResponse extends RPCResponse { if (parameters.get(KEY_SUPPORTED_DIAG_MODES) instanceof List<?>) {
List<?> list = (List<?>)parameters.get( KEY_SUPPORTED_DIAG_MODES);
if (list != null && list.size() > 0) {
- for( Object obj : list ) {
- if (!(obj instanceof Integer)) {
- return null;
- }
+ Object obj = list.get(0);
+ if (obj instanceof Integer) {
+ return (List<Integer>) list;
}
- return (List<Integer>) list;
}
}
return null;
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ResetGlobalProperties.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ResetGlobalProperties.java index 482ebba10..d273d73a2 100644 --- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ResetGlobalProperties.java +++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ResetGlobalProperties.java @@ -7,7 +7,6 @@ import java.util.List; import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCRequest;
import com.smartdevicelink.proxy.rpc.enums.GlobalProperty;
-import com.smartdevicelink.util.DebugTool;
/**
* Resets the passed global properties to their default values as defined by
* SDL
@@ -89,52 +88,20 @@ public class ResetGlobalProperties extends RPCRequest { if (parameters.get(KEY_PROPERTIES) instanceof List<?>) {
List<?> list = (List<?>)parameters.get(KEY_PROPERTIES);
if (list != null && list.size() > 0) {
-
- List<GlobalProperty> globalPropertyList = new ArrayList<GlobalProperty>();
-
- boolean flagRaw = false;
- boolean flagStr = false;
-
- for ( Object obj : list ) {
-
- // This does not currently allow for a mixing of types, meaning
- // there cannot be a raw GlobalProperty and a String value in the
- // same same list. It will not be considered valid currently.
- if (obj instanceof SoftButton) {
- if (flagStr) {
- return null;
- }
-
- flagRaw = true;
-
- } else if (obj instanceof String) {
- if (flagRaw) {
- return null;
- }
-
- flagStr = true;
- String strFormat = (String) obj;
- GlobalProperty toAdd = null;
- try {
- toAdd = GlobalProperty.valueForString(strFormat);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_PROPERTIES, e);
- }
+ Object obj = list.get(0);
+ if (obj instanceof GlobalProperty) {
+ return (List<GlobalProperty>) list;
+ } else if (obj instanceof String) {
+ List<GlobalProperty> newList = new ArrayList<GlobalProperty>();
+ for (Object hashObj : list) {
+ String strFormat = (String)hashObj;
+ GlobalProperty toAdd = GlobalProperty.valueForString(strFormat);
if (toAdd != null) {
- globalPropertyList.add(toAdd);
+ newList.add(toAdd);
}
-
- } else {
- return null;
- }
-
- }
-
- if (flagRaw) {
- return (List<GlobalProperty>) list;
- } else if (flagStr) {
- return globalPropertyList;
- }
+ }
+ return newList;
+ }
}
}
return null;
@@ -151,16 +118,7 @@ public class ResetGlobalProperties extends RPCRequest { * <b>Notes: </b>Array must have at least one element
*/
public void setProperties( List<GlobalProperty> properties ) {
-
- boolean valid = true;
-
- for (GlobalProperty item : properties ) {
- if (item == null) {
- valid = false;
- }
- }
-
- if ( (properties != null) && (properties.size() > 0) && valid) {
+ if (properties != null) {
parameters.put(KEY_PROPERTIES, properties );
} else {
parameters.remove(KEY_PROPERTIES);
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ScrollableMessage.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ScrollableMessage.java index 09cece1fb..38d3e1404 100644 --- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ScrollableMessage.java +++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ScrollableMessage.java @@ -154,16 +154,7 @@ public class ScrollableMessage extends RPCRequest { * <b>Notes: </b>Minsize=0, Maxsize=8
*/
public void setSoftButtons(List<SoftButton> softButtons) {
-
- boolean valid = true;
-
- for (SoftButton item : softButtons ) {
- if (item == null) {
- valid = false;
- }
- }
-
- if ( (softButtons != null) && (softButtons.size() > 0) && valid) {
+ if (softButtons != null) {
parameters.put(KEY_SOFT_BUTTONS, softButtons);
} else {
parameters.remove(KEY_SOFT_BUTTONS);
@@ -179,43 +170,16 @@ public class ScrollableMessage extends RPCRequest { if (parameters.get(KEY_SOFT_BUTTONS) instanceof List<?>) {
List<?> list = (List<?>)parameters.get(KEY_SOFT_BUTTONS);
if (list != null && list.size() > 0) {
-
- List<SoftButton> softButtonList = new ArrayList<SoftButton>();
-
- boolean flagRaw = false;
- boolean flagHash = false;
-
- for ( Object obj : list ) {
-
- // This does not currently allow for a mixing of types, meaning
- // there cannot be a raw SoftButton and a Hashtable value in the
- // same same list. It will not be considered valid currently.
- if (obj instanceof SoftButton) {
- if (flagHash) {
- return null;
- }
-
- flagRaw = true;
-
- } else if (obj instanceof Hashtable) {
- if (flagRaw) {
- return null;
- }
-
- flagHash = true;
- softButtonList.add(new SoftButton((Hashtable<String, Object>) obj));
-
- } else {
- return null;
- }
-
- }
-
- if (flagRaw) {
- return (List<SoftButton>) list;
- } else if (flagHash) {
- return softButtonList;
- }
+ Object obj = list.get(0);
+ if (obj instanceof SoftButton) {
+ return (List<SoftButton>) list;
+ } else if (obj instanceof Hashtable) {
+ List<SoftButton> newList = new ArrayList<SoftButton>();
+ for (Object hashObj : list) {
+ newList.add(new SoftButton((Hashtable<String, Object>) hashObj));
+ }
+ return newList;
+ }
}
}
return null;
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SendLocation.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SendLocation.java index e357e3356..0257a4c1c 100644 --- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SendLocation.java +++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SendLocation.java @@ -171,12 +171,10 @@ public class SendLocation extends RPCRequest{ if(parameters.get(KEY_ADDRESS_LINES) instanceof List<?>){ List<?> list = (List<?>) parameters.get(KEY_ADDRESS_LINES); if(list != null && list.size() > 0){ - for( Object obj : list ) { - if (!(obj instanceof String)) { - return null; - } - } - return (List<String>) list; + Object obj = list.get(0); + if(obj instanceof String){ + return (List<String>) list; + } } } return null; @@ -187,16 +185,7 @@ public class SendLocation extends RPCRequest{ * @param addressLines The address lines of the location */ public void setAddressLines(List<String> addressLines){ - - boolean valid = true; - - for (String item : addressLines ) { - if (item == null) { - valid = false; - } - } - - if ( (addressLines != null) && (addressLines.size() > 0) && valid) { + if(addressLines != null){ parameters.put(KEY_ADDRESS_LINES, addressLines); } else{ diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SetDisplayLayoutResponse.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SetDisplayLayoutResponse.java index 6d0a83b36..787bdd9f7 100644 --- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SetDisplayLayoutResponse.java +++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SetDisplayLayoutResponse.java @@ -61,59 +61,23 @@ public class SetDisplayLayoutResponse extends RPCResponse { if (parameters.get(KEY_BUTTON_CAPABILITIES) instanceof List<?>) {
List<?> list = (List<?>)parameters.get(KEY_BUTTON_CAPABILITIES);
if (list != null && list.size() > 0) {
-
- List<ButtonCapabilities> buttonCapabilitiesList = new ArrayList<ButtonCapabilities>();
-
- boolean flagRaw = false;
- boolean flagHash = false;
-
- for ( Object obj : list ) {
-
- // This does not currently allow for a mixing of types, meaning
- // there cannot be a raw ButtonCapabilities and a Hashtable value in the
- // same same list. It will not be considered valid currently.
- if (obj instanceof ButtonCapabilities) {
- if (flagHash) {
- return null;
- }
-
- flagRaw = true;
-
- } else if (obj instanceof Hashtable) {
- if (flagRaw) {
- return null;
- }
-
- flagHash = true;
- buttonCapabilitiesList.add(new ButtonCapabilities((Hashtable<String, Object>) obj));
-
- } else {
- return null;
- }
-
- }
-
- if (flagRaw) {
- return (List<ButtonCapabilities>) list;
- } else if (flagHash) {
- return buttonCapabilitiesList;
- }
+ Object obj = list.get(0);
+ if (obj instanceof ButtonCapabilities) {
+ return (List<ButtonCapabilities>) list;
+ } else if (obj instanceof Hashtable) {
+ List<ButtonCapabilities> newList = new ArrayList<ButtonCapabilities>();
+ for (Object hashObj : list) {
+ newList.add(new ButtonCapabilities((Hashtable<String, Object>)hashObj));
+ }
+ return newList;
+ }
}
}
return null;
}
public void setButtonCapabilities(List<ButtonCapabilities> buttonCapabilities) {
-
- boolean valid = true;
-
- for (ButtonCapabilities item : buttonCapabilities ) {
- if (item == null) {
- valid = false;
- }
- }
-
- if ( (buttonCapabilities != null) && (buttonCapabilities.size() > 0) && valid) {
+ if (buttonCapabilities != null) {
parameters.put(KEY_BUTTON_CAPABILITIES, buttonCapabilities);
} else {
parameters.remove(KEY_BUTTON_CAPABILITIES);
@@ -125,59 +89,23 @@ public class SetDisplayLayoutResponse extends RPCResponse { if (parameters.get(KEY_SOFT_BUTTON_CAPABILITIES) instanceof List<?>) {
List<?> list = (List<?>)parameters.get(KEY_SOFT_BUTTON_CAPABILITIES);
if (list != null && list.size() > 0) {
-
- List<SoftButtonCapabilities> softButtonCapabilitiesList = new ArrayList<SoftButtonCapabilities>();
-
- boolean flagRaw = false;
- boolean flagHash = false;
-
- for ( Object obj : list ) {
-
- // This does not currently allow for a mixing of types, meaning
- // there cannot be a raw SoftButtonCapabilities and a Hashtable value in the
- // same same list. It will not be considered valid currently.
- if (obj instanceof SoftButtonCapabilities) {
- if (flagHash) {
- return null;
- }
-
- flagRaw = true;
-
- } else if (obj instanceof Hashtable) {
- if (flagRaw) {
- return null;
- }
-
- flagHash = true;
- softButtonCapabilitiesList.add(new SoftButtonCapabilities((Hashtable<String, Object>) obj));
-
- } else {
- return null;
- }
-
- }
-
- if (flagRaw) {
- return (List<SoftButtonCapabilities>) list;
- } else if (flagHash) {
- return softButtonCapabilitiesList;
- }
+ Object obj = list.get(0);
+ if (obj instanceof SoftButtonCapabilities) {
+ return (List<SoftButtonCapabilities>) list;
+ } else if (obj instanceof Hashtable) {
+ List<SoftButtonCapabilities> newList = new ArrayList<SoftButtonCapabilities>();
+ for (Object hashObj : list) {
+ newList.add(new SoftButtonCapabilities((Hashtable<String, Object>)hashObj));
+ }
+ return newList;
+ }
}
}
return null;
}
public void setSoftButtonCapabilities(List<SoftButtonCapabilities> softButtonCapabilities) {
-
- boolean valid = true;
-
- for (SoftButtonCapabilities item : softButtonCapabilities ) {
- if (item == null) {
- valid = false;
- }
- }
-
- if ( (softButtonCapabilities != null) && (softButtonCapabilities.size() > 0) && valid) {
+ if (softButtonCapabilities != null) {
parameters.put(KEY_SOFT_BUTTON_CAPABILITIES, softButtonCapabilities);
} else {
parameters.remove(KEY_SOFT_BUTTON_CAPABILITIES);
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SetGlobalProperties.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SetGlobalProperties.java index bca753582..5722f39dd 100644 --- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SetGlobalProperties.java +++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SetGlobalProperties.java @@ -146,43 +146,16 @@ public class SetGlobalProperties extends RPCRequest { if (parameters.get(KEY_HELP_PROMPT) instanceof List<?>) {
List<?> list = (List<?>)parameters.get(KEY_HELP_PROMPT);
if (list != null && list.size() > 0) {
-
- List<TTSChunk> ttsChunkList = new ArrayList<TTSChunk>();
-
- boolean flagRaw = false;
- boolean flagHash = false;
-
- for ( Object obj : list ) {
-
- // This does not currently allow for a mixing of types, meaning
- // there cannot be a raw TTSChunk and a Hashtable value in the
- // same same list. It will not be considered valid currently.
- if (obj instanceof TTSChunk) {
- if (flagHash) {
- return null;
- }
-
- flagRaw = true;
-
- } else if (obj instanceof Hashtable) {
- if (flagRaw) {
- return null;
- }
-
- flagHash = true;
- ttsChunkList.add(new TTSChunk((Hashtable<String, Object>) obj));
-
- } else {
- return null;
- }
-
- }
-
- if (flagRaw) {
- return (List<TTSChunk>) list;
- } else if (flagHash) {
- return ttsChunkList;
- }
+ Object obj = list.get(0);
+ if (obj instanceof TTSChunk) {
+ return (List<TTSChunk>) list;
+ } else if (obj instanceof Hashtable) {
+ List<TTSChunk> newList = new ArrayList<TTSChunk>();
+ for (Object hashObj : list) {
+ newList.add(new TTSChunk((Hashtable<String, Object>)hashObj));
+ }
+ return newList;
+ }
}
}
return null;
@@ -202,16 +175,7 @@ public class SetGlobalProperties extends RPCRequest { * </ul>
*/
public void setHelpPrompt(List<TTSChunk> helpPrompt) {
-
- boolean valid = true;
-
- for (TTSChunk item : helpPrompt ) {
- if (item == null) {
- valid = false;
- }
- }
-
- if ( (helpPrompt != null) && (helpPrompt.size() > 0) && valid) {
+ if (helpPrompt != null) {
parameters.put(KEY_HELP_PROMPT, helpPrompt);
} else {
parameters.remove(KEY_HELP_PROMPT);
@@ -230,43 +194,16 @@ public class SetGlobalProperties extends RPCRequest { if (parameters.get(KEY_TIMEOUT_PROMPT) instanceof List<?>) {
List<?> list = (List<?>)parameters.get(KEY_TIMEOUT_PROMPT);
if (list != null && list.size() > 0) {
-
- List<TTSChunk> ttsChunkList = new ArrayList<TTSChunk>();
-
- boolean flagRaw = false;
- boolean flagHash = false;
-
- for ( Object obj : list ) {
-
- // This does not currently allow for a mixing of types, meaning
- // there cannot be a raw TTSChunk and a Hashtable value in the
- // same same list. It will not be considered valid currently.
- if (obj instanceof TTSChunk) {
- if (flagHash) {
- return null;
- }
-
- flagRaw = true;
-
- } else if (obj instanceof Hashtable) {
- if (flagRaw) {
- return null;
- }
-
- flagHash = true;
- ttsChunkList.add(new TTSChunk((Hashtable<String, Object>) obj));
-
- } else {
- return null;
- }
-
- }
-
- if (flagRaw) {
- return (List<TTSChunk>) list;
- } else if (flagHash) {
- return ttsChunkList;
- }
+ Object obj = list.get(0);
+ if (obj instanceof TTSChunk) {
+ return (List<TTSChunk>) list;
+ } else if (obj instanceof Hashtable) {
+ List<TTSChunk> newList = new ArrayList<TTSChunk>();
+ for (Object hashObj : list) {
+ newList.add(new TTSChunk((Hashtable<String, Object>)hashObj));
+ }
+ return newList;
+ }
}
}
return null;
@@ -278,16 +215,7 @@ public class SetGlobalProperties extends RPCRequest { *
*/
public void setTimeoutPrompt(List<TTSChunk> timeoutPrompt) {
-
- boolean valid = true;
-
- for (TTSChunk item : timeoutPrompt ) {
- if (item == null) {
- valid = false;
- }
- }
-
- if ( (timeoutPrompt != null) && (timeoutPrompt.size() > 0) && valid) {
+ if (timeoutPrompt != null) {
parameters.put(KEY_TIMEOUT_PROMPT, timeoutPrompt);
} else {
parameters.remove(KEY_TIMEOUT_PROMPT);
@@ -342,43 +270,16 @@ public class SetGlobalProperties extends RPCRequest { if (parameters.get(KEY_VR_HELP) instanceof List<?>) {
List<?> list = (List<?>)parameters.get(KEY_VR_HELP);
if (list != null && list.size() > 0) {
-
- List<VrHelpItem> vrHelpItemList = new ArrayList<VrHelpItem>();
-
- boolean flagRaw = false;
- boolean flagHash = false;
-
- for ( Object obj : list ) {
-
- // This does not currently allow for a mixing of types, meaning
- // there cannot be a raw VrHelpItem and a Hashtable value in the
- // same same list. It will not be considered valid currently.
- if (obj instanceof VrHelpItem) {
- if (flagHash) {
- return null;
- }
-
- flagRaw = true;
-
- } else if (obj instanceof Hashtable) {
- if (flagRaw) {
- return null;
- }
-
- flagHash = true;
- vrHelpItemList.add(new VrHelpItem((Hashtable<String, Object>) obj));
-
- } else {
- return null;
- }
-
- }
-
- if (flagRaw) {
- return (List<VrHelpItem>) list;
- } else if (flagHash) {
- return vrHelpItemList;
- }
+ Object obj = list.get(0);
+ if (obj instanceof VrHelpItem) {
+ return (List<VrHelpItem>) list;
+ } else if (obj instanceof Hashtable) {
+ List<VrHelpItem> newList = new ArrayList<VrHelpItem>();
+ for (Object hashObj : list) {
+ newList.add(new VrHelpItem((Hashtable<String, Object>)hashObj));
+ }
+ return newList;
+ }
}
}
return null;
@@ -406,16 +307,7 @@ public class SetGlobalProperties extends RPCRequest { * @since SmartDeviceLink 2.0
*/
public void setVrHelp(List<VrHelpItem> vrHelp) {
-
- boolean valid = true;
-
- for (VrHelpItem item : vrHelp ) {
- if (item == null) {
- valid = false;
- }
- }
-
- if ( (vrHelp != null) && (vrHelp.size() > 0) && valid) {
+ if (vrHelp != null) {
parameters.put(KEY_VR_HELP, vrHelp);
} else {
parameters.remove(KEY_VR_HELP);
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/Show.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/Show.java index a6d070e2e..527b8b060 100644 --- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/Show.java +++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/Show.java @@ -538,43 +538,16 @@ public class Show extends RPCRequest { if (parameters.get(KEY_SOFT_BUTTONS) instanceof List<?>) {
List<?> list = (List<?>)parameters.get(KEY_SOFT_BUTTONS);
if (list != null && list.size() > 0) {
-
- List<SoftButton> softButtonList = new ArrayList<SoftButton>();
-
- boolean flagRaw = false;
- boolean flagHash = false;
-
- for ( Object obj : list ) {
-
- // This does not currently allow for a mixing of types, meaning
- // there cannot be a raw SoftButton and a Hashtable value in the
- // same same list. It will not be considered valid currently.
- if (obj instanceof SoftButton) {
- if (flagHash) {
- return null;
- }
-
- flagRaw = true;
-
- } else if (obj instanceof Hashtable) {
- if (flagRaw) {
- return null;
- }
-
- flagHash = true;
- softButtonList.add(new SoftButton((Hashtable<String, Object>) obj));
-
- } else {
- return null;
- }
-
- }
-
- if (flagRaw) {
- return (List<SoftButton>) list;
- } else if (flagHash) {
- return softButtonList;
- }
+ Object obj = list.get(0);
+ if (obj instanceof SoftButton) {
+ return (List<SoftButton>) list;
+ } else if (obj instanceof Hashtable) {
+ List<SoftButton> newList = new ArrayList<SoftButton>();
+ for (Object hashObj : list) {
+ newList.add(new SoftButton((Hashtable<String, Object>)hashObj));
+ }
+ return newList;
+ }
}
}
return null;
@@ -598,21 +571,11 @@ public class Show extends RPCRequest { * @since SmartDeviceLink 2.0
*/
public void setSoftButtons(List<SoftButton> softButtons) {
-
- boolean valid = true;
-
- for (SoftButton item : softButtons ) {
- if (item == null) {
- valid = false;
- }
- }
-
- if ( (softButtons != null) && (softButtons.size() > 0) && valid) {
- parameters.put(KEY_SOFT_BUTTONS, softButtons);
- }
- else{
- parameters.remove(KEY_SOFT_BUTTONS);
- }
+ if (softButtons != null) {
+ parameters.put(KEY_SOFT_BUTTONS, softButtons);
+ } else {
+ parameters.remove(KEY_SOFT_BUTTONS);
+ }
}
/**
@@ -626,13 +589,11 @@ public class Show extends RPCRequest { public List<String> getCustomPresets() {
if (parameters.get(KEY_CUSTOM_PRESETS) instanceof List<?>) {
List<?> list = (List<?>)parameters.get(KEY_CUSTOM_PRESETS);
- if (list != null && list.size() > 0) {
- for( Object obj : list ) {
- if (!(obj instanceof String)) {
- return null;
- }
- }
- return (List<String>) list;
+ if (list != null && list.size()>0) {
+ Object obj = list.get(0);
+ if (obj instanceof String) {
+ return (List<String>) list;
+ }
}
}
return null;
@@ -653,16 +614,7 @@ public class Show extends RPCRequest { * @since SmartDeviceLink 2.0
*/
public void setCustomPresets(List<String> customPresets) {
-
- boolean valid = true;
-
- for (String item : customPresets ) {
- if (item == null) {
- valid = false;
- }
- }
-
- if ( (customPresets != null) && (customPresets.size() > 0) && valid) {
+ if (customPresets != null) {
parameters.put(KEY_CUSTOM_PRESETS, customPresets);
} else {
parameters.remove(KEY_CUSTOM_PRESETS);
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ShowConstantTbt.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ShowConstantTbt.java index 2c4bd5173..293adddbe 100644 --- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ShowConstantTbt.java +++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ShowConstantTbt.java @@ -307,21 +307,12 @@ public class ShowConstantTbt extends RPCRequest{ * a List<SoftButton> value */ public void setSoftButtons(List<SoftButton> softButtons){ - - boolean valid = true; - - for (SoftButton item : softButtons ) { - if (item == null) { - valid = false; - } - } - - if ( (softButtons != null) && (softButtons.size() > 0) && valid) { - parameters.put(KEY_SOFT_BUTTONS, softButtons); - } - else{ - parameters.remove(KEY_SOFT_BUTTONS); - } + if(softButtons != null){ + parameters.put(KEY_SOFT_BUTTONS, softButtons); + } + else{ + parameters.remove(KEY_SOFT_BUTTONS); + } } /** @@ -335,43 +326,16 @@ public class ShowConstantTbt extends RPCRequest{ if (parameters.get(KEY_SOFT_BUTTONS) instanceof List<?>) { List<?> list = (List<?>)parameters.get(KEY_SOFT_BUTTONS); if (list != null && list.size() > 0) { - - List<SoftButton> softButtonList = new ArrayList<SoftButton>(); - - boolean flagRaw = false; - boolean flagHash = false; - - for ( Object obj : list ) { - - // This does not currently allow for a mixing of types, meaning - // there cannot be a raw SoftButton and a Hashtable value in the - // same same list. It will not be considered valid currently. - if (obj instanceof SoftButton) { - if (flagHash) { - return null; - } - - flagRaw = true; - - } else if (obj instanceof Hashtable) { - if (flagRaw) { - return null; - } - - flagHash = true; - softButtonList.add(new SoftButton((Hashtable<String, Object>) obj)); - - } else { - return null; - } - - } - - if (flagRaw) { - return (List<SoftButton>) list; - } else if (flagHash) { - return softButtonList; - } + Object obj = list.get(0); + if (obj instanceof SoftButton) { + return (List<SoftButton>) list; + } else if (obj instanceof Hashtable) { + List<SoftButton> newList = new ArrayList<SoftButton>(); + for (Object hashObj : list) { + newList.add(new SoftButton((Hashtable<String, Object>)hashObj)); + } + return newList; + } } } return null; diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/Slider.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/Slider.java index 72af6a03a..96a17624d 100644 --- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/Slider.java +++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/Slider.java @@ -197,16 +197,7 @@ public class Slider extends RPCRequest { * <b>Notes: </b>Maxlength=500; Minvalue=1; Maxvalue=26
*/
public void setSliderFooter(List<String> sliderFooter) {
-
- boolean valid = true;
-
- for (String item : sliderFooter ) {
- if (item == null) {
- valid = false;
- }
- }
-
- if ( (sliderFooter != null) && (sliderFooter.size() > 0) && valid) {
+ if (sliderFooter != null) {
parameters.put(KEY_SLIDER_FOOTER, sliderFooter);
} else {
parameters.remove(KEY_SLIDER_FOOTER);
@@ -222,13 +213,11 @@ public class Slider extends RPCRequest { public List<String> getSliderFooter() {
if (parameters.get(KEY_SLIDER_FOOTER) instanceof List<?>) {
List<?> list = (List<?>)parameters.get(KEY_SLIDER_FOOTER);
- if (list != null && list.size() > 0) {
- for( Object obj : list ) {
- if (!(obj instanceof String)) {
- return null;
- }
+ if (list != null && list.size()>0) {
+ Object obj = list.get(0);
+ if (obj instanceof String) {
+ return (List<String>) list;
}
- return (List<String>) list;
}
}
return null;
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/Speak.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/Speak.java index 82e749be4..015f70adf 100644 --- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/Speak.java +++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/Speak.java @@ -138,43 +138,16 @@ public class Speak extends RPCRequest { if (parameters.get(KEY_TTS_CHUNKS) instanceof List<?>) {
List<?> list = (List<?>)parameters.get(KEY_TTS_CHUNKS);
if (list != null && list.size() > 0) {
-
- List<TTSChunk> ttsChunkList = new ArrayList<TTSChunk>();
-
- boolean flagRaw = false;
- boolean flagHash = false;
-
- for ( Object obj : list ) {
-
- // This does not currently allow for a mixing of types, meaning
- // there cannot be a raw TTSChunk and a Hashtable value in the
- // same same list. It will not be considered valid currently.
- if (obj instanceof TTSChunk) {
- if (flagHash) {
- return null;
- }
-
- flagRaw = true;
-
- } else if (obj instanceof Hashtable) {
- if (flagRaw) {
- return null;
- }
-
- flagHash = true;
- ttsChunkList.add(new TTSChunk((Hashtable<String, Object>) obj));
-
- } else {
- return null;
- }
-
- }
-
- if (flagRaw) {
- return (List<TTSChunk>) list;
- } else if (flagHash) {
- return ttsChunkList;
- }
+ Object obj = list.get(0);
+ if (obj instanceof TTSChunk) {
+ return (List<TTSChunk>) list;
+ } else if (obj instanceof Hashtable) {
+ List<TTSChunk> newList = new ArrayList<TTSChunk>();
+ for (Object hashObj : list) {
+ newList.add(new TTSChunk((Hashtable<String, Object>)hashObj));
+ }
+ return newList;
+ }
}
}
return null;
@@ -196,16 +169,7 @@ public class Speak extends RPCRequest { * </ul>
*/
public void setTtsChunks( List<TTSChunk> ttsChunks ) {
-
- boolean valid = true;
-
- for (TTSChunk item : ttsChunks ) {
- if (item == null) {
- valid = false;
- }
- }
-
- if ( (ttsChunks != null) && (ttsChunks.size() > 0) && valid) {
+ if (ttsChunks != null) {
parameters.put(KEY_TTS_CHUNKS, ttsChunks );
} else {
parameters.remove(KEY_TTS_CHUNKS);
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SystemRequest.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SystemRequest.java index bb38316b1..f5d8edb12 100644 --- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SystemRequest.java +++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SystemRequest.java @@ -67,28 +67,17 @@ public class SystemRequest extends RPCRequest { if (parameters.get(KEY_DATA) instanceof List<?>) {
List<?> list = (List<?>)parameters.get(KEY_DATA);
if (list != null && list.size()>0) {
- for( Object obj : list ) {
- if (!(obj instanceof String)) {
- return null;
- }
+ Object obj = list.get(0);
+ if (obj instanceof String) {
+ return (List<String>) list;
}
- return (List<String>) list;
}
}
return null;
}
- public void setLegacyData( List<String> data ) {
-
- boolean valid = true;
-
- for ( String item : data ) {
- if (item == null) {
- valid = false;
- }
- }
-
- if ( (data != null) && (data.size() > 0) && valid ) {
+ public void setLegacyData( List<String> data ) {
+ if ( data!= null) {
parameters.put(KEY_DATA, data );
} else {
parameters.remove(KEY_DATA);
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/TouchEvent.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/TouchEvent.java index fb5aa82a8..9b610d58c 100644 --- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/TouchEvent.java +++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/TouchEvent.java @@ -89,22 +89,18 @@ public class TouchEvent extends RPCStruct { if(store.get(KEY_TS) instanceof List<?>){
List<?> list = (List<?>)store.get(KEY_TS);
if(list != null && list.size()>0){
- for( Object obj : list ) {
- if (!(obj instanceof Integer) || !(obj instanceof Long)) {
- return null;
- }
- }
-
- if (list.get(0) instanceof Integer) {
+ Object obj = list.get(0);
+ if(obj instanceof Integer){ //Backwards case
+ int size = list.size();
List<Integer> listOfInt = (List<Integer>) list;
- List<Long> listofLongs = new ArrayList<Long>(list.size());
- for(int i = 0; i < list.size(); i++){
+ List<Long> listofLongs = new ArrayList<Long>(size);
+ for(int i = 0; i<size;i++){
listofLongs.add(listOfInt.get(i).longValue());
}
- return listofLongs;
- } else if (list.get(0) instanceof Long) {
- return (List<Long>) list;
- }
+ return listofLongs;
+ }else if(obj instanceof Long){
+ return (List<Long>) list;
+ }
}
}
return null;
@@ -123,43 +119,16 @@ public class TouchEvent extends RPCStruct { if (store.get(KEY_C) instanceof List<?>) {
List<?> list = (List<?>)store.get(KEY_C);
if (list != null && list.size() > 0) {
-
- List<TouchCoord> touchCoordList = new ArrayList<TouchCoord>();
-
- boolean flagRaw = false;
- boolean flagHash = false;
-
- for ( Object obj : list ) {
-
- // This does not currently allow for a mixing of types, meaning
- // there cannot be a raw TouchCoord and a Hashtable value in the
- // same same list. It will not be considered valid currently.
- if (obj instanceof TouchCoord) {
- if (flagHash) {
- return null;
- }
-
- flagRaw = true;
-
- } else if (obj instanceof Hashtable) {
- if (flagRaw) {
- return null;
- }
-
- flagHash = true;
- touchCoordList.add(new TouchCoord((Hashtable<String, Object>) obj));
-
- } else {
- return null;
- }
-
- }
-
- if (flagRaw) {
- return (List<TouchCoord>) list;
- } else if (flagHash) {
- return touchCoordList;
- }
+ Object obj = list.get(0);
+ if (obj instanceof TouchCoord) {
+ return (List<TouchCoord>) list;
+ } else if (obj instanceof Hashtable) {
+ List<TouchCoord> newList = new ArrayList<TouchCoord>();
+ for (Object hashObj : list) {
+ newList.add(new TouchCoord((Hashtable<String, Object>) hashObj));
+ }
+ return newList;
+ }
}
}
return null;
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/UpdateTurnList.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/UpdateTurnList.java index 48aa4b2b6..fd4f88fa8 100644 --- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/UpdateTurnList.java +++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/UpdateTurnList.java @@ -52,16 +52,7 @@ public class UpdateTurnList extends RPCRequest{ * <b>Notes: </b>Minsize=1; Maxsize=100 */ public void setTurnList(List<Turn> turnList){ - - boolean valid = true; - - for (Turn item : turnList ) { - if (item == null) { - valid = false; - } - } - - if ( (turnList != null) && (turnList.size() > 0) && valid) { + if(turnList != null){ parameters.put(KEY_TURN_LIST, turnList); } else{ @@ -79,43 +70,17 @@ public class UpdateTurnList extends RPCRequest{ if(parameters.get(KEY_TURN_LIST) instanceof List<?>){ List<?> list = (List<?>) parameters.get(KEY_TURN_LIST); if(list != null && list.size() > 0){ - - List<Turn> turnList = new ArrayList<Turn>(); - - boolean flagRaw = false; - boolean flagHash = false; - - for ( Object obj : list ) { - - // This does not currently allow for a mixing of types, meaning - // there cannot be a raw Turn and a Hashtable value in the - // same same list. It will not be considered valid currently. - if (obj instanceof Turn) { - if (flagHash) { - return null; - } - - flagRaw = true; - - } else if (obj instanceof Hashtable) { - if (flagRaw) { - return null; - } - - flagHash = true; - turnList.add(new Turn((Hashtable<String, Object>) obj)); - - } else { - return null; - } - - } - - if (flagRaw) { - return (List<Turn>) list; - } else if (flagHash) { - return turnList; - } + Object obj = list.get(0); + if(obj instanceof Turn){ + return (List<Turn>) list; + } + else if(obj instanceof Hashtable){ + List<Turn> newList = new ArrayList<Turn>(); + for(Object hashObj : list){ + newList.add(new Turn((Hashtable<String, Object>) hashObj)); + } + return newList; + } } } return null; @@ -132,43 +97,17 @@ public class UpdateTurnList extends RPCRequest{ if(parameters.get(KEY_SOFT_BUTTONS) instanceof List<?>){ List<?> list = (List<?>) parameters.get(KEY_SOFT_BUTTONS); if(list != null && list.size() > 0){ - - List<SoftButton> softButtonList = new ArrayList<SoftButton>(); - - boolean flagRaw = false; - boolean flagHash = false; - - for ( Object obj : list ) { - - // This does not currently allow for a mixing of types, meaning - // there cannot be a raw SoftButton and a Hashtable value in the - // same same list. It will not be considered valid currently. - if (obj instanceof SoftButton) { - if (flagHash) { - return null; - } - - flagRaw = true; - - } else if (obj instanceof Hashtable) { - if (flagRaw) { - return null; - } - - flagHash = true; - softButtonList.add(new SoftButton((Hashtable<String, Object>) obj)); - - } else { - return null; - } - - } - - if (flagRaw) { - return (List<SoftButton>) list; - } else if (flagHash) { - return softButtonList; - } + Object obj = list.get(0); + if(obj instanceof SoftButton){ + return (List<SoftButton>) list; + } + else if(obj instanceof Hashtable){ + List<SoftButton> newList = new ArrayList<SoftButton>(); + for(Object hashObj : list){ + newList.add(new SoftButton((Hashtable<String, Object>) hashObj)); + } + return newList; + } } } return null; @@ -190,16 +129,7 @@ public class UpdateTurnList extends RPCRequest{ */ public void setSoftButtons(List<SoftButton> softButtons){ - - boolean valid = true; - - for (SoftButton item : softButtons ) { - if (item == null) { - valid = false; - } - } - - if ( (softButtons != null) && (softButtons.size() > 0) && valid) { + if(softButtons != null){ parameters.put(KEY_SOFT_BUTTONS, softButtons); } else{ |