类com.fasterxml.jackson.annotation.JsonInclude.Value源码实例Demo

下面列出了怎么用com.fasterxml.jackson.annotation.JsonInclude.Value的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: nifi   文件: SiteToSiteCliMain.java
/**
 * Prints the usage to System.out
 *
 * @param errorMessage optional error message
 * @param options      the options object to print usage for
 */
public static void printUsage(String errorMessage, Options options) {
    if (errorMessage != null) {
        System.out.println(errorMessage);
        System.out.println();
        System.out.println();
    }
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.disable(JsonGenerator.Feature.AUTO_CLOSE_TARGET);
    objectMapper.setDefaultPropertyInclusion(Value.construct(JsonInclude.Include.NON_NULL, JsonInclude.Include.ALWAYS));
    System.out.println("s2s is a command line tool that can either read a list of DataPackets from stdin to send over site-to-site or write the received DataPackets to stdout");
    System.out.println();
    System.out.println("The s2s cli input/output format is a JSON list of DataPackets.  They can have the following formats:");
    try {
        System.out.println();
        objectMapper.writeValue(System.out, Arrays.asList(new DataPacketDto("hello nifi".getBytes(StandardCharsets.UTF_8)).putAttribute("key", "value")));
        System.out.println();
        System.out.println("Where data is the base64 encoded value of the FlowFile content (always used for received data) or");
        System.out.println();
        objectMapper.writeValue(System.out, Arrays.asList(new DataPacketDto(new HashMap<>(), new File("EXAMPLE").getAbsolutePath()).putAttribute("key", "value")));
        System.out.println();
        System.out.println("Where dataFile is a file to read the FlowFile content from");
        System.out.println();
        System.out.println();
        System.out.println("Example usage to send a FlowFile with the contents of \"hey nifi\" to a local unsecured NiFi over http with an input port named input:");
        System.out.print("echo '");
        DataPacketDto dataPacketDto = new DataPacketDto("hey nifi".getBytes(StandardCharsets.UTF_8));
        dataPacketDto.setAttributes(null);
        objectMapper.writeValue(System.out, Arrays.asList(dataPacketDto));
        System.out.println("' | bin/s2s.sh -n input -p http");
        System.out.println();
    } catch (IOException e) {
        e.printStackTrace();
    }
    HelpFormatter helpFormatter = new HelpFormatter();
    helpFormatter.setWidth(160);
    helpFormatter.printHelp("s2s", options);
    System.out.flush();
}
 
源代码2 项目: nifi   文件: OkHttpReplicationClient.java
public OkHttpReplicationClient(final NiFiProperties properties) {
    jsonCodec.setDefaultPropertyInclusion(Value.construct(Include.NON_NULL, Include.ALWAYS));
    jsonCodec.setAnnotationIntrospector(new JaxbAnnotationIntrospector(jsonCodec.getTypeFactory()));

    jsonSerializer = new JsonEntitySerializer(jsonCodec);
    xmlSerializer = new XmlEntitySerializer();

    okHttpClient = createOkHttpClient(properties);
}
 
源代码3 项目: Rosetta   文件: RosettaAnnotationIntrospector.java
@Override
public Value findPropertyInclusion(Annotated a) {
  return Value.construct(Include.ALWAYS, Include.ALWAYS);
}
 
源代码4 项目: nifi   文件: ObjectMapperResolver.java
public ObjectMapperResolver() throws Exception {
    mapper = new ObjectMapper();
    mapper.setDefaultPropertyInclusion(Value.construct(Include.NON_NULL, Include.ALWAYS));
    mapper.setAnnotationIntrospector(new JaxbAnnotationIntrospector(mapper.getTypeFactory()));
}
 
 类方法
 同包方法