Merge "Tron logging - Fix isValidValue to match its name, allow nulls."

This commit is contained in:
TreeHugger Robot
2017-01-25 17:25:15 +00:00
committed by Android (Google) Code Review
2 changed files with 8 additions and 3 deletions

View File

@@ -106,7 +106,7 @@ public class LogMaker {
* @return
*/
public LogMaker addTaggedData(int tag, Object value) {
if (isValidValue(value)) {
if (!isValidValue(value)) {
throw new IllegalArgumentException(
"Value must be loggable type - int, long, float, String");
}
@@ -119,10 +119,14 @@ public class LogMaker {
}
public boolean isValidValue(Object value) {
return !(value instanceof Integer ||
if (value == null) {
Log.i("LogBuilder", "Logging a null value.");
return true;
}
return value instanceof Integer ||
value instanceof String ||
value instanceof Long ||
value instanceof Float);
value instanceof Float;
}
public Object getTaggedData(int tag) {

View File

@@ -100,6 +100,7 @@ public class LogMakerTest extends TestCase {
builder.addTaggedData(2, 123);
builder.addTaggedData(3, 123L);
builder.addTaggedData(4, 123.0F);
builder.addTaggedData(5, null);
Object[] out = builder.serialize();
assertEquals("onetwothree", out[1]);
assertEquals(123, out[3]);