Initial commit 🎉
fbshipit-source-id: b6fc29740c6875d2e78953b8a7123890a67930f2 Co-authored-by: Sebastian McKenzie <sebmck@fb.com> Co-authored-by: John Knox <jknox@fb.com> Co-authored-by: Emil Sjölander <emilsj@fb.com> Co-authored-by: Pritesh Nandgaonkar <prit91@fb.com>
This commit is contained in:
51
android/plugins/inspector/SearchResultNode.java
Normal file
51
android/plugins/inspector/SearchResultNode.java
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 2018-present, Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.facebook.sonar.plugins.inspector;
|
||||
|
||||
import android.support.annotation.Nullable;
|
||||
import com.facebook.sonar.core.SonarArray;
|
||||
import com.facebook.sonar.core.SonarObject;
|
||||
import java.util.List;
|
||||
|
||||
public class SearchResultNode {
|
||||
|
||||
private final String id;
|
||||
private final boolean isMatch;
|
||||
private final SonarObject element;
|
||||
@Nullable
|
||||
private final List<SearchResultNode> children;
|
||||
|
||||
SearchResultNode(
|
||||
String id, boolean isMatch, SonarObject element, @Nullable List<SearchResultNode> children) {
|
||||
this.id = id;
|
||||
this.isMatch = isMatch;
|
||||
this.element = element;
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
SonarObject toSonarObject() {
|
||||
final SonarArray childArray;
|
||||
if (children != null) {
|
||||
final SonarArray.Builder builder = new SonarArray.Builder();
|
||||
for (SearchResultNode child : children) {
|
||||
builder.put(child.toSonarObject());
|
||||
}
|
||||
childArray = builder.build();
|
||||
} else {
|
||||
childArray = null;
|
||||
}
|
||||
|
||||
return new SonarObject.Builder()
|
||||
.put("id", this.id)
|
||||
.put("isMatch", this.isMatch)
|
||||
.put("element", this.element)
|
||||
.put("children", childArray)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user