aboutsummaryrefslogtreecommitdiff
path: root/shadows/framework/src/main/java/org/robolectric/shadows/InformationElementBuilder.java
diff options
context:
space:
mode:
Diffstat (limited to 'shadows/framework/src/main/java/org/robolectric/shadows/InformationElementBuilder.java')
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/InformationElementBuilder.java50
1 files changed, 50 insertions, 0 deletions
diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/InformationElementBuilder.java b/shadows/framework/src/main/java/org/robolectric/shadows/InformationElementBuilder.java
new file mode 100644
index 000000000..493244daa
--- /dev/null
+++ b/shadows/framework/src/main/java/org/robolectric/shadows/InformationElementBuilder.java
@@ -0,0 +1,50 @@
+package org.robolectric.shadows;
+
+import static android.os.Build.VERSION_CODES.R;
+
+import android.net.wifi.ScanResult.InformationElement;
+import com.google.errorprone.annotations.CanIgnoreReturnValue;
+import org.robolectric.RuntimeEnvironment;
+
+/** Builder for {@link InformationElement}. */
+public class InformationElementBuilder {
+ private int id;
+ private int idExt;
+ private byte[] bytes;
+
+ private InformationElementBuilder() {}
+
+ public static InformationElementBuilder newBuilder() {
+ return new InformationElementBuilder();
+ }
+
+ @CanIgnoreReturnValue
+ public InformationElementBuilder setId(int id) {
+ this.id = id;
+ return this;
+ }
+
+ @CanIgnoreReturnValue
+ public InformationElementBuilder setIdExt(int idExt) {
+ this.idExt = idExt;
+ return this;
+ }
+
+ @CanIgnoreReturnValue
+ public InformationElementBuilder setBytes(byte[] bytes) {
+ this.bytes = bytes;
+ return this;
+ }
+
+ public InformationElement build() {
+ if (RuntimeEnvironment.getApiLevel() > R) {
+ return new InformationElement(this.id, this.idExt, this.bytes);
+ } else {
+ InformationElement info = new InformationElement();
+ info.id = this.id;
+ info.idExt = this.idExt;
+ info.bytes = this.bytes;
+ return info;
+ }
+ }
+}