Tabnine Logo
InputFieldJsonWriter.writeCustom
Code IndexAdd Tabnine to your IDE (free)

How to use
writeCustom
method
in
com.apollographql.apollo.internal.json.InputFieldJsonWriter

Best Java code snippets using com.apollographql.apollo.internal.json.InputFieldJsonWriter.writeCustom (Showing top 5 results out of 315)

origin: apollographql/apollo-android

@Test
public void writeCustomNumber() throws IOException {
 Map<ScalarType, CustomTypeAdapter> customTypeAdapters = new HashMap<>();
 customTypeAdapters.put(new MockCustomScalarType(CustomTypeValue.GraphQLNumber.class), new MockCustomTypeAdapter() {
  @NotNull @Override public CustomTypeValue encode(@NotNull Object value) {
   return new CustomTypeValue.GraphQLNumber((Number) value);
  }
 });
 inputFieldJsonWriter = new InputFieldJsonWriter(jsonWriter, new ScalarTypeAdapters(customTypeAdapters));
 inputFieldJsonWriter.writeCustom("someField", new MockCustomScalarType(CustomTypeValue.GraphQLNumber.class), BigDecimal.valueOf(100.1));
 inputFieldJsonWriter.writeCustom("someNullField", new MockCustomScalarType(CustomTypeValue.GraphQLNumber.class), null);
 assertThat(jsonBuffer.readUtf8()).isEqualTo("{\"someField\":100.1,\"someNullField\":null");
}
origin: apollographql/apollo-android

@Test
public void writeCustomString() throws IOException {
 Map<ScalarType, CustomTypeAdapter> customTypeAdapters = new HashMap<>();
 customTypeAdapters.put(new MockCustomScalarType(CustomTypeValue.GraphQLString.class), new MockCustomTypeAdapter() {
  @NotNull @Override public CustomTypeValue encode(@NotNull Object value) {
   return new CustomTypeValue.GraphQLString((String) value);
  }
 });
 inputFieldJsonWriter = new InputFieldJsonWriter(jsonWriter, new ScalarTypeAdapters(customTypeAdapters));
 inputFieldJsonWriter.writeCustom("someField", new MockCustomScalarType(CustomTypeValue.GraphQLString.class), "someValue");
 inputFieldJsonWriter.writeCustom("someNullField", new MockCustomScalarType(CustomTypeValue.GraphQLString.class), null);
 assertThat(jsonBuffer.readUtf8()).isEqualTo("{\"someField\":\"someValue\",\"someNullField\":null");
}
origin: apollographql/apollo-android

@Test
public void writeCustomBoolean() throws IOException {
 Map<ScalarType, CustomTypeAdapter> customTypeAdapters = new HashMap<>();
 customTypeAdapters.put(new MockCustomScalarType(CustomTypeValue.GraphQLBoolean.class), new MockCustomTypeAdapter() {
  @NotNull @Override public CustomTypeValue encode(@NotNull Object value) {
   return new CustomTypeValue.GraphQLBoolean((Boolean) value);
  }
 });
 inputFieldJsonWriter = new InputFieldJsonWriter(jsonWriter, new ScalarTypeAdapters(customTypeAdapters));
 inputFieldJsonWriter.writeCustom("someField", new MockCustomScalarType(CustomTypeValue.GraphQLBoolean.class), true);
 inputFieldJsonWriter.writeCustom("someNullField", new MockCustomScalarType(CustomTypeValue.GraphQLBoolean.class), null);
 assertThat(jsonBuffer.readUtf8()).isEqualTo("{\"someField\":true,\"someNullField\":null");
}
origin: apollographql/apollo-android

@Test
public void writeCustomJsonString() throws IOException {
 Map<ScalarType, CustomTypeAdapter> customTypeAdapters = new HashMap<>();
 customTypeAdapters.put(new MockCustomScalarType(CustomTypeValue.GraphQLJsonString.class), new MockCustomTypeAdapter() {
  @NotNull @Override public CustomTypeValue encode(@NotNull Object value) {
   return new CustomTypeValue.GraphQLJsonString((String) value);
  }
 });
 inputFieldJsonWriter = new InputFieldJsonWriter(jsonWriter, new ScalarTypeAdapters(customTypeAdapters));
 inputFieldJsonWriter.writeCustom("someField", new MockCustomScalarType(CustomTypeValue.GraphQLJsonString.class), "{\"someField\": \"someValue\"}");
 inputFieldJsonWriter.writeCustom("someNullField", new MockCustomScalarType(CustomTypeValue.GraphQLJsonString.class), null);
 assertThat(jsonBuffer.readUtf8()).isEqualTo("{\"someField\":\"{\\\"someField\\\": \\\"someValue\\\"}\",\"someNullField\":null");
}
origin: apollographql/apollo-android

@Test
public void writeCustomJson() throws IOException {
 Map<ScalarType, CustomTypeAdapter> customTypeAdapters = new HashMap<>();
 customTypeAdapters.put(new MockCustomScalarType(CustomTypeValue.GraphQLJson.class), new MockCustomTypeAdapter() {
  @NotNull @Override public CustomTypeValue encode(@NotNull Object value) {
   return new CustomTypeValue.GraphQLJson((Map<String, Object>) value);
  }
 });
 inputFieldJsonWriter = new InputFieldJsonWriter(jsonWriter, new ScalarTypeAdapters(customTypeAdapters));
 Map<String, Object> objectMap = new LinkedHashMap<>();
 objectMap.put("booleanField", true);
 objectMap.put("stringField", "someValue");
 objectMap.put("numberField", 100);
 objectMap.put("objectField", new UnmodifiableMapBuilder().put("someField", "someValue").build());
 inputFieldJsonWriter.writeCustom("someField", new MockCustomScalarType(CustomTypeValue.GraphQLJson.class), objectMap);
 inputFieldJsonWriter.writeCustom("someNullField", new MockCustomScalarType(CustomTypeValue.GraphQLJson.class), null);
 assertThat(jsonBuffer.readUtf8()).isEqualTo("{\"someField\":{\"booleanField\":true,\"stringField\":\"someValue\",\"numberField\":100,\"objectField\":{\"someField\":\"someValue\"}},\"someNullField\":null");
}
com.apollographql.apollo.internal.jsonInputFieldJsonWriterwriteCustom

Popular methods of InputFieldJsonWriter

  • <init>
  • writeString
  • writeBoolean
  • writeNumber
  • writeDouble
  • writeInt
  • writeList
  • writeLong
  • writeMap
  • writeObject

Popular in Java

  • Updating database using SQL prepared statement
  • getApplicationContext (Context)
  • notifyDataSetChanged (ArrayAdapter)
  • getSharedPreferences (Context)
  • Pointer (com.sun.jna)
    An abstraction for a native pointer data type. A Pointer instance represents, on the Java side, a na
  • HttpURLConnection (java.net)
    An URLConnection for HTTP (RFC 2616 [http://tools.ietf.org/html/rfc2616]) used to send and receive d
  • ZipFile (java.util.zip)
    This class provides random read access to a zip file. You pay more to read the zip file's central di
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • Project (org.apache.tools.ant)
    Central representation of an Ant project. This class defines an Ant project with all of its targets,
  • DateTimeFormat (org.joda.time.format)
    Factory that creates instances of DateTimeFormatter from patterns and styles. Datetime formatting i
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now