當前位置: 首頁>>代碼示例>>Java>>正文


Java VavrModule類代碼示例

本文整理匯總了Java中io.vavr.jackson.datatype.VavrModule的典型用法代碼示例。如果您正苦於以下問題:Java VavrModule類的具體用法?Java VavrModule怎麽用?Java VavrModule使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


VavrModule類屬於io.vavr.jackson.datatype包,在下文中一共展示了VavrModule類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: initMapper

import io.vavr.jackson.datatype.VavrModule; //導入依賴的package包/類
public static void initMapper(TypeSpec.Builder builder, String name, VavrModule.Settings settings) {
    Modifier[] mods = new Modifier[] { Modifier.PRIVATE, Modifier.STATIC, Modifier.FINAL };
    if (settings != null) {
        builder.addField(FieldSpec.builder(ClassName.get(VavrModule.Settings.class), name + "_SETTINGS", mods)
                .initializer("new $T()\n        .useOptionInPlainFormat($L).deserializeNullAsEmptyCollection($L)",
                        ClassName.get(VavrModule.Settings.class),
                        settings.useOptionInPlainFormat(), settings.deserializeNullAsEmptyCollection())
                .build());
        builder.addField(FieldSpec.builder(ClassName.get(VavrModule.class), name + "_MODULE", mods)
                .initializer("new $T($L)", ClassName.get(VavrModule.class), name + "_SETTINGS")
                .build());
    } else {
        builder.addField(FieldSpec.builder(ClassName.get(VavrModule.class), name + "_MODULE", mods)
                .initializer("new $T()", ClassName.get(VavrModule.class))
                .build());
    }
    builder.addField(FieldSpec.builder(ClassName.get(ObjectMapper.class), name, mods)
            .initializer("new $T().registerModule($L)", ClassName.get(ObjectMapper.class), name + "_MODULE")
            .build());
}
 
開發者ID:vavr-io,項目名稱:vavr-jackson,代碼行數:21,代碼來源:Initializer.java

示例2: test4

import io.vavr.jackson.datatype.VavrModule; //導入依賴的package包/類
@Test
public void test4() throws IOException {
    VavrModule.Settings settings = new VavrModule.Settings();
    settings.deserializeNullAsEmptyCollection(true);
    ObjectMapper mapper = mapper(settings);
    Set<?> restored = mapper.readValue("null", typeReference());
    Assert.assertTrue(restored.isEmpty());
}
 
開發者ID:vavr-io,項目名稱:vavr-jackson,代碼行數:9,代碼來源:SetTest.java

示例3: test4

import io.vavr.jackson.datatype.VavrModule; //導入依賴的package包/類
@Test
public void test4() throws IOException {
    VavrModule.Settings settings = new VavrModule.Settings();
    settings.deserializeNullAsEmptyCollection(true);
    ObjectMapper mapper = mapper(settings);
    Seq<?> restored = (Seq<?>) mapper.readValue("null", clz());
    Assert.assertTrue(restored.isEmpty());
}
 
開發者ID:vavr-io,項目名稱:vavr-jackson,代碼行數:9,代碼來源:SeqTest.java

示例4: json_roundtrip_test

import io.vavr.jackson.datatype.VavrModule; //導入依賴的package包/類
public static <T> void json_roundtrip_test(T value, Class<T> valueType) throws IOException {
    ObjectMapper mapper = new ObjectMapper();
    mapper.registerModule(new VavrModule());
    String asString = mapper.writeValueAsString(value);
    assertNotNull(asString);
    final T value_decoded = mapper.readValue(asString, valueType);
    assertEquals(value, value_decoded);
}
 
開發者ID:vavr-io,項目名稱:vavr-jackson,代碼行數:9,代碼來源:AbstractContentTest.java

示例5: initialize

import io.vavr.jackson.datatype.VavrModule; //導入依賴的package包/類
@Override
public void initialize(Bootstrap<?> bootstrap) {
    bootstrap.getObjectMapper().registerModule(new VavrModule(settings));
    bootstrap.setValidatorFactory(newValidatorFactory());
}
 
開發者ID:dropwizard,項目名稱:dropwizard-vavr,代碼行數:6,代碼來源:VavrBundle.java

示例6: parseJson

import io.vavr.jackson.datatype.VavrModule; //導入依賴的package包/類
public static Schema parseJson(Reader in) throws IOException {
    ObjectMapper mapper = new ObjectMapper();
    mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    mapper.registerModule(new VavrModule());
    return mapper.readValue(in, Schema.class);
}
 
開發者ID:netzwerg,項目名稱:paleo,代碼行數:7,代碼來源:Schema.java

示例7: VavrSerializers

import io.vavr.jackson.datatype.VavrModule; //導入依賴的package包/類
public VavrSerializers(VavrModule.Settings settings) {
    this.settings = settings;
}
 
開發者ID:vavr-io,項目名稱:vavr-jackson,代碼行數:4,代碼來源:VavrSerializers.java

示例8: VavrDeserializers

import io.vavr.jackson.datatype.VavrModule; //導入依賴的package包/類
public VavrDeserializers(VavrModule.Settings settings) {
    this.settings = settings;
}
 
開發者ID:vavr-io,項目名稱:vavr-jackson,代碼行數:4,代碼來源:VavrDeserializers.java

示例9: VavrBundle

import io.vavr.jackson.datatype.VavrModule; //導入依賴的package包/類
/**
 * Add Vavr support (Jackson, Jersey) to Dropwizard.
 *
 * @param registerMessageBodyWriters Register {@link EitherMessageBodyWriter} and {@link ValueMessageBodyWriter}
 *                                   in {@link com.fasterxml.jackson.databind.ObjectMapper}.
 *                                   <em>NOTE:</em> This will make it impossible to serialize or deserialize classes
 *                                   such as {@link io.vavr.control.Either}, {@link io.vavr.control.Option}, and
 *                                   {@link io.vavr.Lazy} with Jackson. Use with care!
 */
public VavrBundle(boolean registerMessageBodyWriters) {
    this(new VavrModule.Settings(), registerMessageBodyWriters);
}
 
開發者ID:dropwizard,項目名稱:dropwizard-vavr,代碼行數:13,代碼來源:VavrBundle.java


注:本文中的io.vavr.jackson.datatype.VavrModule類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。