/xjc-kafka-connect-plugin

Kafka Connect plugin to extend code generated by xjc to produce Kafka Connect Schemas and Structs.

Primary LanguageJava

Introduction

xjc-kafka-connect-plugin is used to extend code generated by xjc. All type classes generated by xjc will be augmented to implement the Connectable interface. The following method is added to each of the classes that are generated by xjc. This will return a Struct that is populated with the graph of the object.

    @Override
    public Struct toConnectStruct() {
        Struct struct = new Struct(CONNECT_SCHEMA);
        struct.put("author", this.getAuthor());
        struct.put("title", this.getTitle());
        struct.put("genre", this.getGenre());
        struct.put("price", this.getPrice());
        if (null!= this.getPubDate()) {
            struct.put("pub_date", this.getPubDate().toGregorianCalendar(TimeZone.getTimeZone("UTC"), null, null).getTime());
        } else {
            struct.put("pub_date", null);
        }
        struct.put("review", this.getReview());
        struct.put("id", this.getId());
        return struct;
    }