From 0e126ad99910ebf3dbd39a11da94e56f2da3fe21 Mon Sep 17 00:00:00 2001 From: Jakub Stejskal Date: Fri, 19 Jul 2024 23:01:43 +0200 Subject: [PATCH 1/2] Generate data from Avro schemas that could be used for data validation Signed-off-by: Jakub Stejskal --- checkstyle.xml => .checkstyle/checkstyle.xml | 0 .checkstyle/suppressions.xml | 13 + .spotbugs/spotbugs-exclude.xml | 6 + README.md | 4 +- pom.xml | 41 +- src/main/avro/Flights.avsc | 81 ++ src/main/avro/IotDevice.avsc | 171 +++ src/main/avro/PaymentFiat.avsc | 147 +++ src/main/avro/Payroll.avsc | 43 + src/main/avro/StarGate.avsc | 39 + src/main/avro/StarWars.avsc | 43 + .../skodjob/datagenerator/DataGenerator.java | 28 +- .../datagenerator/enums/ETemplateType.java | 24 +- .../datagenerator/handlers/Flights.java | 77 -- .../handlers/FlightsHandler.java | 67 ++ .../datagenerator/handlers/IotDevice.java | 131 --- .../handlers/IotDeviceHandler.java | 153 +++ .../datagenerator/handlers/PaymentFiat.java | 191 --- .../handlers/PaymentFiatHandler.java | 160 +++ .../datagenerator/handlers/Payroll.java | 58 - .../handlers/PayrollHandler.java | 49 + .../datagenerator/handlers/StarGate.java | 54 - .../handlers/StarGateHandler.java | 47 + .../datagenerator/handlers/StarWars.java | 59 - .../handlers/StarWarsHandler.java | 48 + .../datagenerator/models/flights/Flight.java | 1039 +++++++++++++++++ .../models/flights/FlightRecord.java | 511 ++++++++ .../models/flights/Passenger.java | 559 +++++++++ .../models/iotdevice/Battery.java | 398 +++++++ .../models/iotdevice/ButtonData.java | 455 ++++++++ .../models/iotdevice/CustomData.java | 399 +++++++ .../models/iotdevice/EnergyCurrent.java | 398 +++++++ .../models/iotdevice/EnergyToday.java | 398 +++++++ .../models/iotdevice/GateData.java | 399 +++++++ .../models/iotdevice/IotDevice.java | 721 ++++++++++++ .../models/iotdevice/LightData.java | 478 ++++++++ .../models/iotdevice/PlugData.java | 591 ++++++++++ .../models/iotdevice/ThermometerData.java | 533 +++++++++ .../models/paymentfiat/Address.java | 639 ++++++++++ .../models/paymentfiat/Payee.java | 694 +++++++++++ .../models/paymentfiat/Payer.java | 983 ++++++++++++++++ .../models/paymentfiat/Payment.java | 717 ++++++++++++ .../models/paymentfiat/PaymentDetails.java | 717 ++++++++++++ .../models/paymentfiat/PaymentFiat.java | 647 ++++++++++ .../models/payroll/Employee.java | 957 +++++++++++++++ .../models/stargate/StarGate.java | 877 ++++++++++++++ .../models/starwars/StarWars.java | 959 +++++++++++++++ .../datagenerator/DataGeneratorTest.java | 37 +- 48 files changed, 15222 insertions(+), 618 deletions(-) rename checkstyle.xml => .checkstyle/checkstyle.xml (100%) create mode 100644 .checkstyle/suppressions.xml create mode 100644 .spotbugs/spotbugs-exclude.xml create mode 100644 src/main/avro/Flights.avsc create mode 100644 src/main/avro/IotDevice.avsc create mode 100644 src/main/avro/PaymentFiat.avsc create mode 100644 src/main/avro/Payroll.avsc create mode 100644 src/main/avro/StarGate.avsc create mode 100644 src/main/avro/StarWars.avsc delete mode 100644 src/main/java/io/skodjob/datagenerator/handlers/Flights.java create mode 100644 src/main/java/io/skodjob/datagenerator/handlers/FlightsHandler.java delete mode 100644 src/main/java/io/skodjob/datagenerator/handlers/IotDevice.java create mode 100644 src/main/java/io/skodjob/datagenerator/handlers/IotDeviceHandler.java delete mode 100644 src/main/java/io/skodjob/datagenerator/handlers/PaymentFiat.java create mode 100644 src/main/java/io/skodjob/datagenerator/handlers/PaymentFiatHandler.java delete mode 100644 src/main/java/io/skodjob/datagenerator/handlers/Payroll.java create mode 100644 src/main/java/io/skodjob/datagenerator/handlers/PayrollHandler.java delete mode 100644 src/main/java/io/skodjob/datagenerator/handlers/StarGate.java create mode 100644 src/main/java/io/skodjob/datagenerator/handlers/StarGateHandler.java delete mode 100644 src/main/java/io/skodjob/datagenerator/handlers/StarWars.java create mode 100644 src/main/java/io/skodjob/datagenerator/handlers/StarWarsHandler.java create mode 100644 src/main/java/io/skodjob/datagenerator/models/flights/Flight.java create mode 100644 src/main/java/io/skodjob/datagenerator/models/flights/FlightRecord.java create mode 100644 src/main/java/io/skodjob/datagenerator/models/flights/Passenger.java create mode 100644 src/main/java/io/skodjob/datagenerator/models/iotdevice/Battery.java create mode 100644 src/main/java/io/skodjob/datagenerator/models/iotdevice/ButtonData.java create mode 100644 src/main/java/io/skodjob/datagenerator/models/iotdevice/CustomData.java create mode 100644 src/main/java/io/skodjob/datagenerator/models/iotdevice/EnergyCurrent.java create mode 100644 src/main/java/io/skodjob/datagenerator/models/iotdevice/EnergyToday.java create mode 100644 src/main/java/io/skodjob/datagenerator/models/iotdevice/GateData.java create mode 100644 src/main/java/io/skodjob/datagenerator/models/iotdevice/IotDevice.java create mode 100644 src/main/java/io/skodjob/datagenerator/models/iotdevice/LightData.java create mode 100644 src/main/java/io/skodjob/datagenerator/models/iotdevice/PlugData.java create mode 100644 src/main/java/io/skodjob/datagenerator/models/iotdevice/ThermometerData.java create mode 100644 src/main/java/io/skodjob/datagenerator/models/paymentfiat/Address.java create mode 100644 src/main/java/io/skodjob/datagenerator/models/paymentfiat/Payee.java create mode 100644 src/main/java/io/skodjob/datagenerator/models/paymentfiat/Payer.java create mode 100644 src/main/java/io/skodjob/datagenerator/models/paymentfiat/Payment.java create mode 100644 src/main/java/io/skodjob/datagenerator/models/paymentfiat/PaymentDetails.java create mode 100644 src/main/java/io/skodjob/datagenerator/models/paymentfiat/PaymentFiat.java create mode 100644 src/main/java/io/skodjob/datagenerator/models/payroll/Employee.java create mode 100644 src/main/java/io/skodjob/datagenerator/models/stargate/StarGate.java create mode 100644 src/main/java/io/skodjob/datagenerator/models/starwars/StarWars.java diff --git a/checkstyle.xml b/.checkstyle/checkstyle.xml similarity index 100% rename from checkstyle.xml rename to .checkstyle/checkstyle.xml diff --git a/.checkstyle/suppressions.xml b/.checkstyle/suppressions.xml new file mode 100644 index 0000000..396a599 --- /dev/null +++ b/.checkstyle/suppressions.xml @@ -0,0 +1,13 @@ + + + + + + + + + + diff --git a/.spotbugs/spotbugs-exclude.xml b/.spotbugs/spotbugs-exclude.xml new file mode 100644 index 0000000..f4cfee4 --- /dev/null +++ b/.spotbugs/spotbugs-exclude.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/README.md b/README.md index a301b25..7baab5d 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ import io.skodjob.datagenerator.enums.ETemplateType; public class Main { public static void main(String[] args) { DataGenerator dataGenerator = new DataGenerator(ETemplateType.PAYMENT_FIAT); - String paymentDataString = dataGenerator.generateStringData(); + String paymentDataString = dataGenerator.generateData(); JsonNode paymentDataJson = dataGenerator.generateJsonData(); System.out.println(paymentDataString); } @@ -66,7 +66,7 @@ import io.skodjob.datagenerator.enums.ETemplateType; public class Main { public static void main(String[] args) { DataGenerator dataGenerator = new DataGenerator(ETemplateType.FLIGHTS); - String paymentDataString = dataGenerator.generateStringData(); + String paymentDataString = dataGenerator.generateData(); JsonNode paymentDataJson = dataGenerator.generateJsonData(); System.out.println(paymentDataString); } diff --git a/pom.xml b/pom.xml index 8b3c250..c62ed0f 100644 --- a/pom.xml +++ b/pom.xml @@ -89,6 +89,7 @@ 1.10.3 3.3.1 2.3.1 + 1.11.3 2.17.2 @@ -100,8 +101,6 @@ true ${skipTests} - - checkstyle.xml @@ -181,6 +180,18 @@ datafaker ${datafaker.version} + + + org.apache.avro + avro + ${avro.version} + + + + org.apache.avro + avro-tools + ${avro.version} + @@ -213,6 +224,8 @@ true ${project.build.directory}/spotbugs + + ${project.basedir}/.spotbugs/spotbugs-exclude.xml @@ -229,6 +242,7 @@ public true true + io.skodjob.datagenerator.models.* @@ -244,6 +258,8 @@ true true + .checkstyle/checkstyle.xml + .checkstyle/suppressions.xml check @@ -326,6 +342,27 @@ true + + + + org.apache.avro + avro-maven-plugin + ${avro.version} + + + generate-sources + + schema + + + + + ${project.basedir}/src/main/avro + ${project.basedir}/src/main/java + + + + central-sonatype diff --git a/src/main/avro/Flights.avsc b/src/main/avro/Flights.avsc new file mode 100644 index 0000000..93b256c --- /dev/null +++ b/src/main/avro/Flights.avsc @@ -0,0 +1,81 @@ +{ + "type": "record", + "name": "FlightRecord", + "namespace": "io.skodjob.datagenerator.models.flights", + "fields": [ + { + "name": "passenger", + "type": { + "type": "record", + "name": "Passenger", + "fields": [ + { + "name": "id", + "type": "string" + }, + { + "name": "name", + "type": "string" + }, + { + "name": "passport_number", + "type": "string" + }, + { + "name": "nationality", + "type": "string" + } + ] + } + }, + { + "name": "flight", + "type": { + "type": "record", + "name": "Flight", + "fields": [ + { + "name": "number", + "type": "string" + }, + { + "name": "departure_airport", + "type": "string" + }, + { + "name": "arrival_airport", + "type": "string" + }, + { + "name": "departure_time", + "type": "string" + }, + { + "name": "arrival_time", + "type": "string" + }, + { + "name": "seat_number", + "type": "string" + }, + { + "name": "gate", + "type": "string" + }, + { + "name": "boarding_group", + "type": "string" + }, + { + "name": "plane_model", + "type": "string" + }, + { + "name": "airline", + "type": "string" + } + ] + } + } + ] +} diff --git a/src/main/avro/IotDevice.avsc b/src/main/avro/IotDevice.avsc new file mode 100644 index 0000000..666768c --- /dev/null +++ b/src/main/avro/IotDevice.avsc @@ -0,0 +1,171 @@ +{ + "type": "record", + "name": "IotDevice", + "namespace": "io.skodjob.datagenerator.models.iotdevice", + "fields": [ + { + "name": "IPV4", + "type": "string" + }, + { + "name": "MAC", + "type": "string" + }, + { + "name": "ID", + "type": "string" + }, + { + "name": "TYPE", + "type": "string" + }, + { + "name": "LAST_UPDATE", + "type": "string" + }, + { + "name": "LINK_QUALITY", + "type": "int" + }, + { + "name": "DATA", + "type": [ + { + "type": "record", + "name": "CustomData", + "fields": [ + { + "name": "info", + "type": "string" + }, + { + "name": "state", + "type": "string" + } + ] + }, + { + "type": "record", + "name": "ButtonData", + "fields": [ + { + "name": "power", + "type": "string" + }, + { + "name": "battery", + "type": { + "type": "record", + "name": "Battery", + "fields": [ + { + "name": "value", + "type": "int" + }, + { + "name": "unit", + "type": "string" + } + ] + } + } + ] + }, + { + "type": "record", + "name": "PlugData", + "fields": [ + { + "name": "power", + "type": "string" + }, + { + "name": "energy_current", + "type": { + "type": "record", + "name": "EnergyCurrent", + "fields": [ + { + "name": "state", + "type": "float" + }, + { + "name": "unit", + "type": "string" + } + ] + } + }, + { + "name": "energy_today", + "type": { + "type": "record", + "name": "EnergyToday", + "fields": [ + { + "name": "state", + "type": "float" + }, + { + "name": "unit", + "type": "string" + } + ] + } + } + ] + }, + { + "type": "record", + "name": "ThermometerData", + "fields": [ + { + "name": "temperature", + "type": "float" + }, + { + "name": "humidity", + "type": "float" + }, + { + "name": "battery", + "type": "io.skodjob.datagenerator.models.iotdevice.Battery" + } + ] + }, + { + "type": "record", + "name": "GateData", + "fields": [ + { + "name": "vendor", + "type": "string" + }, + { + "name": "state", + "type": "string" + } + ] + }, + { + "type": "record", + "name": "LightData", + "fields": [ + { + "name": "power", + "type": "string" + }, + { + "name": "brightness", + "type": "int" + }, + { + "name": "power_on_behavior", + "type": "string" + } + ] + } + ] + } + ] +} diff --git a/src/main/avro/PaymentFiat.avsc b/src/main/avro/PaymentFiat.avsc new file mode 100644 index 0000000..30e3f48 --- /dev/null +++ b/src/main/avro/PaymentFiat.avsc @@ -0,0 +1,147 @@ +{ + "type": "record", + "name": "PaymentFiat", + "namespace": "io.skodjob.datagenerator.models.paymentfiat", + "fields": [ + { + "name": "paymentDetails", + "type": { + "type": "record", + "name": "PaymentDetails", + "fields": [ + { + "name": "transactionId", + "type": "string" + }, + { + "name": "type", + "type": "string" + }, + { + "name": "amount", + "type": "double" + }, + { + "name": "currency", + "type": "string" + }, + { + "name": "date", + "type": "string" + }, + { + "name": "status", + "type": "string" + } + ] + } + }, + { + "name": "payer", + "type": { + "type": "record", + "name": "Payer", + "fields": [ + { + "name": "name", + "type": "string" + }, + { + "name": "payerType", + "type": "string" + }, + { + "name": "accountNumber", + "type": "string" + }, + { + "name": "bank", + "type": "string" + }, + { + "name": "billingAddress", + "type": { + "type": "record", + "name": "Address", + "fields": [ + { + "name": "street", + "type": "string" + }, + { + "name": "city", + "type": "string" + }, + { + "name": "state", + "type": "string" + }, + { + "name": "country", + "type": "string" + }, + { + "name": "postalCode", + "type": "string" + } + ] + } + }, + { + "name": "cardNumber", + "type": [ + "null", + "string" + ], + "default": null + }, + { + "name": "cardType", + "type": [ + "null", + "string" + ], + "default": null + }, + { + "name": "expiryDate", + "type": [ + "null", + "string" + ], + "default": null + } + ] + } + }, + { + "name": "payee", + "type": { + "type": "record", + "name": "Payee", + "fields": [ + { + "name": "name", + "type": "string" + }, + { + "name": "payeeType", + "type": "string" + }, + { + "name": "accountNumber", + "type": "string" + }, + { + "name": "bank", + "type": "string" + }, + { + "name": "address", + "type": "Address" + } + ] + } + } + ] +} diff --git a/src/main/avro/Payroll.avsc b/src/main/avro/Payroll.avsc new file mode 100644 index 0000000..14655d2 --- /dev/null +++ b/src/main/avro/Payroll.avsc @@ -0,0 +1,43 @@ +{ + "type": "record", + "name": "Employee", + "namespace": "io.skodjob.datagenerator.models.payroll", + "fields": [ + { + "name": "employeeId", + "type": "string" + }, + { + "name": "firstName", + "type": "string" + }, + { + "name": "lastName", + "type": "string" + }, + { + "name": "age", + "type": "int" + }, + { + "name": "ssn", + "type": "string" + }, + { + "name": "hourlyRate", + "type": "float" + }, + { + "name": "gender", + "type": "string" + }, + { + "name": "email", + "type": "string" + }, + { + "name": "company", + "type": "string" + } + ] +} diff --git a/src/main/avro/StarGate.avsc b/src/main/avro/StarGate.avsc new file mode 100644 index 0000000..4b9c923 --- /dev/null +++ b/src/main/avro/StarGate.avsc @@ -0,0 +1,39 @@ +{ + "type": "record", + "name": "StarGate", + "namespace": "io.skodjob.datagenerator.models.stargate", + "fields": [ + { + "name": "character_name", + "type": "string" + }, + { + "name": "source_planet", + "type": "string" + }, + { + "name": "target_planet", + "type": "string" + }, + { + "name": "quote", + "type": "string" + }, + { + "name": "duration", + "type": "int" + }, + { + "name": "duration_unit", + "type": "string" + }, + { + "name": "distance", + "type": "int" + }, + { + "name": "distance_unit", + "type": "string" + } + ] +} diff --git a/src/main/avro/StarWars.avsc b/src/main/avro/StarWars.avsc new file mode 100644 index 0000000..858b584 --- /dev/null +++ b/src/main/avro/StarWars.avsc @@ -0,0 +1,43 @@ +{ + "type": "record", + "name": "StarWars", + "namespace": "io.skodjob.datagenerator.models.starwars", + "fields": [ + { + "name": "character_name", + "type": "string" + }, + { + "name": "source_planet", + "type": "string" + }, + { + "name": "target_planet", + "type": "string" + }, + { + "name": "quote", + "type": "string" + }, + { + "name": "callSign", + "type": "string" + }, + { + "name": "species", + "type": "string" + }, + { + "name": "vehicle", + "type": "string" + }, + { + "name": "wookieWords", + "type": "string" + }, + { + "name": "alternateCharacterSpelling", + "type": "string" + } + ] +} diff --git a/src/main/java/io/skodjob/datagenerator/DataGenerator.java b/src/main/java/io/skodjob/datagenerator/DataGenerator.java index 08a758f..e719a4a 100644 --- a/src/main/java/io/skodjob/datagenerator/DataGenerator.java +++ b/src/main/java/io/skodjob/datagenerator/DataGenerator.java @@ -7,12 +7,12 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import io.skodjob.datagenerator.enums.ETemplateType; -import io.skodjob.datagenerator.handlers.Flights; -import io.skodjob.datagenerator.handlers.IotDevice; -import io.skodjob.datagenerator.handlers.PaymentFiat; -import io.skodjob.datagenerator.handlers.Payroll; -import io.skodjob.datagenerator.handlers.StarGate; -import io.skodjob.datagenerator.handlers.StarWars; +import io.skodjob.datagenerator.handlers.FlightsHandler; +import io.skodjob.datagenerator.handlers.IotDeviceHandler; +import io.skodjob.datagenerator.handlers.PaymentFiatHandler; +import io.skodjob.datagenerator.handlers.PayrollHandler; +import io.skodjob.datagenerator.handlers.StarGateHandler; +import io.skodjob.datagenerator.handlers.StarWarsHandler; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -41,20 +41,20 @@ public DataGenerator(ETemplateType templateType) { * * @return the generated string data */ - public String generateStringData() { + public String generateData() { switch (this.templateType) { case PAYROLL: - return Payroll.generateData(); + return PayrollHandler.generateData(); case IOT_DEVICE: - return IotDevice.generateData(); + return IotDeviceHandler.generateData(); case STARGATE: - return StarGate.generateData(); + return StarGateHandler.generateData(); case STARWARS: - return StarWars.generateData(); + return StarWarsHandler.generateData(); case PAYMENT_FIAT: - return PaymentFiat.generateData(); + return PaymentFiatHandler.generateData(); case FLIGHTS: - return Flights.generateData(); + return FlightsHandler.generateData(); default: throw new IllegalArgumentException("Unknown template type: " + this.templateType); } @@ -67,7 +67,7 @@ public String generateStringData() { */ public JsonNode generateJsonData() { try { - return new ObjectMapper().readTree(generateStringData()); + return new ObjectMapper().readTree(generateData()); } catch (Exception e) { throw new RuntimeException("Error generating JSON data", e); } diff --git a/src/main/java/io/skodjob/datagenerator/enums/ETemplateType.java b/src/main/java/io/skodjob/datagenerator/enums/ETemplateType.java index 96e78bd..e683e5c 100644 --- a/src/main/java/io/skodjob/datagenerator/enums/ETemplateType.java +++ b/src/main/java/io/skodjob/datagenerator/enums/ETemplateType.java @@ -4,12 +4,12 @@ */ package io.skodjob.datagenerator.enums; -import io.skodjob.datagenerator.handlers.Flights; -import io.skodjob.datagenerator.handlers.IotDevice; -import io.skodjob.datagenerator.handlers.PaymentFiat; -import io.skodjob.datagenerator.handlers.Payroll; -import io.skodjob.datagenerator.handlers.StarGate; -import io.skodjob.datagenerator.handlers.StarWars; +import io.skodjob.datagenerator.handlers.FlightsHandler; +import io.skodjob.datagenerator.handlers.IotDeviceHandler; +import io.skodjob.datagenerator.handlers.PaymentFiatHandler; +import io.skodjob.datagenerator.handlers.PayrollHandler; +import io.skodjob.datagenerator.handlers.StarGateHandler; +import io.skodjob.datagenerator.handlers.StarWarsHandler; /** * Enum representing different template types for use in the load generator. @@ -18,32 +18,32 @@ public enum ETemplateType { /** * Template for People Payrol data */ - PAYROLL(Payroll.TEMPLATE_NAME), + PAYROLL(PayrollHandler.TEMPLATE_NAME), /** * Template for IoT device data */ - IOT_DEVICE(IotDevice.TEMPLATE_NAME), + IOT_DEVICE(IotDeviceHandler.TEMPLATE_NAME), /** * Template for StarGate data */ - STARGATE(StarGate.TEMPLATE_NAME), + STARGATE(StarGateHandler.TEMPLATE_NAME), /** * Template for StarWars data */ - STARWARS(StarWars.TEMPLATE_NAME), + STARWARS(StarWarsHandler.TEMPLATE_NAME), /** * Template for Payment data */ - PAYMENT_FIAT(PaymentFiat.TEMPLATE_NAME), + PAYMENT_FIAT(PaymentFiatHandler.TEMPLATE_NAME), /** * Template for Flights data */ - FLIGHTS(Flights.TEMPLATE_NAME); + FLIGHTS(FlightsHandler.TEMPLATE_NAME); private final String templateName; diff --git a/src/main/java/io/skodjob/datagenerator/handlers/Flights.java b/src/main/java/io/skodjob/datagenerator/handlers/Flights.java deleted file mode 100644 index bf9d8a2..0000000 --- a/src/main/java/io/skodjob/datagenerator/handlers/Flights.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright Skodjob authors. - * License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html). - */ -package io.skodjob.datagenerator.handlers; - -import net.datafaker.Faker; - -import java.time.ZoneOffset; -import java.util.Locale; - -/** - * This class is responsible for generating flight data using the Faker library. - */ -public class Flights { - - /** - * Private constructor to make class static - */ - private Flights() { - - } - - private static final Faker FAKER = new Faker(); - - /** - * Template name used in the generator - */ - public static final String TEMPLATE_NAME = "flights"; - - /** - * Generates flight data using the Faker library. - * - * @return the generated flight data as a JSON string - */ - public static String generateData() { - String passengerId = FAKER.idNumber().valid(); - String passengerName = FAKER.name().fullName(); - String passportNumber = FAKER.regexify("[A-Z]{2}[0-9]{6}"); - String nationality = FAKER.nation().nationality(); - String flightNumber = FAKER.regexify("[A-Z]{2}[0-9]{4}"); - String departureAirport = FAKER.aviation().airport(); - String arrivalAirport = FAKER.aviation().airport(); - String departureTime = FAKER.timeAndDate().future(1, java.util.concurrent.TimeUnit.DAYS) - .atOffset(ZoneOffset.UTC).toString(); - String arrivalTime = FAKER.timeAndDate().future(2, java.util.concurrent.TimeUnit.DAYS) - .atOffset(ZoneOffset.UTC).toString(); - String seatNumber = FAKER.regexify("[A-Z][0-9]{2}"); - String gate = FAKER.regexify("[A-Z][0-9]{1,2}"); - String boardingGroup = FAKER.options().option("A", "B", "C", "D", "E", "F"); - String planeModel = FAKER.aviation().aircraft(); - String airline = FAKER.aviation().airline(); - - return String.format(Locale.US, - "{\"passenger\":{" + - "\"id\":\"%s\"," + - "\"name\":\"%s\"," + - "\"passport_number\":\"%s\"," + - "\"nationality\":\"%s\"" + - "}," + - "\"flight\":{" + - "\"number\":\"%s\"," + - "\"departure_airport\":\"%s\"," + - "\"arrival_airport\":\"%s\"," + - "\"departure_time\":\"%s\"," + - "\"arrival_time\":\"%s\"," + - "\"seat_number\":\"%s\"," + - "\"gate\":\"%s\"," + - "\"boarding_group\":\"%s\"," + - "\"plane_model\":\"%s\"," + - "\"airline\":\"%s\"" + - "}}", - passengerId, passengerName, passportNumber, nationality, - flightNumber, departureAirport, arrivalAirport, departureTime, arrivalTime, seatNumber, gate, boardingGroup, - planeModel, airline); - } -} diff --git a/src/main/java/io/skodjob/datagenerator/handlers/FlightsHandler.java b/src/main/java/io/skodjob/datagenerator/handlers/FlightsHandler.java new file mode 100644 index 0000000..b60fa62 --- /dev/null +++ b/src/main/java/io/skodjob/datagenerator/handlers/FlightsHandler.java @@ -0,0 +1,67 @@ +/* + * Copyright Skodjob authors. + * License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html). + */ +package io.skodjob.datagenerator.handlers; + +import io.skodjob.datagenerator.models.flights.Flight; +import io.skodjob.datagenerator.models.flights.FlightRecord; +import io.skodjob.datagenerator.models.flights.Passenger; +import net.datafaker.Faker; + +import java.time.ZoneOffset; +import java.util.concurrent.TimeUnit; + +/** + * This class is responsible for generating flight data using the Faker library. + */ +public class FlightsHandler { + + /** + * Private constructor to make class static + */ + private FlightsHandler() { + + } + + private static final Faker FAKER = new Faker(); + + /** + * Template name used in the generator + */ + public static final String TEMPLATE_NAME = "flights"; + + /** + * Generates flight data using the Faker library. + * + * @return the generated flight data as a JSON string + */ + public static String generateData() { + FlightRecord flightRecord = new FlightRecord(); + + Passenger passenger = new Passenger(); + passenger.setId(FAKER.idNumber().valid()); + passenger.setName(FAKER.name().fullName()); + passenger.setPassportNumber(FAKER.regexify("[A-Z]{2}[0-9]{6}")); + passenger.setNationality(FAKER.nation().nationality()); + + Flight flight = new Flight(); + flight.setNumber(FAKER.regexify("[A-Z]{2}[0-9]{4}")); + flight.setDepartureAirport(FAKER.aviation().airport()); + flight.setArrivalAirport(FAKER.aviation().airport()); + flight.setDepartureTime(FAKER.timeAndDate().future(1, TimeUnit.HOURS) + .atOffset(ZoneOffset.UTC).toString()); + flight.setArrivalTime(FAKER.timeAndDate().future(2, TimeUnit.HOURS) + .atOffset(ZoneOffset.UTC).toString()); + flight.setSeatNumber(FAKER.regexify("[A-Z][0-9]{2}")); + flight.setGate(FAKER.regexify("[A-Z][0-9]{1,2}")); + flight.setBoardingGroup(FAKER.options().option("A", "B", "C", "D", "E", "F")); + flight.setPlaneModel(FAKER.aviation().aircraft()); + flight.setAirline(FAKER.aviation().airline()); + + flightRecord.setPassenger(passenger); + flightRecord.setFlight(flight); + + return flightRecord.toString(); + } +} diff --git a/src/main/java/io/skodjob/datagenerator/handlers/IotDevice.java b/src/main/java/io/skodjob/datagenerator/handlers/IotDevice.java deleted file mode 100644 index 116dd9f..0000000 --- a/src/main/java/io/skodjob/datagenerator/handlers/IotDevice.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright Skodjob authors. - * License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html). - */ -package io.skodjob.datagenerator.handlers; - -import net.datafaker.Faker; - -import java.util.Locale; - -/** - * This class is responsible for generating IoT device data using the Faker library. - */ -public class IotDevice { - - /** - * Private constructor to make class static - */ - private IotDevice() { - - } - - private static final Faker FAKER = new Faker(); - - /** - * Template name used in the generator - */ - public static final String TEMPLATE_NAME = "iot_device"; - - private static final String TYPE_LIGHT = "light"; - private static final String TYPE_BUTTON = "button"; - private static final String TYPE_THERMOMETER = "thermometer"; - private static final String TYPE_PLUG = "plug"; - private static final String TYPE_CUSTOM = "custom"; - private static final String TYPE_GATE = "gate"; - - /** - * Generates a random power state (on/off). - * - * @return a randomly generated power state - */ - private static String generatePowerState() { - return FAKER.options().option("on", "off"); - } - - /** - * Generates a random power on behavior (on/off/toggle/previous). - * - * @return a randomly generated power on behavior - */ - private static String generatePowerOnBehavior() { - return FAKER.options().option("on", "off", "toggle", "previous"); - } - - /** - * Generates a random vendor name. - * - * @return a randomly generated vendor name - */ - private static String generateVendor() { - return FAKER.options().option("ikea", "apple", "tasmota", "sencor", "amazon", "google", "xiaomi"); - } - - /** - * Generates a random activity state (active/inactive/error). - * - * @return a randomly generated activity state - */ - private static String generateActivityState() { - return FAKER.options().option("active", "inactive", "error"); - } - - /** - * Generates a JSON data section for the specified device type. - * - * @param type the type of the device - * @return a JSON string representing the data section for the specified device type - */ - private static String generateDataSection(String type) { - switch (type) { - case TYPE_LIGHT: - return String.format("{\"power\": \"%s\", \"brightness\": %d, \"power_on_behavior\": \"%s\"}", - generatePowerState(), FAKER.number().numberBetween(0, 254), generatePowerOnBehavior()); - case TYPE_PLUG: - return String.format("{\"power\": \"%s\", \"energy_current\": {\"state\": %.3f, \"unit\": \"A\"}, " + - "\"energy_today\": {\"state\": %.3f, \"unit\": \"kWh\"}}", - generatePowerState(), FAKER.number().randomDouble(3, 0, 1), - FAKER.number().randomDouble(3, 0, 10)); - case TYPE_BUTTON: - return String.format("{\"power\": \"%s\", \"battery\": {\"value\": %d, \"unit\": \"%%\"}}", - generatePowerState(), FAKER.number().numberBetween(0, 100)); - case TYPE_THERMOMETER: - return String.format("{\"temperature\": %.2f, \"humidity\": %.2f, " + - "\"battery\": {\"value\": %d, \"unit\": \"%%\"}}", - FAKER.number().randomDouble(2, -30, 40), - FAKER.number().randomDouble(2, 10, 90), - FAKER.number().numberBetween(0, 100)); - case TYPE_GATE: - return String.format("{\"vendor\": \"%s\", \"state\": \"%s\"}", - generateVendor(), generateActivityState()); - default: - return String.format("{\"info\": \"custom data\", \"state\": \"%s\"}", generateActivityState()); - } - } - - /** - * Generates IoT device data using the Faker library. - * - * @return the generated IoT device data as a JSON string - */ - public static String generateData() { - String ipv4 = FAKER.internet().ipV4Address(); - String mac = FAKER.internet().macAddress(); - String id = String.valueOf(FAKER.number().numberBetween(10000, 999999)); - String type = FAKER.options().option(TYPE_LIGHT, TYPE_BUTTON, TYPE_THERMOMETER, - TYPE_PLUG, TYPE_CUSTOM, TYPE_GATE); - String lastUpdate = String.valueOf(System.currentTimeMillis()); - int linkQuality = FAKER.number().numberBetween(0, 100); - String data = generateDataSection(type); - - return String.format(Locale.US, - "{\"IPV4\":\"%s\"," + - "\"MAC\":\"%s\"," + - "\"ID\":\"%s\"," + - "\"TYPE\":\"%s\"," + - "\"LAST_UPDATE\":\"%s\"," + - "\"LINK_QUALITY\":%d," + - "\"DATA\":%s}", - ipv4, mac, id, type, lastUpdate, linkQuality, data); - } -} diff --git a/src/main/java/io/skodjob/datagenerator/handlers/IotDeviceHandler.java b/src/main/java/io/skodjob/datagenerator/handlers/IotDeviceHandler.java new file mode 100644 index 0000000..c96d062 --- /dev/null +++ b/src/main/java/io/skodjob/datagenerator/handlers/IotDeviceHandler.java @@ -0,0 +1,153 @@ +/* + * Copyright Skodjob authors. + * License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html). + */ +package io.skodjob.datagenerator.handlers; + +import io.skodjob.datagenerator.models.iotdevice.Battery; +import io.skodjob.datagenerator.models.iotdevice.ButtonData; +import io.skodjob.datagenerator.models.iotdevice.CustomData; +import io.skodjob.datagenerator.models.iotdevice.EnergyCurrent; +import io.skodjob.datagenerator.models.iotdevice.EnergyToday; +import io.skodjob.datagenerator.models.iotdevice.GateData; +import io.skodjob.datagenerator.models.iotdevice.IotDevice; +import io.skodjob.datagenerator.models.iotdevice.LightData; +import io.skodjob.datagenerator.models.iotdevice.PlugData; +import io.skodjob.datagenerator.models.iotdevice.ThermometerData; +import net.datafaker.Faker; + +/** + * This class is responsible for generating IoT device data using the Faker library. + */ +public class IotDeviceHandler { + + /** + * Private constructor to make class static + */ + private IotDeviceHandler() { + + } + + private static final Faker FAKER = new Faker(); + + /** + * Template name used in the generator + */ + public static final String TEMPLATE_NAME = "iot_device"; + + private static final String TYPE_LIGHT = "light"; + private static final String TYPE_BUTTON = "button"; + private static final String TYPE_THERMOMETER = "thermometer"; + private static final String TYPE_PLUG = "plug"; + private static final String TYPE_CUSTOM = "custom"; + private static final String TYPE_GATE = "gate"; + + /** + * Generates a random power state (on/off). + * + * @return a randomly generated power state + */ + private static String generatePowerState() { + return FAKER.options().option("on", "off"); + } + + /** + * Generates a random power on behavior (on/off/toggle/previous). + * + * @return a randomly generated power on behavior + */ + private static String generatePowerOnBehavior() { + return FAKER.options().option("on", "off", "toggle", "previous"); + } + + /** + * Generates a random vendor name. + * + * @return a randomly generated vendor name + */ + private static String generateVendor() { + return FAKER.options().option("ikea", "apple", "tasmota", "sencor", "amazon", "google", "xiaomi"); + } + + /** + * Generates a random activity state (active/inactive/error). + * + * @return a randomly generated activity state + */ + private static String generateActivityState() { + return FAKER.options().option("active", "inactive", "error"); + } + + /** + * Generates IoT device data using the Faker library. + * + * @return the generated IoT device data as a JSON string + */ + public static String generateData() { + IotDevice iotDevice = new IotDevice(); + + iotDevice.setIPV4(FAKER.internet().ipV4Address()); + iotDevice.setMAC(FAKER.internet().macAddress()); + iotDevice.setID(String.valueOf(FAKER.number().numberBetween(10000, 999999))); + iotDevice.setTYPE(FAKER.options().option(TYPE_LIGHT, TYPE_BUTTON, TYPE_THERMOMETER, + TYPE_PLUG, TYPE_CUSTOM, TYPE_GATE)); + iotDevice.setLASTUPDATE(String.valueOf(System.currentTimeMillis())); + iotDevice.setLINKQUALITY(FAKER.number().numberBetween(0, 100)); + + switch (iotDevice.getTYPE().toString()) { + case TYPE_LIGHT: + LightData lightData = new LightData(); + lightData.setPower(generatePowerState()); + lightData.setPowerOnBehavior(generatePowerOnBehavior()); + lightData.setBrightness(FAKER.number().numberBetween(0, 254)); + + iotDevice.setDATA(lightData); + break; + case TYPE_PLUG: + PlugData plugData = new PlugData(); + plugData.setPower(generatePowerState()); + + EnergyCurrent energyCurrent = new EnergyCurrent(); + energyCurrent.setState((float) FAKER.number().randomDouble(3, 0, 1)); + energyCurrent.setUnit("A"); + + plugData.setEnergyCurrent(energyCurrent); + + EnergyToday energyToday = new EnergyToday(); + energyToday.setState((float) FAKER.number().randomDouble(3, 0, 10)); + energyToday.setUnit("kWh"); + + plugData.setEnergyToday(energyToday); + + iotDevice.setDATA(plugData); + break; + case TYPE_BUTTON: + ButtonData buttonData = new ButtonData(); + buttonData.setPower(generatePowerState()); + buttonData.setBattery(new Battery(FAKER.number().numberBetween(0, 100), "%")); + + iotDevice.setDATA(buttonData); + break; + case TYPE_THERMOMETER: + ThermometerData thermometerData = new ThermometerData(); + thermometerData.setTemperature((float) FAKER.number().randomDouble(2, -30, 40)); + thermometerData.setHumidity((float) FAKER.number().randomDouble(2, 10, 90)); + thermometerData.setBattery(new Battery(FAKER.number().numberBetween(0, 100), "%")); + + iotDevice.setDATA(thermometerData); + break; + case TYPE_GATE: + GateData gateData = new GateData(generateVendor(), generateActivityState()); + + iotDevice.setDATA(gateData); + break; + default: + CustomData customData = new CustomData("custom data", generateActivityState()); + + iotDevice.setDATA(customData); + break; + } + + return iotDevice.toString(); + } +} diff --git a/src/main/java/io/skodjob/datagenerator/handlers/PaymentFiat.java b/src/main/java/io/skodjob/datagenerator/handlers/PaymentFiat.java deleted file mode 100644 index 3491315..0000000 --- a/src/main/java/io/skodjob/datagenerator/handlers/PaymentFiat.java +++ /dev/null @@ -1,191 +0,0 @@ -/* - * Copyright Skodjob authors. - * License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html). - */ -package io.skodjob.datagenerator.handlers; - -import net.datafaker.Faker; - -import java.time.ZoneOffset; -import java.util.Arrays; -import java.util.List; -import java.util.Locale; - -/** - * This class is responsible for generating payment data using the Faker library. - */ -public class PaymentFiat { - - /** - * Private constructor to make class static - */ - private PaymentFiat() { - - } - - private static final Faker FAKER = new Faker(); - - /** - * Template name used in the generator - */ - public static final String TEMPLATE_NAME = "payment_data"; - - // Constants for payment types - private static final String PAYMENT_TYPE_CREDIT_CARD = "credit_card"; - private static final String PAYMENT_TYPE_BANK_TRANSFER = "bank_transfer"; - private static final String PAYMENT_TYPE_PAYPAL = "paypal"; - - // Constants for payment statuses - private static final String STATUS_COMPLETED = "completed"; - private static final String STATUS_PENDING = "pending"; - private static final String STATUS_FAILED = "failed"; - - // Constants for credit card types - private static final String CARD_TYPE_VISA = "Visa"; - private static final String CARD_TYPE_MASTERCARD = "MasterCard"; - private static final String CARD_TYPE_AMERICAN_EXPRESS = "American Express"; - private static final String CARD_TYPE_REVOLUT = "Revolut"; - private static final String CARD_TYPE_WISE = "Wise"; - private static final String CARD_TYPE_CITYGROUP = "CityGroup"; - private static final String CARD_TYPE_BARCLAYS = "Barclays"; - - // Constants for payer/payee type - private static final String COMPANY = "company"; - private static final String PERSON = "person"; - - // List of world banks - private static final List BANKS = Arrays.asList( - "JPMorgan Chase", "Bank of America", "Wells Fargo", "Citigroup", "Goldman Sachs", - "Morgan Stanley", "HSBC", "BNP Paribas", "UBS", "Credit Suisse", - "Barclays", "Deutsche Bank", "Standard Chartered", "Santander", "Societe Generale", - "ING Group", "Mitsubishi UFJ Financial Group", "Mizuho Financial Group", "Sumitomo Mitsui Financial Group", - "Bank of China", "Industrial and Commercial Bank of China", "China Construction Bank", - "Agricultural Bank of China", "Banco Bradesco", "Itau Unibanco", - "Royal Bank of Canada", "Toronto-Dominion Bank", "National Australia Bank", "Westpac", "ANZ" - ); - - /** - * Generates payment data using the Faker library. - * - * @return the generated payment data as a JSON string - */ - public static String generateData() { - String transactionId = FAKER.regexify("txn_[0-9]{10}"); - String paymentType = FAKER.options() - .option(PAYMENT_TYPE_CREDIT_CARD, PAYMENT_TYPE_BANK_TRANSFER, PAYMENT_TYPE_PAYPAL); - double amount = FAKER.number().randomDouble(2, 10, 1000); - String currency = FAKER.money().currencyCode(); - String date = FAKER.timeAndDate().past(1, java.util.concurrent.TimeUnit.DAYS) - .atOffset(ZoneOffset.UTC).toString(); - String status = FAKER.options().option(STATUS_COMPLETED, STATUS_PENDING, STATUS_FAILED); - - String payerName, payerType, payeeName, payeeType; - - switch (FAKER.number().numberBetween(0, 4)) { - case 0: - payerName = FAKER.company().name(); - payerType = COMPANY; - payeeName = FAKER.company().name(); - payeeType = COMPANY; - break; - case 1: - payerName = FAKER.name().fullName(); - payerType = PERSON; - payeeName = FAKER.company().name(); - payeeType = COMPANY; - break; - case 2: - payerName = FAKER.company().name(); - payerType = COMPANY; - payeeName = FAKER.name().fullName(); - payeeType = PERSON; - break; - default: - payerName = FAKER.name().fullName(); - payerType = PERSON; - payeeName = FAKER.name().fullName(); - payeeType = PERSON; - break; - } - - String payerAccountNumber = FAKER.number().digits(9); - String payerBank = FAKER.options().nextElement(BANKS); - String payerStreet = FAKER.address().streetAddress(); - String payerCity = FAKER.address().city(); - String payerState = FAKER.address().state(); - String payerCountry = FAKER.address().country(); - String payerPostalCode = FAKER.address().zipCode(); - - String payeeAccountNumber = FAKER.number().digits(9); - String payeeBank = FAKER.options().nextElement(BANKS); - String payeeStreet = FAKER.address().streetAddress(); - String payeeCity = FAKER.address().city(); - String payeeState = FAKER.address().state(); - String payeeCountry = FAKER.address().country(); - String payeePostalCode = FAKER.address().zipCode(); - - StringBuilder payerInfo = new StringBuilder(String.format(Locale.US, - "\"name\":\"%s\"," + - "\"payerType\":\"%s\"," + - "\"account_number\":\"%s\"," + - "\"bank\":\"%s\"," + - "\"billing_address\":{" + - "\"street\":\"%s\"," + - "\"city\":\"%s\"," + - "\"state\":\"%s\"," + - "\"country\":\"%s\"," + - "\"postal_code\":\"%s\"" + - "}", - payerName, payerType, payerAccountNumber, payerBank, - payerStreet, payerCity, payerState, payerCountry, payerPostalCode)); - - StringBuilder payeeInfo = new StringBuilder(String.format(Locale.US, - "\"name\":\"%s\"," + - "\"payeeType\":\"%s\"," + - "\"account_number\":\"%s\"," + - "\"bank\":\"%s\"," + - "\"address\":{" + - "\"street\":\"%s\"," + - "\"city\":\"%s\"," + - "\"state\":\"%s\"," + - "\"country\":\"%s\"," + - "\"postal_code\":\"%s\"" + - "}", - payeeName, payeeType, payeeAccountNumber, payeeBank, - payeeStreet, payeeCity, payeeState, payeeCountry, payeePostalCode)); - - if (PAYMENT_TYPE_CREDIT_CARD.equals(paymentType)) { - String payerCardNumber = FAKER.finance().creditCard(); - String payerCardType = FAKER.options().option(CARD_TYPE_VISA, CARD_TYPE_MASTERCARD, - CARD_TYPE_AMERICAN_EXPRESS, CARD_TYPE_REVOLUT, CARD_TYPE_WISE, - CARD_TYPE_CITYGROUP, CARD_TYPE_BARCLAYS); - String payerExpiryDate = FAKER.business().creditCardExpiry(); - - payerInfo.append(String.format(Locale.US, - "," + - "\"card_number\":\"%s\"," + - "\"card_type\":\"%s\"," + - "\"expiry_date\":\"%s\"", - payerCardNumber, payerCardType, payerExpiryDate)); - } - - return String.format(Locale.US, - "{\"payment\":{" + - "\"transaction_id\":\"%s\"," + - "\"type\":\"%s\"," + - "\"amount\":%.2f," + - "\"currency\":\"%s\"," + - "\"date\":\"%s\"," + - "\"status\":\"%s\"" + - "}," + - "\"payer\":{" + - "%s" + - "}," + - "\"payee\":{" + - "%s" + - "}}", - transactionId, paymentType, amount, currency, date, status, - payerInfo, - payeeInfo); - } -} diff --git a/src/main/java/io/skodjob/datagenerator/handlers/PaymentFiatHandler.java b/src/main/java/io/skodjob/datagenerator/handlers/PaymentFiatHandler.java new file mode 100644 index 0000000..d9d5331 --- /dev/null +++ b/src/main/java/io/skodjob/datagenerator/handlers/PaymentFiatHandler.java @@ -0,0 +1,160 @@ +/* + * Copyright Skodjob authors. + * License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html). + */ +package io.skodjob.datagenerator.handlers; + +import io.skodjob.datagenerator.models.paymentfiat.Address; +import io.skodjob.datagenerator.models.paymentfiat.Payee; +import io.skodjob.datagenerator.models.paymentfiat.Payer; +import io.skodjob.datagenerator.models.paymentfiat.PaymentDetails; +import io.skodjob.datagenerator.models.paymentfiat.PaymentFiat; +import net.datafaker.Faker; + +import java.time.ZoneOffset; +import java.util.Arrays; +import java.util.List; + +/** + * This class is responsible for generating payment data using the Faker library. + */ +public class PaymentFiatHandler { + + /** + * Private constructor to make class static + */ + private PaymentFiatHandler() { + + } + + private static final Faker FAKER = new Faker(); + + /** + * Template name used in the generator + */ + public static final String TEMPLATE_NAME = "payment_data"; + + // Constants for payment types + private static final String PAYMENT_TYPE_CREDIT_CARD = "creditCard"; + private static final String PAYMENT_TYPE_BANK_TRANSFER = "bankTransfer"; + private static final String PAYMENT_TYPE_PAYPAL = "paypal"; + + // Constants for payment statuses + private static final String STATUS_COMPLETED = "completed"; + private static final String STATUS_PENDING = "pending"; + private static final String STATUS_FAILED = "failed"; + + // Constants for credit card types + private static final String CARD_TYPE_VISA = "Visa"; + private static final String CARD_TYPE_MASTERCARD = "MasterCard"; + private static final String CARD_TYPE_AMERICAN_EXPRESS = "American Express"; + private static final String CARD_TYPE_REVOLUT = "Revolut"; + private static final String CARD_TYPE_WISE = "Wise"; + private static final String CARD_TYPE_CITYGROUP = "CityGroup"; + private static final String CARD_TYPE_BARCLAYS = "Barclays"; + + // Constants for payer/payee type + private static final String COMPANY = "company"; + private static final String PERSON = "person"; + + // List of world banks + private static final List BANKS = Arrays.asList( + "JPMorgan Chase", "Bank of America", "Wells Fargo", "Citigroup", "Goldman Sachs", + "Morgan Stanley", "HSBC", "BNP Paribas", "UBS", "Credit Suisse", + "Barclays", "Deutsche Bank", "Standard Chartered", "Santander", "Societe Generale", + "ING Group", "Mitsubishi UFJ Financial Group", "Mizuho Financial Group", "Sumitomo Mitsui Financial Group", + "Bank of China", "Industrial and Commercial Bank of China", "China Construction Bank", + "Agricultural Bank of China", "Banco Bradesco", "Itau Unibanco", + "Royal Bank of Canada", "Toronto-Dominion Bank", "National Australia Bank", "Westpac", "ANZ" + ); + + private static PaymentFiat generatePaymentFiatData() { + PaymentFiat paymentFiat = new PaymentFiat(); + + PaymentDetails paymentDetails = new PaymentDetails(); + + paymentDetails.setTransactionId(FAKER.regexify("txn_[0-9]{10}")); + paymentDetails.setType(FAKER.options().option(PAYMENT_TYPE_CREDIT_CARD, + PAYMENT_TYPE_BANK_TRANSFER, PAYMENT_TYPE_PAYPAL)); + paymentDetails.setAmount(FAKER.number().randomDouble(2, 10, 1000)); + paymentDetails.setCurrency(FAKER.money().currencyCode()); + paymentDetails.setDate(FAKER.timeAndDate().past(1, java.util.concurrent.TimeUnit.DAYS) + .atOffset(ZoneOffset.UTC).toString()); + paymentDetails.setStatus(FAKER.options().option(STATUS_COMPLETED, STATUS_PENDING, STATUS_FAILED)); + + Payee payee = new Payee(); + Address payeeAddress = new Address(); + Payer payer = new Payer(); + Address payerAddress = new Address(); + + switch (FAKER.number().numberBetween(0, 4)) { + case 0: + payer.setName(FAKER.company().name()); + payer.setPayerType(COMPANY); + payee.setName(FAKER.company().name()); + payee.setPayeeType(COMPANY); + break; + case 1: + payer.setName(FAKER.name().fullName()); + payer.setPayerType(PERSON); + payee.setName(FAKER.company().name()); + payee.setPayeeType(COMPANY); + break; + case 2: + payer.setName(FAKER.company().name()); + payer.setPayerType(COMPANY); + payee.setName(FAKER.name().fullName()); + payee.setPayeeType(PERSON); + break; + default: + payer.setName(FAKER.name().fullName()); + payer.setPayerType(PERSON); + payee.setName(FAKER.name().fullName()); + payee.setPayeeType(PERSON); + break; + } + + payer.setAccountNumber(FAKER.number().digits(9)); + payer.setBank(FAKER.options().nextElement(BANKS)); + payerAddress.setStreet(FAKER.address().streetAddress()); + payerAddress.setCity(FAKER.address().city()); + payerAddress.setState(FAKER.address().state()); + payerAddress.setCountry(FAKER.address().country()); + payerAddress.setPostalCode(FAKER.address().zipCode()); + payer.setBillingAddress(payerAddress); + + if (PAYMENT_TYPE_CREDIT_CARD.contentEquals(paymentDetails.getType())) { + payer.setCardNumber(FAKER.finance().creditCard()); + payer.setCardType(FAKER.options().option(CARD_TYPE_VISA, CARD_TYPE_MASTERCARD, + CARD_TYPE_AMERICAN_EXPRESS, CARD_TYPE_REVOLUT, CARD_TYPE_WISE, + CARD_TYPE_CITYGROUP, CARD_TYPE_BARCLAYS)); + payer.setExpiryDate(FAKER.business().creditCardExpiry()); + } + + payee.setAccountNumber(FAKER.number().digits(9)); + payee.setBank(FAKER.options().nextElement(BANKS)); + payeeAddress.setStreet(FAKER.address().streetAddress()); + payeeAddress.setCity(FAKER.address().city()); + payeeAddress.setState(FAKER.address().state()); + payeeAddress.setCountry(FAKER.address().country()); + payeeAddress.setPostalCode(FAKER.address().zipCode()); + payee.setAddress(payerAddress); + + paymentFiat.setPaymentDetails(paymentDetails); + paymentFiat.setPayer(payer); + paymentFiat.setPayee(payee); + + return paymentFiat; + } + + /** + * Generates payment data using the Faker library. + * + * @return the generated payment data as a JSON string + */ + public static String generateData() { + PaymentFiat paymentFiat = generatePaymentFiatData(); + + return paymentFiat.toString(); + } +} diff --git a/src/main/java/io/skodjob/datagenerator/handlers/Payroll.java b/src/main/java/io/skodjob/datagenerator/handlers/Payroll.java deleted file mode 100644 index f93d6ca..0000000 --- a/src/main/java/io/skodjob/datagenerator/handlers/Payroll.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright Skodjob authors. - * License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html). - */ -package io.skodjob.datagenerator.handlers; - -import net.datafaker.Faker; - -import java.util.Locale; - -/** - * This class generates random people-related data for use in templates. - */ -public class Payroll { - - /** - * Private constructor to make class static - */ - private Payroll() { - - } - - private static final Faker FAKER = new Faker(); - - /** - * Template name used in the generator - */ - public static final String TEMPLATE_NAME = "payroll"; - - /** - * Generates payroll employee data using the Faker library. - * - * @return the generated payroll employee data as a JSON string - */ - public static String generateData() { - String employeeId = String.valueOf(FAKER.number().numberBetween(10000, 999999)); - String firstName = FAKER.name().firstName(); - String lastName = FAKER.name().lastName(); - int age = FAKER.number().numberBetween(18, 60); - String ssn = FAKER.idNumber().ssnValid(); - double hourlyRate = FAKER.number().randomDouble(2, 10, 50); - String gender = FAKER.demographic().sex(); - String email = FAKER.internet().emailAddress(); - String company = FAKER.company().name(); - - return String.format(Locale.US, - "{\"employee_id\":\"%s\"," + - "\"first_name\":\"%s\"," + - "\"last_name\":\"%s\"," + - "\"age\":%d," + - "\"ssn\":\"%s\"," + - "\"hourly_rate\":%.2f," + - "\"gender\":\"%s\"," + - "\"email\":\"%s\"," + - "\"company\":\"%s\"}", - employeeId, firstName, lastName, age, ssn, hourlyRate, gender, email, company); - } -} diff --git a/src/main/java/io/skodjob/datagenerator/handlers/PayrollHandler.java b/src/main/java/io/skodjob/datagenerator/handlers/PayrollHandler.java new file mode 100644 index 0000000..e94e52f --- /dev/null +++ b/src/main/java/io/skodjob/datagenerator/handlers/PayrollHandler.java @@ -0,0 +1,49 @@ +/* + * Copyright Skodjob authors. + * License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html). + */ +package io.skodjob.datagenerator.handlers; + +import io.skodjob.datagenerator.models.payroll.Employee; +import net.datafaker.Faker; + +/** + * This class generates random people-related data for use in templates. + */ +public class PayrollHandler { + + /** + * Private constructor to make class static + */ + private PayrollHandler() { + + } + + private static final Faker FAKER = new Faker(); + + /** + * Template name used in the generator + */ + public static final String TEMPLATE_NAME = "payroll"; + + /** + * Generates payroll employee data using the Faker library. + * + * @return the generated payroll employee data as a JSON string + */ + public static String generateData() { + Employee employee = new Employee(); + + employee.setEmployeeId(String.valueOf(FAKER.number().numberBetween(10000, 999999))); + employee.setFirstName(FAKER.name().firstName()); + employee.setLastName(FAKER.name().lastName()); + employee.setAge(FAKER.number().numberBetween(18, 60)); + employee.setSsn(FAKER.idNumber().ssnValid()); + employee.setHourlyRate((float) FAKER.number().randomDouble(2, 10, 50)); + employee.setGender(FAKER.demographic().sex()); + employee.setEmail(FAKER.internet().emailAddress()); + employee.setCompany(FAKER.company().name()); + + return employee.toString(); + } +} diff --git a/src/main/java/io/skodjob/datagenerator/handlers/StarGate.java b/src/main/java/io/skodjob/datagenerator/handlers/StarGate.java deleted file mode 100644 index b0d7ca6..0000000 --- a/src/main/java/io/skodjob/datagenerator/handlers/StarGate.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright Skodjob authors. - * License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html). - */ -package io.skodjob.datagenerator.handlers; - -import net.datafaker.Faker; - -import java.util.Locale; - -/** - * This class generates random StarGate-related data for use in templates. - */ -public class StarGate { - - /** - * Private constructor to make class static - */ - private StarGate() { - - } - - private static final Faker FAKER = new Faker(); - - /** - * Template name used in the generator - */ - public static final String TEMPLATE_NAME = "stargate"; - - /** - * Generates StarGate data using the Faker library. - * - * @return the generated StarGate data as a JSON string - */ - public static String generateData() { - String characterName = FAKER.stargate().characters(); - String sourcePlanet = FAKER.stargate().planets(); - String targetPlanet = FAKER.stargate().planets(); - String quote = FAKER.stargate().quotes(); - int duration = FAKER.number().numberBetween(1, 50); - int distance = FAKER.number().numberBetween(20000, 999999); - - return String.format(Locale.US, - "{\"character_name\":\"%s\"," + - "\"source_planet\":\"%s\"," + - "\"target_planet\":\"%s\"," + - "\"quote\":\"%s\"," + - "\"duration\":%d," + - "\"duration_unit\":\"seconds\"," + - "\"distance\":\"%s\"," + - "\"distance_unit\":\"light_year\"}", - characterName, sourcePlanet, targetPlanet, quote, duration, distance); - } -} diff --git a/src/main/java/io/skodjob/datagenerator/handlers/StarGateHandler.java b/src/main/java/io/skodjob/datagenerator/handlers/StarGateHandler.java new file mode 100644 index 0000000..24d0be8 --- /dev/null +++ b/src/main/java/io/skodjob/datagenerator/handlers/StarGateHandler.java @@ -0,0 +1,47 @@ +/* + * Copyright Skodjob authors. + * License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html). + */ +package io.skodjob.datagenerator.handlers; + +import io.skodjob.datagenerator.models.stargate.StarGate; +import net.datafaker.Faker; + +/** + * This class generates random StarGate-related data for use in templates. + */ +public class StarGateHandler { + + /** + * Private constructor to make class static + */ + private StarGateHandler() { + + } + + private static final Faker FAKER = new Faker(); + + /** + * Template name used in the generator + */ + public static final String TEMPLATE_NAME = "stargate"; + + /** + * Generates StarGate data using the Faker library. + * + * @return the generated StarGate data as a JSON string + */ + public static String generateData() { + StarGate starGate = new StarGate(); + starGate.setCharacterName(FAKER.stargate().characters()); + starGate.setSourcePlanet(FAKER.stargate().planets()); + starGate.setTargetPlanet(FAKER.stargate().planets()); + starGate.setQuote(FAKER.stargate().quotes()); + starGate.setDistance(FAKER.number().numberBetween(1, 50)); + starGate.setDistanceUnit("light_year"); + starGate.setDuration(FAKER.number().numberBetween(20000, 999999)); + starGate.setDurationUnit("seconds"); + + return starGate.toString(); + } +} diff --git a/src/main/java/io/skodjob/datagenerator/handlers/StarWars.java b/src/main/java/io/skodjob/datagenerator/handlers/StarWars.java deleted file mode 100644 index f6a8119..0000000 --- a/src/main/java/io/skodjob/datagenerator/handlers/StarWars.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright Skodjob authors. - * License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html). - */ -package io.skodjob.datagenerator.handlers; - -import net.datafaker.Faker; - -import java.util.Locale; - -/** - * This class generates random StarWars-related data for use in templates. - */ -public class StarWars { - - /** - * Private constructor to make class static - */ - private StarWars() { - - } - - private static final Faker FAKER = new Faker(); - - /** - * Template name used in the generator - */ - public static final String TEMPLATE_NAME = "starwars"; - - /** - * Generates StarWars data using the Faker library. - * - * @return the generated StarWars data as a JSON string - */ - public static String generateData() { - String characterName = FAKER.starWars().character(); - String sourcePlanet = FAKER.starWars().planets(); - String targetPlanet = FAKER.starWars().planets(); - String quote = FAKER.starWars().quotes(); - String callSign = FAKER.starWars().callSign(); - String species = FAKER.starWars().species(); - String vehicle = FAKER.starWars().vehicles(); - String wookieWords = FAKER.starWars().wookieWords(); - String alternateCharacterSpelling = FAKER.starWars().alternateCharacterSpelling(); - - return String.format(Locale.US, - "{\"character_name\":\"%s\"," + - "\"source_planet\":\"%s\"," + - "\"target_planet\":\"%s\"," + - "\"quote\":\"%s\"," + - "\"callSign\":\"%s\"," + - "\"species\":\"%s\"," + - "\"vehicle\":\"%s\"," + - "\"wookieWords\":\"%s\"," + - "\"alternateCharacterSpelling\":\"%s\"}", - characterName, sourcePlanet, targetPlanet, quote, callSign, species, - vehicle, wookieWords, alternateCharacterSpelling); - } -} diff --git a/src/main/java/io/skodjob/datagenerator/handlers/StarWarsHandler.java b/src/main/java/io/skodjob/datagenerator/handlers/StarWarsHandler.java new file mode 100644 index 0000000..4211a1f --- /dev/null +++ b/src/main/java/io/skodjob/datagenerator/handlers/StarWarsHandler.java @@ -0,0 +1,48 @@ +/* + * Copyright Skodjob authors. + * License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html). + */ +package io.skodjob.datagenerator.handlers; + +import io.skodjob.datagenerator.models.starwars.StarWars; +import net.datafaker.Faker; + +/** + * This class generates random StarWars-related data for use in templates. + */ +public class StarWarsHandler { + + /** + * Private constructor to make class static + */ + private StarWarsHandler() { + + } + + private static final Faker FAKER = new Faker(); + + /** + * Template name used in the generator + */ + public static final String TEMPLATE_NAME = "starwars"; + + /** + * Generates StarWars data using the Faker library. + * + * @return the generated StarWars data as a JSON string + */ + public static String generateData() { + StarWars starWars = new StarWars(); + starWars.setCharacterName(FAKER.starWars().character()); + starWars.setSourcePlanet(FAKER.starWars().planets()); + starWars.setTargetPlanet(FAKER.starWars().planets()); + starWars.setQuote(FAKER.starWars().quotes()); + starWars.setCallSign(FAKER.starWars().callSign()); + starWars.setSpecies(FAKER.starWars().species()); + starWars.setVehicle(FAKER.starWars().vehicles()); + starWars.setWookieWords(FAKER.starWars().wookieWords()); + starWars.setAlternateCharacterSpelling(FAKER.starWars().alternateCharacterSpelling()); + + return starWars.toString(); + } +} diff --git a/src/main/java/io/skodjob/datagenerator/models/flights/Flight.java b/src/main/java/io/skodjob/datagenerator/models/flights/Flight.java new file mode 100644 index 0000000..db9a0e7 --- /dev/null +++ b/src/main/java/io/skodjob/datagenerator/models/flights/Flight.java @@ -0,0 +1,1039 @@ +/** + * Autogenerated by Avro + * + * DO NOT EDIT DIRECTLY + */ +package io.skodjob.datagenerator.models.flights; + +import org.apache.avro.generic.GenericArray; +import org.apache.avro.specific.SpecificData; +import org.apache.avro.util.Utf8; +import org.apache.avro.message.BinaryMessageEncoder; +import org.apache.avro.message.BinaryMessageDecoder; +import org.apache.avro.message.SchemaStore; + +@org.apache.avro.specific.AvroGenerated +public class Flight extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord { + private static final long serialVersionUID = 4755920530450445103L; + + + public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"Flight\",\"namespace\":\"io.skodjob.datagenerator.models.flights\",\"fields\":[{\"name\":\"number\",\"type\":\"string\"},{\"name\":\"departure_airport\",\"type\":\"string\"},{\"name\":\"arrival_airport\",\"type\":\"string\"},{\"name\":\"departure_time\",\"type\":\"string\"},{\"name\":\"arrival_time\",\"type\":\"string\"},{\"name\":\"seat_number\",\"type\":\"string\"},{\"name\":\"gate\",\"type\":\"string\"},{\"name\":\"boarding_group\",\"type\":\"string\"},{\"name\":\"plane_model\",\"type\":\"string\"},{\"name\":\"airline\",\"type\":\"string\"}]}"); + public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } + + private static final SpecificData MODEL$ = new SpecificData(); + + private static final BinaryMessageEncoder ENCODER = + new BinaryMessageEncoder<>(MODEL$, SCHEMA$); + + private static final BinaryMessageDecoder DECODER = + new BinaryMessageDecoder<>(MODEL$, SCHEMA$); + + /** + * Return the BinaryMessageEncoder instance used by this class. + * @return the message encoder used by this class + */ + public static BinaryMessageEncoder getEncoder() { + return ENCODER; + } + + /** + * Return the BinaryMessageDecoder instance used by this class. + * @return the message decoder used by this class + */ + public static BinaryMessageDecoder getDecoder() { + return DECODER; + } + + /** + * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}. + * @param resolver a {@link SchemaStore} used to find schemas by fingerprint + * @return a BinaryMessageDecoder instance for this class backed by the given SchemaStore + */ + public static BinaryMessageDecoder createDecoder(SchemaStore resolver) { + return new BinaryMessageDecoder<>(MODEL$, SCHEMA$, resolver); + } + + /** + * Serializes this Flight to a ByteBuffer. + * @return a buffer holding the serialized data for this instance + * @throws java.io.IOException if this instance could not be serialized + */ + public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException { + return ENCODER.encode(this); + } + + /** + * Deserializes a Flight from a ByteBuffer. + * @param b a byte buffer holding serialized data for an instance of this class + * @return a Flight instance decoded from the given buffer + * @throws java.io.IOException if the given bytes could not be deserialized into an instance of this class + */ + public static Flight fromByteBuffer( + java.nio.ByteBuffer b) throws java.io.IOException { + return DECODER.decode(b); + } + + private java.lang.CharSequence number; + private java.lang.CharSequence departure_airport; + private java.lang.CharSequence arrival_airport; + private java.lang.CharSequence departure_time; + private java.lang.CharSequence arrival_time; + private java.lang.CharSequence seat_number; + private java.lang.CharSequence gate; + private java.lang.CharSequence boarding_group; + private java.lang.CharSequence plane_model; + private java.lang.CharSequence airline; + + /** + * Default constructor. Note that this does not initialize fields + * to their default values from the schema. If that is desired then + * one should use newBuilder(). + */ + public Flight() {} + + /** + * All-args constructor. + * @param number The new value for number + * @param departure_airport The new value for departure_airport + * @param arrival_airport The new value for arrival_airport + * @param departure_time The new value for departure_time + * @param arrival_time The new value for arrival_time + * @param seat_number The new value for seat_number + * @param gate The new value for gate + * @param boarding_group The new value for boarding_group + * @param plane_model The new value for plane_model + * @param airline The new value for airline + */ + public Flight(java.lang.CharSequence number, java.lang.CharSequence departure_airport, java.lang.CharSequence arrival_airport, java.lang.CharSequence departure_time, java.lang.CharSequence arrival_time, java.lang.CharSequence seat_number, java.lang.CharSequence gate, java.lang.CharSequence boarding_group, java.lang.CharSequence plane_model, java.lang.CharSequence airline) { + this.number = number; + this.departure_airport = departure_airport; + this.arrival_airport = arrival_airport; + this.departure_time = departure_time; + this.arrival_time = arrival_time; + this.seat_number = seat_number; + this.gate = gate; + this.boarding_group = boarding_group; + this.plane_model = plane_model; + this.airline = airline; + } + + @Override + public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; } + + @Override + public org.apache.avro.Schema getSchema() { return SCHEMA$; } + + // Used by DatumWriter. Applications should not call. + @Override + public java.lang.Object get(int field$) { + switch (field$) { + case 0: return number; + case 1: return departure_airport; + case 2: return arrival_airport; + case 3: return departure_time; + case 4: return arrival_time; + case 5: return seat_number; + case 6: return gate; + case 7: return boarding_group; + case 8: return plane_model; + case 9: return airline; + default: throw new IndexOutOfBoundsException("Invalid index: " + field$); + } + } + + // Used by DatumReader. Applications should not call. + @Override + @SuppressWarnings(value="unchecked") + public void put(int field$, java.lang.Object value$) { + switch (field$) { + case 0: number = (java.lang.CharSequence)value$; break; + case 1: departure_airport = (java.lang.CharSequence)value$; break; + case 2: arrival_airport = (java.lang.CharSequence)value$; break; + case 3: departure_time = (java.lang.CharSequence)value$; break; + case 4: arrival_time = (java.lang.CharSequence)value$; break; + case 5: seat_number = (java.lang.CharSequence)value$; break; + case 6: gate = (java.lang.CharSequence)value$; break; + case 7: boarding_group = (java.lang.CharSequence)value$; break; + case 8: plane_model = (java.lang.CharSequence)value$; break; + case 9: airline = (java.lang.CharSequence)value$; break; + default: throw new IndexOutOfBoundsException("Invalid index: " + field$); + } + } + + /** + * Gets the value of the 'number' field. + * @return The value of the 'number' field. + */ + public java.lang.CharSequence getNumber() { + return number; + } + + + /** + * Sets the value of the 'number' field. + * @param value the value to set. + */ + public void setNumber(java.lang.CharSequence value) { + this.number = value; + } + + /** + * Gets the value of the 'departure_airport' field. + * @return The value of the 'departure_airport' field. + */ + public java.lang.CharSequence getDepartureAirport() { + return departure_airport; + } + + + /** + * Sets the value of the 'departure_airport' field. + * @param value the value to set. + */ + public void setDepartureAirport(java.lang.CharSequence value) { + this.departure_airport = value; + } + + /** + * Gets the value of the 'arrival_airport' field. + * @return The value of the 'arrival_airport' field. + */ + public java.lang.CharSequence getArrivalAirport() { + return arrival_airport; + } + + + /** + * Sets the value of the 'arrival_airport' field. + * @param value the value to set. + */ + public void setArrivalAirport(java.lang.CharSequence value) { + this.arrival_airport = value; + } + + /** + * Gets the value of the 'departure_time' field. + * @return The value of the 'departure_time' field. + */ + public java.lang.CharSequence getDepartureTime() { + return departure_time; + } + + + /** + * Sets the value of the 'departure_time' field. + * @param value the value to set. + */ + public void setDepartureTime(java.lang.CharSequence value) { + this.departure_time = value; + } + + /** + * Gets the value of the 'arrival_time' field. + * @return The value of the 'arrival_time' field. + */ + public java.lang.CharSequence getArrivalTime() { + return arrival_time; + } + + + /** + * Sets the value of the 'arrival_time' field. + * @param value the value to set. + */ + public void setArrivalTime(java.lang.CharSequence value) { + this.arrival_time = value; + } + + /** + * Gets the value of the 'seat_number' field. + * @return The value of the 'seat_number' field. + */ + public java.lang.CharSequence getSeatNumber() { + return seat_number; + } + + + /** + * Sets the value of the 'seat_number' field. + * @param value the value to set. + */ + public void setSeatNumber(java.lang.CharSequence value) { + this.seat_number = value; + } + + /** + * Gets the value of the 'gate' field. + * @return The value of the 'gate' field. + */ + public java.lang.CharSequence getGate() { + return gate; + } + + + /** + * Sets the value of the 'gate' field. + * @param value the value to set. + */ + public void setGate(java.lang.CharSequence value) { + this.gate = value; + } + + /** + * Gets the value of the 'boarding_group' field. + * @return The value of the 'boarding_group' field. + */ + public java.lang.CharSequence getBoardingGroup() { + return boarding_group; + } + + + /** + * Sets the value of the 'boarding_group' field. + * @param value the value to set. + */ + public void setBoardingGroup(java.lang.CharSequence value) { + this.boarding_group = value; + } + + /** + * Gets the value of the 'plane_model' field. + * @return The value of the 'plane_model' field. + */ + public java.lang.CharSequence getPlaneModel() { + return plane_model; + } + + + /** + * Sets the value of the 'plane_model' field. + * @param value the value to set. + */ + public void setPlaneModel(java.lang.CharSequence value) { + this.plane_model = value; + } + + /** + * Gets the value of the 'airline' field. + * @return The value of the 'airline' field. + */ + public java.lang.CharSequence getAirline() { + return airline; + } + + + /** + * Sets the value of the 'airline' field. + * @param value the value to set. + */ + public void setAirline(java.lang.CharSequence value) { + this.airline = value; + } + + /** + * Creates a new Flight RecordBuilder. + * @return A new Flight RecordBuilder + */ + public static io.skodjob.datagenerator.models.flights.Flight.Builder newBuilder() { + return new io.skodjob.datagenerator.models.flights.Flight.Builder(); + } + + /** + * Creates a new Flight RecordBuilder by copying an existing Builder. + * @param other The existing builder to copy. + * @return A new Flight RecordBuilder + */ + public static io.skodjob.datagenerator.models.flights.Flight.Builder newBuilder(io.skodjob.datagenerator.models.flights.Flight.Builder other) { + if (other == null) { + return new io.skodjob.datagenerator.models.flights.Flight.Builder(); + } else { + return new io.skodjob.datagenerator.models.flights.Flight.Builder(other); + } + } + + /** + * Creates a new Flight RecordBuilder by copying an existing Flight instance. + * @param other The existing instance to copy. + * @return A new Flight RecordBuilder + */ + public static io.skodjob.datagenerator.models.flights.Flight.Builder newBuilder(io.skodjob.datagenerator.models.flights.Flight other) { + if (other == null) { + return new io.skodjob.datagenerator.models.flights.Flight.Builder(); + } else { + return new io.skodjob.datagenerator.models.flights.Flight.Builder(other); + } + } + + /** + * RecordBuilder for Flight instances. + */ + @org.apache.avro.specific.AvroGenerated + public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase + implements org.apache.avro.data.RecordBuilder { + + private java.lang.CharSequence number; + private java.lang.CharSequence departure_airport; + private java.lang.CharSequence arrival_airport; + private java.lang.CharSequence departure_time; + private java.lang.CharSequence arrival_time; + private java.lang.CharSequence seat_number; + private java.lang.CharSequence gate; + private java.lang.CharSequence boarding_group; + private java.lang.CharSequence plane_model; + private java.lang.CharSequence airline; + + /** Creates a new Builder */ + private Builder() { + super(SCHEMA$, MODEL$); + } + + /** + * Creates a Builder by copying an existing Builder. + * @param other The existing Builder to copy. + */ + private Builder(io.skodjob.datagenerator.models.flights.Flight.Builder other) { + super(other); + if (isValidValue(fields()[0], other.number)) { + this.number = data().deepCopy(fields()[0].schema(), other.number); + fieldSetFlags()[0] = other.fieldSetFlags()[0]; + } + if (isValidValue(fields()[1], other.departure_airport)) { + this.departure_airport = data().deepCopy(fields()[1].schema(), other.departure_airport); + fieldSetFlags()[1] = other.fieldSetFlags()[1]; + } + if (isValidValue(fields()[2], other.arrival_airport)) { + this.arrival_airport = data().deepCopy(fields()[2].schema(), other.arrival_airport); + fieldSetFlags()[2] = other.fieldSetFlags()[2]; + } + if (isValidValue(fields()[3], other.departure_time)) { + this.departure_time = data().deepCopy(fields()[3].schema(), other.departure_time); + fieldSetFlags()[3] = other.fieldSetFlags()[3]; + } + if (isValidValue(fields()[4], other.arrival_time)) { + this.arrival_time = data().deepCopy(fields()[4].schema(), other.arrival_time); + fieldSetFlags()[4] = other.fieldSetFlags()[4]; + } + if (isValidValue(fields()[5], other.seat_number)) { + this.seat_number = data().deepCopy(fields()[5].schema(), other.seat_number); + fieldSetFlags()[5] = other.fieldSetFlags()[5]; + } + if (isValidValue(fields()[6], other.gate)) { + this.gate = data().deepCopy(fields()[6].schema(), other.gate); + fieldSetFlags()[6] = other.fieldSetFlags()[6]; + } + if (isValidValue(fields()[7], other.boarding_group)) { + this.boarding_group = data().deepCopy(fields()[7].schema(), other.boarding_group); + fieldSetFlags()[7] = other.fieldSetFlags()[7]; + } + if (isValidValue(fields()[8], other.plane_model)) { + this.plane_model = data().deepCopy(fields()[8].schema(), other.plane_model); + fieldSetFlags()[8] = other.fieldSetFlags()[8]; + } + if (isValidValue(fields()[9], other.airline)) { + this.airline = data().deepCopy(fields()[9].schema(), other.airline); + fieldSetFlags()[9] = other.fieldSetFlags()[9]; + } + } + + /** + * Creates a Builder by copying an existing Flight instance + * @param other The existing instance to copy. + */ + private Builder(io.skodjob.datagenerator.models.flights.Flight other) { + super(SCHEMA$, MODEL$); + if (isValidValue(fields()[0], other.number)) { + this.number = data().deepCopy(fields()[0].schema(), other.number); + fieldSetFlags()[0] = true; + } + if (isValidValue(fields()[1], other.departure_airport)) { + this.departure_airport = data().deepCopy(fields()[1].schema(), other.departure_airport); + fieldSetFlags()[1] = true; + } + if (isValidValue(fields()[2], other.arrival_airport)) { + this.arrival_airport = data().deepCopy(fields()[2].schema(), other.arrival_airport); + fieldSetFlags()[2] = true; + } + if (isValidValue(fields()[3], other.departure_time)) { + this.departure_time = data().deepCopy(fields()[3].schema(), other.departure_time); + fieldSetFlags()[3] = true; + } + if (isValidValue(fields()[4], other.arrival_time)) { + this.arrival_time = data().deepCopy(fields()[4].schema(), other.arrival_time); + fieldSetFlags()[4] = true; + } + if (isValidValue(fields()[5], other.seat_number)) { + this.seat_number = data().deepCopy(fields()[5].schema(), other.seat_number); + fieldSetFlags()[5] = true; + } + if (isValidValue(fields()[6], other.gate)) { + this.gate = data().deepCopy(fields()[6].schema(), other.gate); + fieldSetFlags()[6] = true; + } + if (isValidValue(fields()[7], other.boarding_group)) { + this.boarding_group = data().deepCopy(fields()[7].schema(), other.boarding_group); + fieldSetFlags()[7] = true; + } + if (isValidValue(fields()[8], other.plane_model)) { + this.plane_model = data().deepCopy(fields()[8].schema(), other.plane_model); + fieldSetFlags()[8] = true; + } + if (isValidValue(fields()[9], other.airline)) { + this.airline = data().deepCopy(fields()[9].schema(), other.airline); + fieldSetFlags()[9] = true; + } + } + + /** + * Gets the value of the 'number' field. + * @return The value. + */ + public java.lang.CharSequence getNumber() { + return number; + } + + + /** + * Sets the value of the 'number' field. + * @param value The value of 'number'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.flights.Flight.Builder setNumber(java.lang.CharSequence value) { + validate(fields()[0], value); + this.number = value; + fieldSetFlags()[0] = true; + return this; + } + + /** + * Checks whether the 'number' field has been set. + * @return True if the 'number' field has been set, false otherwise. + */ + public boolean hasNumber() { + return fieldSetFlags()[0]; + } + + + /** + * Clears the value of the 'number' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.flights.Flight.Builder clearNumber() { + number = null; + fieldSetFlags()[0] = false; + return this; + } + + /** + * Gets the value of the 'departure_airport' field. + * @return The value. + */ + public java.lang.CharSequence getDepartureAirport() { + return departure_airport; + } + + + /** + * Sets the value of the 'departure_airport' field. + * @param value The value of 'departure_airport'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.flights.Flight.Builder setDepartureAirport(java.lang.CharSequence value) { + validate(fields()[1], value); + this.departure_airport = value; + fieldSetFlags()[1] = true; + return this; + } + + /** + * Checks whether the 'departure_airport' field has been set. + * @return True if the 'departure_airport' field has been set, false otherwise. + */ + public boolean hasDepartureAirport() { + return fieldSetFlags()[1]; + } + + + /** + * Clears the value of the 'departure_airport' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.flights.Flight.Builder clearDepartureAirport() { + departure_airport = null; + fieldSetFlags()[1] = false; + return this; + } + + /** + * Gets the value of the 'arrival_airport' field. + * @return The value. + */ + public java.lang.CharSequence getArrivalAirport() { + return arrival_airport; + } + + + /** + * Sets the value of the 'arrival_airport' field. + * @param value The value of 'arrival_airport'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.flights.Flight.Builder setArrivalAirport(java.lang.CharSequence value) { + validate(fields()[2], value); + this.arrival_airport = value; + fieldSetFlags()[2] = true; + return this; + } + + /** + * Checks whether the 'arrival_airport' field has been set. + * @return True if the 'arrival_airport' field has been set, false otherwise. + */ + public boolean hasArrivalAirport() { + return fieldSetFlags()[2]; + } + + + /** + * Clears the value of the 'arrival_airport' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.flights.Flight.Builder clearArrivalAirport() { + arrival_airport = null; + fieldSetFlags()[2] = false; + return this; + } + + /** + * Gets the value of the 'departure_time' field. + * @return The value. + */ + public java.lang.CharSequence getDepartureTime() { + return departure_time; + } + + + /** + * Sets the value of the 'departure_time' field. + * @param value The value of 'departure_time'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.flights.Flight.Builder setDepartureTime(java.lang.CharSequence value) { + validate(fields()[3], value); + this.departure_time = value; + fieldSetFlags()[3] = true; + return this; + } + + /** + * Checks whether the 'departure_time' field has been set. + * @return True if the 'departure_time' field has been set, false otherwise. + */ + public boolean hasDepartureTime() { + return fieldSetFlags()[3]; + } + + + /** + * Clears the value of the 'departure_time' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.flights.Flight.Builder clearDepartureTime() { + departure_time = null; + fieldSetFlags()[3] = false; + return this; + } + + /** + * Gets the value of the 'arrival_time' field. + * @return The value. + */ + public java.lang.CharSequence getArrivalTime() { + return arrival_time; + } + + + /** + * Sets the value of the 'arrival_time' field. + * @param value The value of 'arrival_time'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.flights.Flight.Builder setArrivalTime(java.lang.CharSequence value) { + validate(fields()[4], value); + this.arrival_time = value; + fieldSetFlags()[4] = true; + return this; + } + + /** + * Checks whether the 'arrival_time' field has been set. + * @return True if the 'arrival_time' field has been set, false otherwise. + */ + public boolean hasArrivalTime() { + return fieldSetFlags()[4]; + } + + + /** + * Clears the value of the 'arrival_time' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.flights.Flight.Builder clearArrivalTime() { + arrival_time = null; + fieldSetFlags()[4] = false; + return this; + } + + /** + * Gets the value of the 'seat_number' field. + * @return The value. + */ + public java.lang.CharSequence getSeatNumber() { + return seat_number; + } + + + /** + * Sets the value of the 'seat_number' field. + * @param value The value of 'seat_number'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.flights.Flight.Builder setSeatNumber(java.lang.CharSequence value) { + validate(fields()[5], value); + this.seat_number = value; + fieldSetFlags()[5] = true; + return this; + } + + /** + * Checks whether the 'seat_number' field has been set. + * @return True if the 'seat_number' field has been set, false otherwise. + */ + public boolean hasSeatNumber() { + return fieldSetFlags()[5]; + } + + + /** + * Clears the value of the 'seat_number' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.flights.Flight.Builder clearSeatNumber() { + seat_number = null; + fieldSetFlags()[5] = false; + return this; + } + + /** + * Gets the value of the 'gate' field. + * @return The value. + */ + public java.lang.CharSequence getGate() { + return gate; + } + + + /** + * Sets the value of the 'gate' field. + * @param value The value of 'gate'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.flights.Flight.Builder setGate(java.lang.CharSequence value) { + validate(fields()[6], value); + this.gate = value; + fieldSetFlags()[6] = true; + return this; + } + + /** + * Checks whether the 'gate' field has been set. + * @return True if the 'gate' field has been set, false otherwise. + */ + public boolean hasGate() { + return fieldSetFlags()[6]; + } + + + /** + * Clears the value of the 'gate' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.flights.Flight.Builder clearGate() { + gate = null; + fieldSetFlags()[6] = false; + return this; + } + + /** + * Gets the value of the 'boarding_group' field. + * @return The value. + */ + public java.lang.CharSequence getBoardingGroup() { + return boarding_group; + } + + + /** + * Sets the value of the 'boarding_group' field. + * @param value The value of 'boarding_group'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.flights.Flight.Builder setBoardingGroup(java.lang.CharSequence value) { + validate(fields()[7], value); + this.boarding_group = value; + fieldSetFlags()[7] = true; + return this; + } + + /** + * Checks whether the 'boarding_group' field has been set. + * @return True if the 'boarding_group' field has been set, false otherwise. + */ + public boolean hasBoardingGroup() { + return fieldSetFlags()[7]; + } + + + /** + * Clears the value of the 'boarding_group' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.flights.Flight.Builder clearBoardingGroup() { + boarding_group = null; + fieldSetFlags()[7] = false; + return this; + } + + /** + * Gets the value of the 'plane_model' field. + * @return The value. + */ + public java.lang.CharSequence getPlaneModel() { + return plane_model; + } + + + /** + * Sets the value of the 'plane_model' field. + * @param value The value of 'plane_model'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.flights.Flight.Builder setPlaneModel(java.lang.CharSequence value) { + validate(fields()[8], value); + this.plane_model = value; + fieldSetFlags()[8] = true; + return this; + } + + /** + * Checks whether the 'plane_model' field has been set. + * @return True if the 'plane_model' field has been set, false otherwise. + */ + public boolean hasPlaneModel() { + return fieldSetFlags()[8]; + } + + + /** + * Clears the value of the 'plane_model' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.flights.Flight.Builder clearPlaneModel() { + plane_model = null; + fieldSetFlags()[8] = false; + return this; + } + + /** + * Gets the value of the 'airline' field. + * @return The value. + */ + public java.lang.CharSequence getAirline() { + return airline; + } + + + /** + * Sets the value of the 'airline' field. + * @param value The value of 'airline'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.flights.Flight.Builder setAirline(java.lang.CharSequence value) { + validate(fields()[9], value); + this.airline = value; + fieldSetFlags()[9] = true; + return this; + } + + /** + * Checks whether the 'airline' field has been set. + * @return True if the 'airline' field has been set, false otherwise. + */ + public boolean hasAirline() { + return fieldSetFlags()[9]; + } + + + /** + * Clears the value of the 'airline' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.flights.Flight.Builder clearAirline() { + airline = null; + fieldSetFlags()[9] = false; + return this; + } + + @Override + @SuppressWarnings("unchecked") + public Flight build() { + try { + Flight record = new Flight(); + record.number = fieldSetFlags()[0] ? this.number : (java.lang.CharSequence) defaultValue(fields()[0]); + record.departure_airport = fieldSetFlags()[1] ? this.departure_airport : (java.lang.CharSequence) defaultValue(fields()[1]); + record.arrival_airport = fieldSetFlags()[2] ? this.arrival_airport : (java.lang.CharSequence) defaultValue(fields()[2]); + record.departure_time = fieldSetFlags()[3] ? this.departure_time : (java.lang.CharSequence) defaultValue(fields()[3]); + record.arrival_time = fieldSetFlags()[4] ? this.arrival_time : (java.lang.CharSequence) defaultValue(fields()[4]); + record.seat_number = fieldSetFlags()[5] ? this.seat_number : (java.lang.CharSequence) defaultValue(fields()[5]); + record.gate = fieldSetFlags()[6] ? this.gate : (java.lang.CharSequence) defaultValue(fields()[6]); + record.boarding_group = fieldSetFlags()[7] ? this.boarding_group : (java.lang.CharSequence) defaultValue(fields()[7]); + record.plane_model = fieldSetFlags()[8] ? this.plane_model : (java.lang.CharSequence) defaultValue(fields()[8]); + record.airline = fieldSetFlags()[9] ? this.airline : (java.lang.CharSequence) defaultValue(fields()[9]); + return record; + } catch (org.apache.avro.AvroMissingFieldException e) { + throw e; + } catch (java.lang.Exception e) { + throw new org.apache.avro.AvroRuntimeException(e); + } + } + } + + @SuppressWarnings("unchecked") + private static final org.apache.avro.io.DatumWriter + WRITER$ = (org.apache.avro.io.DatumWriter)MODEL$.createDatumWriter(SCHEMA$); + + @Override public void writeExternal(java.io.ObjectOutput out) + throws java.io.IOException { + WRITER$.write(this, SpecificData.getEncoder(out)); + } + + @SuppressWarnings("unchecked") + private static final org.apache.avro.io.DatumReader + READER$ = (org.apache.avro.io.DatumReader)MODEL$.createDatumReader(SCHEMA$); + + @Override public void readExternal(java.io.ObjectInput in) + throws java.io.IOException { + READER$.read(this, SpecificData.getDecoder(in)); + } + + @Override protected boolean hasCustomCoders() { return true; } + + @Override public void customEncode(org.apache.avro.io.Encoder out) + throws java.io.IOException + { + out.writeString(this.number); + + out.writeString(this.departure_airport); + + out.writeString(this.arrival_airport); + + out.writeString(this.departure_time); + + out.writeString(this.arrival_time); + + out.writeString(this.seat_number); + + out.writeString(this.gate); + + out.writeString(this.boarding_group); + + out.writeString(this.plane_model); + + out.writeString(this.airline); + + } + + @Override public void customDecode(org.apache.avro.io.ResolvingDecoder in) + throws java.io.IOException + { + org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff(); + if (fieldOrder == null) { + this.number = in.readString(this.number instanceof Utf8 ? (Utf8)this.number : null); + + this.departure_airport = in.readString(this.departure_airport instanceof Utf8 ? (Utf8)this.departure_airport : null); + + this.arrival_airport = in.readString(this.arrival_airport instanceof Utf8 ? (Utf8)this.arrival_airport : null); + + this.departure_time = in.readString(this.departure_time instanceof Utf8 ? (Utf8)this.departure_time : null); + + this.arrival_time = in.readString(this.arrival_time instanceof Utf8 ? (Utf8)this.arrival_time : null); + + this.seat_number = in.readString(this.seat_number instanceof Utf8 ? (Utf8)this.seat_number : null); + + this.gate = in.readString(this.gate instanceof Utf8 ? (Utf8)this.gate : null); + + this.boarding_group = in.readString(this.boarding_group instanceof Utf8 ? (Utf8)this.boarding_group : null); + + this.plane_model = in.readString(this.plane_model instanceof Utf8 ? (Utf8)this.plane_model : null); + + this.airline = in.readString(this.airline instanceof Utf8 ? (Utf8)this.airline : null); + + } else { + for (int i = 0; i < 10; i++) { + switch (fieldOrder[i].pos()) { + case 0: + this.number = in.readString(this.number instanceof Utf8 ? (Utf8)this.number : null); + break; + + case 1: + this.departure_airport = in.readString(this.departure_airport instanceof Utf8 ? (Utf8)this.departure_airport : null); + break; + + case 2: + this.arrival_airport = in.readString(this.arrival_airport instanceof Utf8 ? (Utf8)this.arrival_airport : null); + break; + + case 3: + this.departure_time = in.readString(this.departure_time instanceof Utf8 ? (Utf8)this.departure_time : null); + break; + + case 4: + this.arrival_time = in.readString(this.arrival_time instanceof Utf8 ? (Utf8)this.arrival_time : null); + break; + + case 5: + this.seat_number = in.readString(this.seat_number instanceof Utf8 ? (Utf8)this.seat_number : null); + break; + + case 6: + this.gate = in.readString(this.gate instanceof Utf8 ? (Utf8)this.gate : null); + break; + + case 7: + this.boarding_group = in.readString(this.boarding_group instanceof Utf8 ? (Utf8)this.boarding_group : null); + break; + + case 8: + this.plane_model = in.readString(this.plane_model instanceof Utf8 ? (Utf8)this.plane_model : null); + break; + + case 9: + this.airline = in.readString(this.airline instanceof Utf8 ? (Utf8)this.airline : null); + break; + + default: + throw new java.io.IOException("Corrupt ResolvingDecoder."); + } + } + } + } +} + + + + + + + + + + diff --git a/src/main/java/io/skodjob/datagenerator/models/flights/FlightRecord.java b/src/main/java/io/skodjob/datagenerator/models/flights/FlightRecord.java new file mode 100644 index 0000000..ca8a137 --- /dev/null +++ b/src/main/java/io/skodjob/datagenerator/models/flights/FlightRecord.java @@ -0,0 +1,511 @@ +/** + * Autogenerated by Avro + * + * DO NOT EDIT DIRECTLY + */ +package io.skodjob.datagenerator.models.flights; + +import org.apache.avro.generic.GenericArray; +import org.apache.avro.specific.SpecificData; +import org.apache.avro.util.Utf8; +import org.apache.avro.message.BinaryMessageEncoder; +import org.apache.avro.message.BinaryMessageDecoder; +import org.apache.avro.message.SchemaStore; + +@org.apache.avro.specific.AvroGenerated +public class FlightRecord extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord { + private static final long serialVersionUID = 1649870568249374036L; + + + public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"FlightRecord\",\"namespace\":\"io.skodjob.datagenerator.models.flights\",\"fields\":[{\"name\":\"passenger\",\"type\":{\"type\":\"record\",\"name\":\"Passenger\",\"fields\":[{\"name\":\"id\",\"type\":\"string\"},{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"passport_number\",\"type\":\"string\"},{\"name\":\"nationality\",\"type\":\"string\"}]}},{\"name\":\"flight\",\"type\":{\"type\":\"record\",\"name\":\"Flight\",\"fields\":[{\"name\":\"number\",\"type\":\"string\"},{\"name\":\"departure_airport\",\"type\":\"string\"},{\"name\":\"arrival_airport\",\"type\":\"string\"},{\"name\":\"departure_time\",\"type\":\"string\"},{\"name\":\"arrival_time\",\"type\":\"string\"},{\"name\":\"seat_number\",\"type\":\"string\"},{\"name\":\"gate\",\"type\":\"string\"},{\"name\":\"boarding_group\",\"type\":\"string\"},{\"name\":\"plane_model\",\"type\":\"string\"},{\"name\":\"airline\",\"type\":\"string\"}]}}]}"); + public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } + + private static final SpecificData MODEL$ = new SpecificData(); + + private static final BinaryMessageEncoder ENCODER = + new BinaryMessageEncoder<>(MODEL$, SCHEMA$); + + private static final BinaryMessageDecoder DECODER = + new BinaryMessageDecoder<>(MODEL$, SCHEMA$); + + /** + * Return the BinaryMessageEncoder instance used by this class. + * @return the message encoder used by this class + */ + public static BinaryMessageEncoder getEncoder() { + return ENCODER; + } + + /** + * Return the BinaryMessageDecoder instance used by this class. + * @return the message decoder used by this class + */ + public static BinaryMessageDecoder getDecoder() { + return DECODER; + } + + /** + * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}. + * @param resolver a {@link SchemaStore} used to find schemas by fingerprint + * @return a BinaryMessageDecoder instance for this class backed by the given SchemaStore + */ + public static BinaryMessageDecoder createDecoder(SchemaStore resolver) { + return new BinaryMessageDecoder<>(MODEL$, SCHEMA$, resolver); + } + + /** + * Serializes this FlightRecord to a ByteBuffer. + * @return a buffer holding the serialized data for this instance + * @throws java.io.IOException if this instance could not be serialized + */ + public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException { + return ENCODER.encode(this); + } + + /** + * Deserializes a FlightRecord from a ByteBuffer. + * @param b a byte buffer holding serialized data for an instance of this class + * @return a FlightRecord instance decoded from the given buffer + * @throws java.io.IOException if the given bytes could not be deserialized into an instance of this class + */ + public static FlightRecord fromByteBuffer( + java.nio.ByteBuffer b) throws java.io.IOException { + return DECODER.decode(b); + } + + private io.skodjob.datagenerator.models.flights.Passenger passenger; + private io.skodjob.datagenerator.models.flights.Flight flight; + + /** + * Default constructor. Note that this does not initialize fields + * to their default values from the schema. If that is desired then + * one should use newBuilder(). + */ + public FlightRecord() {} + + /** + * All-args constructor. + * @param passenger The new value for passenger + * @param flight The new value for flight + */ + public FlightRecord(io.skodjob.datagenerator.models.flights.Passenger passenger, io.skodjob.datagenerator.models.flights.Flight flight) { + this.passenger = passenger; + this.flight = flight; + } + + @Override + public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; } + + @Override + public org.apache.avro.Schema getSchema() { return SCHEMA$; } + + // Used by DatumWriter. Applications should not call. + @Override + public java.lang.Object get(int field$) { + switch (field$) { + case 0: return passenger; + case 1: return flight; + default: throw new IndexOutOfBoundsException("Invalid index: " + field$); + } + } + + // Used by DatumReader. Applications should not call. + @Override + @SuppressWarnings(value="unchecked") + public void put(int field$, java.lang.Object value$) { + switch (field$) { + case 0: passenger = (io.skodjob.datagenerator.models.flights.Passenger)value$; break; + case 1: flight = (io.skodjob.datagenerator.models.flights.Flight)value$; break; + default: throw new IndexOutOfBoundsException("Invalid index: " + field$); + } + } + + /** + * Gets the value of the 'passenger' field. + * @return The value of the 'passenger' field. + */ + public io.skodjob.datagenerator.models.flights.Passenger getPassenger() { + return passenger; + } + + + /** + * Sets the value of the 'passenger' field. + * @param value the value to set. + */ + public void setPassenger(io.skodjob.datagenerator.models.flights.Passenger value) { + this.passenger = value; + } + + /** + * Gets the value of the 'flight' field. + * @return The value of the 'flight' field. + */ + public io.skodjob.datagenerator.models.flights.Flight getFlight() { + return flight; + } + + + /** + * Sets the value of the 'flight' field. + * @param value the value to set. + */ + public void setFlight(io.skodjob.datagenerator.models.flights.Flight value) { + this.flight = value; + } + + /** + * Creates a new FlightRecord RecordBuilder. + * @return A new FlightRecord RecordBuilder + */ + public static io.skodjob.datagenerator.models.flights.FlightRecord.Builder newBuilder() { + return new io.skodjob.datagenerator.models.flights.FlightRecord.Builder(); + } + + /** + * Creates a new FlightRecord RecordBuilder by copying an existing Builder. + * @param other The existing builder to copy. + * @return A new FlightRecord RecordBuilder + */ + public static io.skodjob.datagenerator.models.flights.FlightRecord.Builder newBuilder(io.skodjob.datagenerator.models.flights.FlightRecord.Builder other) { + if (other == null) { + return new io.skodjob.datagenerator.models.flights.FlightRecord.Builder(); + } else { + return new io.skodjob.datagenerator.models.flights.FlightRecord.Builder(other); + } + } + + /** + * Creates a new FlightRecord RecordBuilder by copying an existing FlightRecord instance. + * @param other The existing instance to copy. + * @return A new FlightRecord RecordBuilder + */ + public static io.skodjob.datagenerator.models.flights.FlightRecord.Builder newBuilder(io.skodjob.datagenerator.models.flights.FlightRecord other) { + if (other == null) { + return new io.skodjob.datagenerator.models.flights.FlightRecord.Builder(); + } else { + return new io.skodjob.datagenerator.models.flights.FlightRecord.Builder(other); + } + } + + /** + * RecordBuilder for FlightRecord instances. + */ + @org.apache.avro.specific.AvroGenerated + public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase + implements org.apache.avro.data.RecordBuilder { + + private io.skodjob.datagenerator.models.flights.Passenger passenger; + private io.skodjob.datagenerator.models.flights.Passenger.Builder passengerBuilder; + private io.skodjob.datagenerator.models.flights.Flight flight; + private io.skodjob.datagenerator.models.flights.Flight.Builder flightBuilder; + + /** Creates a new Builder */ + private Builder() { + super(SCHEMA$, MODEL$); + } + + /** + * Creates a Builder by copying an existing Builder. + * @param other The existing Builder to copy. + */ + private Builder(io.skodjob.datagenerator.models.flights.FlightRecord.Builder other) { + super(other); + if (isValidValue(fields()[0], other.passenger)) { + this.passenger = data().deepCopy(fields()[0].schema(), other.passenger); + fieldSetFlags()[0] = other.fieldSetFlags()[0]; + } + if (other.hasPassengerBuilder()) { + this.passengerBuilder = io.skodjob.datagenerator.models.flights.Passenger.newBuilder(other.getPassengerBuilder()); + } + if (isValidValue(fields()[1], other.flight)) { + this.flight = data().deepCopy(fields()[1].schema(), other.flight); + fieldSetFlags()[1] = other.fieldSetFlags()[1]; + } + if (other.hasFlightBuilder()) { + this.flightBuilder = io.skodjob.datagenerator.models.flights.Flight.newBuilder(other.getFlightBuilder()); + } + } + + /** + * Creates a Builder by copying an existing FlightRecord instance + * @param other The existing instance to copy. + */ + private Builder(io.skodjob.datagenerator.models.flights.FlightRecord other) { + super(SCHEMA$, MODEL$); + if (isValidValue(fields()[0], other.passenger)) { + this.passenger = data().deepCopy(fields()[0].schema(), other.passenger); + fieldSetFlags()[0] = true; + } + this.passengerBuilder = null; + if (isValidValue(fields()[1], other.flight)) { + this.flight = data().deepCopy(fields()[1].schema(), other.flight); + fieldSetFlags()[1] = true; + } + this.flightBuilder = null; + } + + /** + * Gets the value of the 'passenger' field. + * @return The value. + */ + public io.skodjob.datagenerator.models.flights.Passenger getPassenger() { + return passenger; + } + + + /** + * Sets the value of the 'passenger' field. + * @param value The value of 'passenger'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.flights.FlightRecord.Builder setPassenger(io.skodjob.datagenerator.models.flights.Passenger value) { + validate(fields()[0], value); + this.passengerBuilder = null; + this.passenger = value; + fieldSetFlags()[0] = true; + return this; + } + + /** + * Checks whether the 'passenger' field has been set. + * @return True if the 'passenger' field has been set, false otherwise. + */ + public boolean hasPassenger() { + return fieldSetFlags()[0]; + } + + /** + * Gets the Builder instance for the 'passenger' field and creates one if it doesn't exist yet. + * @return This builder. + */ + public io.skodjob.datagenerator.models.flights.Passenger.Builder getPassengerBuilder() { + if (passengerBuilder == null) { + if (hasPassenger()) { + setPassengerBuilder(io.skodjob.datagenerator.models.flights.Passenger.newBuilder(passenger)); + } else { + setPassengerBuilder(io.skodjob.datagenerator.models.flights.Passenger.newBuilder()); + } + } + return passengerBuilder; + } + + /** + * Sets the Builder instance for the 'passenger' field + * @param value The builder instance that must be set. + * @return This builder. + */ + + public io.skodjob.datagenerator.models.flights.FlightRecord.Builder setPassengerBuilder(io.skodjob.datagenerator.models.flights.Passenger.Builder value) { + clearPassenger(); + passengerBuilder = value; + return this; + } + + /** + * Checks whether the 'passenger' field has an active Builder instance + * @return True if the 'passenger' field has an active Builder instance + */ + public boolean hasPassengerBuilder() { + return passengerBuilder != null; + } + + /** + * Clears the value of the 'passenger' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.flights.FlightRecord.Builder clearPassenger() { + passenger = null; + passengerBuilder = null; + fieldSetFlags()[0] = false; + return this; + } + + /** + * Gets the value of the 'flight' field. + * @return The value. + */ + public io.skodjob.datagenerator.models.flights.Flight getFlight() { + return flight; + } + + + /** + * Sets the value of the 'flight' field. + * @param value The value of 'flight'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.flights.FlightRecord.Builder setFlight(io.skodjob.datagenerator.models.flights.Flight value) { + validate(fields()[1], value); + this.flightBuilder = null; + this.flight = value; + fieldSetFlags()[1] = true; + return this; + } + + /** + * Checks whether the 'flight' field has been set. + * @return True if the 'flight' field has been set, false otherwise. + */ + public boolean hasFlight() { + return fieldSetFlags()[1]; + } + + /** + * Gets the Builder instance for the 'flight' field and creates one if it doesn't exist yet. + * @return This builder. + */ + public io.skodjob.datagenerator.models.flights.Flight.Builder getFlightBuilder() { + if (flightBuilder == null) { + if (hasFlight()) { + setFlightBuilder(io.skodjob.datagenerator.models.flights.Flight.newBuilder(flight)); + } else { + setFlightBuilder(io.skodjob.datagenerator.models.flights.Flight.newBuilder()); + } + } + return flightBuilder; + } + + /** + * Sets the Builder instance for the 'flight' field + * @param value The builder instance that must be set. + * @return This builder. + */ + + public io.skodjob.datagenerator.models.flights.FlightRecord.Builder setFlightBuilder(io.skodjob.datagenerator.models.flights.Flight.Builder value) { + clearFlight(); + flightBuilder = value; + return this; + } + + /** + * Checks whether the 'flight' field has an active Builder instance + * @return True if the 'flight' field has an active Builder instance + */ + public boolean hasFlightBuilder() { + return flightBuilder != null; + } + + /** + * Clears the value of the 'flight' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.flights.FlightRecord.Builder clearFlight() { + flight = null; + flightBuilder = null; + fieldSetFlags()[1] = false; + return this; + } + + @Override + @SuppressWarnings("unchecked") + public FlightRecord build() { + try { + FlightRecord record = new FlightRecord(); + if (passengerBuilder != null) { + try { + record.passenger = this.passengerBuilder.build(); + } catch (org.apache.avro.AvroMissingFieldException e) { + e.addParentField(record.getSchema().getField("passenger")); + throw e; + } + } else { + record.passenger = fieldSetFlags()[0] ? this.passenger : (io.skodjob.datagenerator.models.flights.Passenger) defaultValue(fields()[0]); + } + if (flightBuilder != null) { + try { + record.flight = this.flightBuilder.build(); + } catch (org.apache.avro.AvroMissingFieldException e) { + e.addParentField(record.getSchema().getField("flight")); + throw e; + } + } else { + record.flight = fieldSetFlags()[1] ? this.flight : (io.skodjob.datagenerator.models.flights.Flight) defaultValue(fields()[1]); + } + return record; + } catch (org.apache.avro.AvroMissingFieldException e) { + throw e; + } catch (java.lang.Exception e) { + throw new org.apache.avro.AvroRuntimeException(e); + } + } + } + + @SuppressWarnings("unchecked") + private static final org.apache.avro.io.DatumWriter + WRITER$ = (org.apache.avro.io.DatumWriter)MODEL$.createDatumWriter(SCHEMA$); + + @Override public void writeExternal(java.io.ObjectOutput out) + throws java.io.IOException { + WRITER$.write(this, SpecificData.getEncoder(out)); + } + + @SuppressWarnings("unchecked") + private static final org.apache.avro.io.DatumReader + READER$ = (org.apache.avro.io.DatumReader)MODEL$.createDatumReader(SCHEMA$); + + @Override public void readExternal(java.io.ObjectInput in) + throws java.io.IOException { + READER$.read(this, SpecificData.getDecoder(in)); + } + + @Override protected boolean hasCustomCoders() { return true; } + + @Override public void customEncode(org.apache.avro.io.Encoder out) + throws java.io.IOException + { + this.passenger.customEncode(out); + + this.flight.customEncode(out); + + } + + @Override public void customDecode(org.apache.avro.io.ResolvingDecoder in) + throws java.io.IOException + { + org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff(); + if (fieldOrder == null) { + if (this.passenger == null) { + this.passenger = new io.skodjob.datagenerator.models.flights.Passenger(); + } + this.passenger.customDecode(in); + + if (this.flight == null) { + this.flight = new io.skodjob.datagenerator.models.flights.Flight(); + } + this.flight.customDecode(in); + + } else { + for (int i = 0; i < 2; i++) { + switch (fieldOrder[i].pos()) { + case 0: + if (this.passenger == null) { + this.passenger = new io.skodjob.datagenerator.models.flights.Passenger(); + } + this.passenger.customDecode(in); + break; + + case 1: + if (this.flight == null) { + this.flight = new io.skodjob.datagenerator.models.flights.Flight(); + } + this.flight.customDecode(in); + break; + + default: + throw new java.io.IOException("Corrupt ResolvingDecoder."); + } + } + } + } +} + + + + + + + + + + diff --git a/src/main/java/io/skodjob/datagenerator/models/flights/Passenger.java b/src/main/java/io/skodjob/datagenerator/models/flights/Passenger.java new file mode 100644 index 0000000..9cc1146 --- /dev/null +++ b/src/main/java/io/skodjob/datagenerator/models/flights/Passenger.java @@ -0,0 +1,559 @@ +/** + * Autogenerated by Avro + * + * DO NOT EDIT DIRECTLY + */ +package io.skodjob.datagenerator.models.flights; + +import org.apache.avro.generic.GenericArray; +import org.apache.avro.specific.SpecificData; +import org.apache.avro.util.Utf8; +import org.apache.avro.message.BinaryMessageEncoder; +import org.apache.avro.message.BinaryMessageDecoder; +import org.apache.avro.message.SchemaStore; + +@org.apache.avro.specific.AvroGenerated +public class Passenger extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord { + private static final long serialVersionUID = 7514441306189719528L; + + + public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"Passenger\",\"namespace\":\"io.skodjob.datagenerator.models.flights\",\"fields\":[{\"name\":\"id\",\"type\":\"string\"},{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"passport_number\",\"type\":\"string\"},{\"name\":\"nationality\",\"type\":\"string\"}]}"); + public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } + + private static final SpecificData MODEL$ = new SpecificData(); + + private static final BinaryMessageEncoder ENCODER = + new BinaryMessageEncoder<>(MODEL$, SCHEMA$); + + private static final BinaryMessageDecoder DECODER = + new BinaryMessageDecoder<>(MODEL$, SCHEMA$); + + /** + * Return the BinaryMessageEncoder instance used by this class. + * @return the message encoder used by this class + */ + public static BinaryMessageEncoder getEncoder() { + return ENCODER; + } + + /** + * Return the BinaryMessageDecoder instance used by this class. + * @return the message decoder used by this class + */ + public static BinaryMessageDecoder getDecoder() { + return DECODER; + } + + /** + * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}. + * @param resolver a {@link SchemaStore} used to find schemas by fingerprint + * @return a BinaryMessageDecoder instance for this class backed by the given SchemaStore + */ + public static BinaryMessageDecoder createDecoder(SchemaStore resolver) { + return new BinaryMessageDecoder<>(MODEL$, SCHEMA$, resolver); + } + + /** + * Serializes this Passenger to a ByteBuffer. + * @return a buffer holding the serialized data for this instance + * @throws java.io.IOException if this instance could not be serialized + */ + public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException { + return ENCODER.encode(this); + } + + /** + * Deserializes a Passenger from a ByteBuffer. + * @param b a byte buffer holding serialized data for an instance of this class + * @return a Passenger instance decoded from the given buffer + * @throws java.io.IOException if the given bytes could not be deserialized into an instance of this class + */ + public static Passenger fromByteBuffer( + java.nio.ByteBuffer b) throws java.io.IOException { + return DECODER.decode(b); + } + + private java.lang.CharSequence id; + private java.lang.CharSequence name; + private java.lang.CharSequence passport_number; + private java.lang.CharSequence nationality; + + /** + * Default constructor. Note that this does not initialize fields + * to their default values from the schema. If that is desired then + * one should use newBuilder(). + */ + public Passenger() {} + + /** + * All-args constructor. + * @param id The new value for id + * @param name The new value for name + * @param passport_number The new value for passport_number + * @param nationality The new value for nationality + */ + public Passenger(java.lang.CharSequence id, java.lang.CharSequence name, java.lang.CharSequence passport_number, java.lang.CharSequence nationality) { + this.id = id; + this.name = name; + this.passport_number = passport_number; + this.nationality = nationality; + } + + @Override + public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; } + + @Override + public org.apache.avro.Schema getSchema() { return SCHEMA$; } + + // Used by DatumWriter. Applications should not call. + @Override + public java.lang.Object get(int field$) { + switch (field$) { + case 0: return id; + case 1: return name; + case 2: return passport_number; + case 3: return nationality; + default: throw new IndexOutOfBoundsException("Invalid index: " + field$); + } + } + + // Used by DatumReader. Applications should not call. + @Override + @SuppressWarnings(value="unchecked") + public void put(int field$, java.lang.Object value$) { + switch (field$) { + case 0: id = (java.lang.CharSequence)value$; break; + case 1: name = (java.lang.CharSequence)value$; break; + case 2: passport_number = (java.lang.CharSequence)value$; break; + case 3: nationality = (java.lang.CharSequence)value$; break; + default: throw new IndexOutOfBoundsException("Invalid index: " + field$); + } + } + + /** + * Gets the value of the 'id' field. + * @return The value of the 'id' field. + */ + public java.lang.CharSequence getId() { + return id; + } + + + /** + * Sets the value of the 'id' field. + * @param value the value to set. + */ + public void setId(java.lang.CharSequence value) { + this.id = value; + } + + /** + * Gets the value of the 'name' field. + * @return The value of the 'name' field. + */ + public java.lang.CharSequence getName() { + return name; + } + + + /** + * Sets the value of the 'name' field. + * @param value the value to set. + */ + public void setName(java.lang.CharSequence value) { + this.name = value; + } + + /** + * Gets the value of the 'passport_number' field. + * @return The value of the 'passport_number' field. + */ + public java.lang.CharSequence getPassportNumber() { + return passport_number; + } + + + /** + * Sets the value of the 'passport_number' field. + * @param value the value to set. + */ + public void setPassportNumber(java.lang.CharSequence value) { + this.passport_number = value; + } + + /** + * Gets the value of the 'nationality' field. + * @return The value of the 'nationality' field. + */ + public java.lang.CharSequence getNationality() { + return nationality; + } + + + /** + * Sets the value of the 'nationality' field. + * @param value the value to set. + */ + public void setNationality(java.lang.CharSequence value) { + this.nationality = value; + } + + /** + * Creates a new Passenger RecordBuilder. + * @return A new Passenger RecordBuilder + */ + public static io.skodjob.datagenerator.models.flights.Passenger.Builder newBuilder() { + return new io.skodjob.datagenerator.models.flights.Passenger.Builder(); + } + + /** + * Creates a new Passenger RecordBuilder by copying an existing Builder. + * @param other The existing builder to copy. + * @return A new Passenger RecordBuilder + */ + public static io.skodjob.datagenerator.models.flights.Passenger.Builder newBuilder(io.skodjob.datagenerator.models.flights.Passenger.Builder other) { + if (other == null) { + return new io.skodjob.datagenerator.models.flights.Passenger.Builder(); + } else { + return new io.skodjob.datagenerator.models.flights.Passenger.Builder(other); + } + } + + /** + * Creates a new Passenger RecordBuilder by copying an existing Passenger instance. + * @param other The existing instance to copy. + * @return A new Passenger RecordBuilder + */ + public static io.skodjob.datagenerator.models.flights.Passenger.Builder newBuilder(io.skodjob.datagenerator.models.flights.Passenger other) { + if (other == null) { + return new io.skodjob.datagenerator.models.flights.Passenger.Builder(); + } else { + return new io.skodjob.datagenerator.models.flights.Passenger.Builder(other); + } + } + + /** + * RecordBuilder for Passenger instances. + */ + @org.apache.avro.specific.AvroGenerated + public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase + implements org.apache.avro.data.RecordBuilder { + + private java.lang.CharSequence id; + private java.lang.CharSequence name; + private java.lang.CharSequence passport_number; + private java.lang.CharSequence nationality; + + /** Creates a new Builder */ + private Builder() { + super(SCHEMA$, MODEL$); + } + + /** + * Creates a Builder by copying an existing Builder. + * @param other The existing Builder to copy. + */ + private Builder(io.skodjob.datagenerator.models.flights.Passenger.Builder other) { + super(other); + if (isValidValue(fields()[0], other.id)) { + this.id = data().deepCopy(fields()[0].schema(), other.id); + fieldSetFlags()[0] = other.fieldSetFlags()[0]; + } + if (isValidValue(fields()[1], other.name)) { + this.name = data().deepCopy(fields()[1].schema(), other.name); + fieldSetFlags()[1] = other.fieldSetFlags()[1]; + } + if (isValidValue(fields()[2], other.passport_number)) { + this.passport_number = data().deepCopy(fields()[2].schema(), other.passport_number); + fieldSetFlags()[2] = other.fieldSetFlags()[2]; + } + if (isValidValue(fields()[3], other.nationality)) { + this.nationality = data().deepCopy(fields()[3].schema(), other.nationality); + fieldSetFlags()[3] = other.fieldSetFlags()[3]; + } + } + + /** + * Creates a Builder by copying an existing Passenger instance + * @param other The existing instance to copy. + */ + private Builder(io.skodjob.datagenerator.models.flights.Passenger other) { + super(SCHEMA$, MODEL$); + if (isValidValue(fields()[0], other.id)) { + this.id = data().deepCopy(fields()[0].schema(), other.id); + fieldSetFlags()[0] = true; + } + if (isValidValue(fields()[1], other.name)) { + this.name = data().deepCopy(fields()[1].schema(), other.name); + fieldSetFlags()[1] = true; + } + if (isValidValue(fields()[2], other.passport_number)) { + this.passport_number = data().deepCopy(fields()[2].schema(), other.passport_number); + fieldSetFlags()[2] = true; + } + if (isValidValue(fields()[3], other.nationality)) { + this.nationality = data().deepCopy(fields()[3].schema(), other.nationality); + fieldSetFlags()[3] = true; + } + } + + /** + * Gets the value of the 'id' field. + * @return The value. + */ + public java.lang.CharSequence getId() { + return id; + } + + + /** + * Sets the value of the 'id' field. + * @param value The value of 'id'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.flights.Passenger.Builder setId(java.lang.CharSequence value) { + validate(fields()[0], value); + this.id = value; + fieldSetFlags()[0] = true; + return this; + } + + /** + * Checks whether the 'id' field has been set. + * @return True if the 'id' field has been set, false otherwise. + */ + public boolean hasId() { + return fieldSetFlags()[0]; + } + + + /** + * Clears the value of the 'id' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.flights.Passenger.Builder clearId() { + id = null; + fieldSetFlags()[0] = false; + return this; + } + + /** + * Gets the value of the 'name' field. + * @return The value. + */ + public java.lang.CharSequence getName() { + return name; + } + + + /** + * Sets the value of the 'name' field. + * @param value The value of 'name'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.flights.Passenger.Builder setName(java.lang.CharSequence value) { + validate(fields()[1], value); + this.name = value; + fieldSetFlags()[1] = true; + return this; + } + + /** + * Checks whether the 'name' field has been set. + * @return True if the 'name' field has been set, false otherwise. + */ + public boolean hasName() { + return fieldSetFlags()[1]; + } + + + /** + * Clears the value of the 'name' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.flights.Passenger.Builder clearName() { + name = null; + fieldSetFlags()[1] = false; + return this; + } + + /** + * Gets the value of the 'passport_number' field. + * @return The value. + */ + public java.lang.CharSequence getPassportNumber() { + return passport_number; + } + + + /** + * Sets the value of the 'passport_number' field. + * @param value The value of 'passport_number'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.flights.Passenger.Builder setPassportNumber(java.lang.CharSequence value) { + validate(fields()[2], value); + this.passport_number = value; + fieldSetFlags()[2] = true; + return this; + } + + /** + * Checks whether the 'passport_number' field has been set. + * @return True if the 'passport_number' field has been set, false otherwise. + */ + public boolean hasPassportNumber() { + return fieldSetFlags()[2]; + } + + + /** + * Clears the value of the 'passport_number' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.flights.Passenger.Builder clearPassportNumber() { + passport_number = null; + fieldSetFlags()[2] = false; + return this; + } + + /** + * Gets the value of the 'nationality' field. + * @return The value. + */ + public java.lang.CharSequence getNationality() { + return nationality; + } + + + /** + * Sets the value of the 'nationality' field. + * @param value The value of 'nationality'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.flights.Passenger.Builder setNationality(java.lang.CharSequence value) { + validate(fields()[3], value); + this.nationality = value; + fieldSetFlags()[3] = true; + return this; + } + + /** + * Checks whether the 'nationality' field has been set. + * @return True if the 'nationality' field has been set, false otherwise. + */ + public boolean hasNationality() { + return fieldSetFlags()[3]; + } + + + /** + * Clears the value of the 'nationality' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.flights.Passenger.Builder clearNationality() { + nationality = null; + fieldSetFlags()[3] = false; + return this; + } + + @Override + @SuppressWarnings("unchecked") + public Passenger build() { + try { + Passenger record = new Passenger(); + record.id = fieldSetFlags()[0] ? this.id : (java.lang.CharSequence) defaultValue(fields()[0]); + record.name = fieldSetFlags()[1] ? this.name : (java.lang.CharSequence) defaultValue(fields()[1]); + record.passport_number = fieldSetFlags()[2] ? this.passport_number : (java.lang.CharSequence) defaultValue(fields()[2]); + record.nationality = fieldSetFlags()[3] ? this.nationality : (java.lang.CharSequence) defaultValue(fields()[3]); + return record; + } catch (org.apache.avro.AvroMissingFieldException e) { + throw e; + } catch (java.lang.Exception e) { + throw new org.apache.avro.AvroRuntimeException(e); + } + } + } + + @SuppressWarnings("unchecked") + private static final org.apache.avro.io.DatumWriter + WRITER$ = (org.apache.avro.io.DatumWriter)MODEL$.createDatumWriter(SCHEMA$); + + @Override public void writeExternal(java.io.ObjectOutput out) + throws java.io.IOException { + WRITER$.write(this, SpecificData.getEncoder(out)); + } + + @SuppressWarnings("unchecked") + private static final org.apache.avro.io.DatumReader + READER$ = (org.apache.avro.io.DatumReader)MODEL$.createDatumReader(SCHEMA$); + + @Override public void readExternal(java.io.ObjectInput in) + throws java.io.IOException { + READER$.read(this, SpecificData.getDecoder(in)); + } + + @Override protected boolean hasCustomCoders() { return true; } + + @Override public void customEncode(org.apache.avro.io.Encoder out) + throws java.io.IOException + { + out.writeString(this.id); + + out.writeString(this.name); + + out.writeString(this.passport_number); + + out.writeString(this.nationality); + + } + + @Override public void customDecode(org.apache.avro.io.ResolvingDecoder in) + throws java.io.IOException + { + org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff(); + if (fieldOrder == null) { + this.id = in.readString(this.id instanceof Utf8 ? (Utf8)this.id : null); + + this.name = in.readString(this.name instanceof Utf8 ? (Utf8)this.name : null); + + this.passport_number = in.readString(this.passport_number instanceof Utf8 ? (Utf8)this.passport_number : null); + + this.nationality = in.readString(this.nationality instanceof Utf8 ? (Utf8)this.nationality : null); + + } else { + for (int i = 0; i < 4; i++) { + switch (fieldOrder[i].pos()) { + case 0: + this.id = in.readString(this.id instanceof Utf8 ? (Utf8)this.id : null); + break; + + case 1: + this.name = in.readString(this.name instanceof Utf8 ? (Utf8)this.name : null); + break; + + case 2: + this.passport_number = in.readString(this.passport_number instanceof Utf8 ? (Utf8)this.passport_number : null); + break; + + case 3: + this.nationality = in.readString(this.nationality instanceof Utf8 ? (Utf8)this.nationality : null); + break; + + default: + throw new java.io.IOException("Corrupt ResolvingDecoder."); + } + } + } + } +} + + + + + + + + + + diff --git a/src/main/java/io/skodjob/datagenerator/models/iotdevice/Battery.java b/src/main/java/io/skodjob/datagenerator/models/iotdevice/Battery.java new file mode 100644 index 0000000..404eaa5 --- /dev/null +++ b/src/main/java/io/skodjob/datagenerator/models/iotdevice/Battery.java @@ -0,0 +1,398 @@ +/** + * Autogenerated by Avro + * + * DO NOT EDIT DIRECTLY + */ +package io.skodjob.datagenerator.models.iotdevice; + +import org.apache.avro.generic.GenericArray; +import org.apache.avro.specific.SpecificData; +import org.apache.avro.util.Utf8; +import org.apache.avro.message.BinaryMessageEncoder; +import org.apache.avro.message.BinaryMessageDecoder; +import org.apache.avro.message.SchemaStore; + +@org.apache.avro.specific.AvroGenerated +public class Battery extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord { + private static final long serialVersionUID = 4816886687575535407L; + + + public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"Battery\",\"namespace\":\"io.skodjob.datagenerator.models.iotdevice\",\"fields\":[{\"name\":\"value\",\"type\":\"int\"},{\"name\":\"unit\",\"type\":\"string\"}]}"); + public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } + + private static final SpecificData MODEL$ = new SpecificData(); + + private static final BinaryMessageEncoder ENCODER = + new BinaryMessageEncoder<>(MODEL$, SCHEMA$); + + private static final BinaryMessageDecoder DECODER = + new BinaryMessageDecoder<>(MODEL$, SCHEMA$); + + /** + * Return the BinaryMessageEncoder instance used by this class. + * @return the message encoder used by this class + */ + public static BinaryMessageEncoder getEncoder() { + return ENCODER; + } + + /** + * Return the BinaryMessageDecoder instance used by this class. + * @return the message decoder used by this class + */ + public static BinaryMessageDecoder getDecoder() { + return DECODER; + } + + /** + * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}. + * @param resolver a {@link SchemaStore} used to find schemas by fingerprint + * @return a BinaryMessageDecoder instance for this class backed by the given SchemaStore + */ + public static BinaryMessageDecoder createDecoder(SchemaStore resolver) { + return new BinaryMessageDecoder<>(MODEL$, SCHEMA$, resolver); + } + + /** + * Serializes this Battery to a ByteBuffer. + * @return a buffer holding the serialized data for this instance + * @throws java.io.IOException if this instance could not be serialized + */ + public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException { + return ENCODER.encode(this); + } + + /** + * Deserializes a Battery from a ByteBuffer. + * @param b a byte buffer holding serialized data for an instance of this class + * @return a Battery instance decoded from the given buffer + * @throws java.io.IOException if the given bytes could not be deserialized into an instance of this class + */ + public static Battery fromByteBuffer( + java.nio.ByteBuffer b) throws java.io.IOException { + return DECODER.decode(b); + } + + private int value; + private java.lang.CharSequence unit; + + /** + * Default constructor. Note that this does not initialize fields + * to their default values from the schema. If that is desired then + * one should use newBuilder(). + */ + public Battery() {} + + /** + * All-args constructor. + * @param value The new value for value + * @param unit The new value for unit + */ + public Battery(java.lang.Integer value, java.lang.CharSequence unit) { + this.value = value; + this.unit = unit; + } + + @Override + public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; } + + @Override + public org.apache.avro.Schema getSchema() { return SCHEMA$; } + + // Used by DatumWriter. Applications should not call. + @Override + public java.lang.Object get(int field$) { + switch (field$) { + case 0: return value; + case 1: return unit; + default: throw new IndexOutOfBoundsException("Invalid index: " + field$); + } + } + + // Used by DatumReader. Applications should not call. + @Override + @SuppressWarnings(value="unchecked") + public void put(int field$, java.lang.Object value$) { + switch (field$) { + case 0: value = (java.lang.Integer)value$; break; + case 1: unit = (java.lang.CharSequence)value$; break; + default: throw new IndexOutOfBoundsException("Invalid index: " + field$); + } + } + + /** + * Gets the value of the 'value' field. + * @return The value of the 'value' field. + */ + public int getValue() { + return value; + } + + + /** + * Sets the value of the 'value' field. + * @param value the value to set. + */ + public void setValue(int value) { + this.value = value; + } + + /** + * Gets the value of the 'unit' field. + * @return The value of the 'unit' field. + */ + public java.lang.CharSequence getUnit() { + return unit; + } + + + /** + * Sets the value of the 'unit' field. + * @param value the value to set. + */ + public void setUnit(java.lang.CharSequence value) { + this.unit = value; + } + + /** + * Creates a new Battery RecordBuilder. + * @return A new Battery RecordBuilder + */ + public static io.skodjob.datagenerator.models.iotdevice.Battery.Builder newBuilder() { + return new io.skodjob.datagenerator.models.iotdevice.Battery.Builder(); + } + + /** + * Creates a new Battery RecordBuilder by copying an existing Builder. + * @param other The existing builder to copy. + * @return A new Battery RecordBuilder + */ + public static io.skodjob.datagenerator.models.iotdevice.Battery.Builder newBuilder(io.skodjob.datagenerator.models.iotdevice.Battery.Builder other) { + if (other == null) { + return new io.skodjob.datagenerator.models.iotdevice.Battery.Builder(); + } else { + return new io.skodjob.datagenerator.models.iotdevice.Battery.Builder(other); + } + } + + /** + * Creates a new Battery RecordBuilder by copying an existing Battery instance. + * @param other The existing instance to copy. + * @return A new Battery RecordBuilder + */ + public static io.skodjob.datagenerator.models.iotdevice.Battery.Builder newBuilder(io.skodjob.datagenerator.models.iotdevice.Battery other) { + if (other == null) { + return new io.skodjob.datagenerator.models.iotdevice.Battery.Builder(); + } else { + return new io.skodjob.datagenerator.models.iotdevice.Battery.Builder(other); + } + } + + /** + * RecordBuilder for Battery instances. + */ + @org.apache.avro.specific.AvroGenerated + public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase + implements org.apache.avro.data.RecordBuilder { + + private int value; + private java.lang.CharSequence unit; + + /** Creates a new Builder */ + private Builder() { + super(SCHEMA$, MODEL$); + } + + /** + * Creates a Builder by copying an existing Builder. + * @param other The existing Builder to copy. + */ + private Builder(io.skodjob.datagenerator.models.iotdevice.Battery.Builder other) { + super(other); + if (isValidValue(fields()[0], other.value)) { + this.value = data().deepCopy(fields()[0].schema(), other.value); + fieldSetFlags()[0] = other.fieldSetFlags()[0]; + } + if (isValidValue(fields()[1], other.unit)) { + this.unit = data().deepCopy(fields()[1].schema(), other.unit); + fieldSetFlags()[1] = other.fieldSetFlags()[1]; + } + } + + /** + * Creates a Builder by copying an existing Battery instance + * @param other The existing instance to copy. + */ + private Builder(io.skodjob.datagenerator.models.iotdevice.Battery other) { + super(SCHEMA$, MODEL$); + if (isValidValue(fields()[0], other.value)) { + this.value = data().deepCopy(fields()[0].schema(), other.value); + fieldSetFlags()[0] = true; + } + if (isValidValue(fields()[1], other.unit)) { + this.unit = data().deepCopy(fields()[1].schema(), other.unit); + fieldSetFlags()[1] = true; + } + } + + /** + * Gets the value of the 'value' field. + * @return The value. + */ + public int getValue() { + return value; + } + + + /** + * Sets the value of the 'value' field. + * @param value The value of 'value'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.iotdevice.Battery.Builder setValue(int value) { + validate(fields()[0], value); + this.value = value; + fieldSetFlags()[0] = true; + return this; + } + + /** + * Checks whether the 'value' field has been set. + * @return True if the 'value' field has been set, false otherwise. + */ + public boolean hasValue() { + return fieldSetFlags()[0]; + } + + + /** + * Clears the value of the 'value' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.iotdevice.Battery.Builder clearValue() { + fieldSetFlags()[0] = false; + return this; + } + + /** + * Gets the value of the 'unit' field. + * @return The value. + */ + public java.lang.CharSequence getUnit() { + return unit; + } + + + /** + * Sets the value of the 'unit' field. + * @param value The value of 'unit'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.iotdevice.Battery.Builder setUnit(java.lang.CharSequence value) { + validate(fields()[1], value); + this.unit = value; + fieldSetFlags()[1] = true; + return this; + } + + /** + * Checks whether the 'unit' field has been set. + * @return True if the 'unit' field has been set, false otherwise. + */ + public boolean hasUnit() { + return fieldSetFlags()[1]; + } + + + /** + * Clears the value of the 'unit' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.iotdevice.Battery.Builder clearUnit() { + unit = null; + fieldSetFlags()[1] = false; + return this; + } + + @Override + @SuppressWarnings("unchecked") + public Battery build() { + try { + Battery record = new Battery(); + record.value = fieldSetFlags()[0] ? this.value : (java.lang.Integer) defaultValue(fields()[0]); + record.unit = fieldSetFlags()[1] ? this.unit : (java.lang.CharSequence) defaultValue(fields()[1]); + return record; + } catch (org.apache.avro.AvroMissingFieldException e) { + throw e; + } catch (java.lang.Exception e) { + throw new org.apache.avro.AvroRuntimeException(e); + } + } + } + + @SuppressWarnings("unchecked") + private static final org.apache.avro.io.DatumWriter + WRITER$ = (org.apache.avro.io.DatumWriter)MODEL$.createDatumWriter(SCHEMA$); + + @Override public void writeExternal(java.io.ObjectOutput out) + throws java.io.IOException { + WRITER$.write(this, SpecificData.getEncoder(out)); + } + + @SuppressWarnings("unchecked") + private static final org.apache.avro.io.DatumReader + READER$ = (org.apache.avro.io.DatumReader)MODEL$.createDatumReader(SCHEMA$); + + @Override public void readExternal(java.io.ObjectInput in) + throws java.io.IOException { + READER$.read(this, SpecificData.getDecoder(in)); + } + + @Override protected boolean hasCustomCoders() { return true; } + + @Override public void customEncode(org.apache.avro.io.Encoder out) + throws java.io.IOException + { + out.writeInt(this.value); + + out.writeString(this.unit); + + } + + @Override public void customDecode(org.apache.avro.io.ResolvingDecoder in) + throws java.io.IOException + { + org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff(); + if (fieldOrder == null) { + this.value = in.readInt(); + + this.unit = in.readString(this.unit instanceof Utf8 ? (Utf8)this.unit : null); + + } else { + for (int i = 0; i < 2; i++) { + switch (fieldOrder[i].pos()) { + case 0: + this.value = in.readInt(); + break; + + case 1: + this.unit = in.readString(this.unit instanceof Utf8 ? (Utf8)this.unit : null); + break; + + default: + throw new java.io.IOException("Corrupt ResolvingDecoder."); + } + } + } + } +} + + + + + + + + + + diff --git a/src/main/java/io/skodjob/datagenerator/models/iotdevice/ButtonData.java b/src/main/java/io/skodjob/datagenerator/models/iotdevice/ButtonData.java new file mode 100644 index 0000000..3a4ad44 --- /dev/null +++ b/src/main/java/io/skodjob/datagenerator/models/iotdevice/ButtonData.java @@ -0,0 +1,455 @@ +/** + * Autogenerated by Avro + * + * DO NOT EDIT DIRECTLY + */ +package io.skodjob.datagenerator.models.iotdevice; + +import org.apache.avro.generic.GenericArray; +import org.apache.avro.specific.SpecificData; +import org.apache.avro.util.Utf8; +import org.apache.avro.message.BinaryMessageEncoder; +import org.apache.avro.message.BinaryMessageDecoder; +import org.apache.avro.message.SchemaStore; + +@org.apache.avro.specific.AvroGenerated +public class ButtonData extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord { + private static final long serialVersionUID = -6315539208887626138L; + + + public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"ButtonData\",\"namespace\":\"io.skodjob.datagenerator.models.iotdevice\",\"fields\":[{\"name\":\"power\",\"type\":\"string\"},{\"name\":\"battery\",\"type\":{\"type\":\"record\",\"name\":\"Battery\",\"fields\":[{\"name\":\"value\",\"type\":\"int\"},{\"name\":\"unit\",\"type\":\"string\"}]}}]}"); + public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } + + private static final SpecificData MODEL$ = new SpecificData(); + + private static final BinaryMessageEncoder ENCODER = + new BinaryMessageEncoder<>(MODEL$, SCHEMA$); + + private static final BinaryMessageDecoder DECODER = + new BinaryMessageDecoder<>(MODEL$, SCHEMA$); + + /** + * Return the BinaryMessageEncoder instance used by this class. + * @return the message encoder used by this class + */ + public static BinaryMessageEncoder getEncoder() { + return ENCODER; + } + + /** + * Return the BinaryMessageDecoder instance used by this class. + * @return the message decoder used by this class + */ + public static BinaryMessageDecoder getDecoder() { + return DECODER; + } + + /** + * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}. + * @param resolver a {@link SchemaStore} used to find schemas by fingerprint + * @return a BinaryMessageDecoder instance for this class backed by the given SchemaStore + */ + public static BinaryMessageDecoder createDecoder(SchemaStore resolver) { + return new BinaryMessageDecoder<>(MODEL$, SCHEMA$, resolver); + } + + /** + * Serializes this ButtonData to a ByteBuffer. + * @return a buffer holding the serialized data for this instance + * @throws java.io.IOException if this instance could not be serialized + */ + public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException { + return ENCODER.encode(this); + } + + /** + * Deserializes a ButtonData from a ByteBuffer. + * @param b a byte buffer holding serialized data for an instance of this class + * @return a ButtonData instance decoded from the given buffer + * @throws java.io.IOException if the given bytes could not be deserialized into an instance of this class + */ + public static ButtonData fromByteBuffer( + java.nio.ByteBuffer b) throws java.io.IOException { + return DECODER.decode(b); + } + + private java.lang.CharSequence power; + private io.skodjob.datagenerator.models.iotdevice.Battery battery; + + /** + * Default constructor. Note that this does not initialize fields + * to their default values from the schema. If that is desired then + * one should use newBuilder(). + */ + public ButtonData() {} + + /** + * All-args constructor. + * @param power The new value for power + * @param battery The new value for battery + */ + public ButtonData(java.lang.CharSequence power, io.skodjob.datagenerator.models.iotdevice.Battery battery) { + this.power = power; + this.battery = battery; + } + + @Override + public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; } + + @Override + public org.apache.avro.Schema getSchema() { return SCHEMA$; } + + // Used by DatumWriter. Applications should not call. + @Override + public java.lang.Object get(int field$) { + switch (field$) { + case 0: return power; + case 1: return battery; + default: throw new IndexOutOfBoundsException("Invalid index: " + field$); + } + } + + // Used by DatumReader. Applications should not call. + @Override + @SuppressWarnings(value="unchecked") + public void put(int field$, java.lang.Object value$) { + switch (field$) { + case 0: power = (java.lang.CharSequence)value$; break; + case 1: battery = (io.skodjob.datagenerator.models.iotdevice.Battery)value$; break; + default: throw new IndexOutOfBoundsException("Invalid index: " + field$); + } + } + + /** + * Gets the value of the 'power' field. + * @return The value of the 'power' field. + */ + public java.lang.CharSequence getPower() { + return power; + } + + + /** + * Sets the value of the 'power' field. + * @param value the value to set. + */ + public void setPower(java.lang.CharSequence value) { + this.power = value; + } + + /** + * Gets the value of the 'battery' field. + * @return The value of the 'battery' field. + */ + public io.skodjob.datagenerator.models.iotdevice.Battery getBattery() { + return battery; + } + + + /** + * Sets the value of the 'battery' field. + * @param value the value to set. + */ + public void setBattery(io.skodjob.datagenerator.models.iotdevice.Battery value) { + this.battery = value; + } + + /** + * Creates a new ButtonData RecordBuilder. + * @return A new ButtonData RecordBuilder + */ + public static io.skodjob.datagenerator.models.iotdevice.ButtonData.Builder newBuilder() { + return new io.skodjob.datagenerator.models.iotdevice.ButtonData.Builder(); + } + + /** + * Creates a new ButtonData RecordBuilder by copying an existing Builder. + * @param other The existing builder to copy. + * @return A new ButtonData RecordBuilder + */ + public static io.skodjob.datagenerator.models.iotdevice.ButtonData.Builder newBuilder(io.skodjob.datagenerator.models.iotdevice.ButtonData.Builder other) { + if (other == null) { + return new io.skodjob.datagenerator.models.iotdevice.ButtonData.Builder(); + } else { + return new io.skodjob.datagenerator.models.iotdevice.ButtonData.Builder(other); + } + } + + /** + * Creates a new ButtonData RecordBuilder by copying an existing ButtonData instance. + * @param other The existing instance to copy. + * @return A new ButtonData RecordBuilder + */ + public static io.skodjob.datagenerator.models.iotdevice.ButtonData.Builder newBuilder(io.skodjob.datagenerator.models.iotdevice.ButtonData other) { + if (other == null) { + return new io.skodjob.datagenerator.models.iotdevice.ButtonData.Builder(); + } else { + return new io.skodjob.datagenerator.models.iotdevice.ButtonData.Builder(other); + } + } + + /** + * RecordBuilder for ButtonData instances. + */ + @org.apache.avro.specific.AvroGenerated + public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase + implements org.apache.avro.data.RecordBuilder { + + private java.lang.CharSequence power; + private io.skodjob.datagenerator.models.iotdevice.Battery battery; + private io.skodjob.datagenerator.models.iotdevice.Battery.Builder batteryBuilder; + + /** Creates a new Builder */ + private Builder() { + super(SCHEMA$, MODEL$); + } + + /** + * Creates a Builder by copying an existing Builder. + * @param other The existing Builder to copy. + */ + private Builder(io.skodjob.datagenerator.models.iotdevice.ButtonData.Builder other) { + super(other); + if (isValidValue(fields()[0], other.power)) { + this.power = data().deepCopy(fields()[0].schema(), other.power); + fieldSetFlags()[0] = other.fieldSetFlags()[0]; + } + if (isValidValue(fields()[1], other.battery)) { + this.battery = data().deepCopy(fields()[1].schema(), other.battery); + fieldSetFlags()[1] = other.fieldSetFlags()[1]; + } + if (other.hasBatteryBuilder()) { + this.batteryBuilder = io.skodjob.datagenerator.models.iotdevice.Battery.newBuilder(other.getBatteryBuilder()); + } + } + + /** + * Creates a Builder by copying an existing ButtonData instance + * @param other The existing instance to copy. + */ + private Builder(io.skodjob.datagenerator.models.iotdevice.ButtonData other) { + super(SCHEMA$, MODEL$); + if (isValidValue(fields()[0], other.power)) { + this.power = data().deepCopy(fields()[0].schema(), other.power); + fieldSetFlags()[0] = true; + } + if (isValidValue(fields()[1], other.battery)) { + this.battery = data().deepCopy(fields()[1].schema(), other.battery); + fieldSetFlags()[1] = true; + } + this.batteryBuilder = null; + } + + /** + * Gets the value of the 'power' field. + * @return The value. + */ + public java.lang.CharSequence getPower() { + return power; + } + + + /** + * Sets the value of the 'power' field. + * @param value The value of 'power'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.iotdevice.ButtonData.Builder setPower(java.lang.CharSequence value) { + validate(fields()[0], value); + this.power = value; + fieldSetFlags()[0] = true; + return this; + } + + /** + * Checks whether the 'power' field has been set. + * @return True if the 'power' field has been set, false otherwise. + */ + public boolean hasPower() { + return fieldSetFlags()[0]; + } + + + /** + * Clears the value of the 'power' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.iotdevice.ButtonData.Builder clearPower() { + power = null; + fieldSetFlags()[0] = false; + return this; + } + + /** + * Gets the value of the 'battery' field. + * @return The value. + */ + public io.skodjob.datagenerator.models.iotdevice.Battery getBattery() { + return battery; + } + + + /** + * Sets the value of the 'battery' field. + * @param value The value of 'battery'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.iotdevice.ButtonData.Builder setBattery(io.skodjob.datagenerator.models.iotdevice.Battery value) { + validate(fields()[1], value); + this.batteryBuilder = null; + this.battery = value; + fieldSetFlags()[1] = true; + return this; + } + + /** + * Checks whether the 'battery' field has been set. + * @return True if the 'battery' field has been set, false otherwise. + */ + public boolean hasBattery() { + return fieldSetFlags()[1]; + } + + /** + * Gets the Builder instance for the 'battery' field and creates one if it doesn't exist yet. + * @return This builder. + */ + public io.skodjob.datagenerator.models.iotdevice.Battery.Builder getBatteryBuilder() { + if (batteryBuilder == null) { + if (hasBattery()) { + setBatteryBuilder(io.skodjob.datagenerator.models.iotdevice.Battery.newBuilder(battery)); + } else { + setBatteryBuilder(io.skodjob.datagenerator.models.iotdevice.Battery.newBuilder()); + } + } + return batteryBuilder; + } + + /** + * Sets the Builder instance for the 'battery' field + * @param value The builder instance that must be set. + * @return This builder. + */ + + public io.skodjob.datagenerator.models.iotdevice.ButtonData.Builder setBatteryBuilder(io.skodjob.datagenerator.models.iotdevice.Battery.Builder value) { + clearBattery(); + batteryBuilder = value; + return this; + } + + /** + * Checks whether the 'battery' field has an active Builder instance + * @return True if the 'battery' field has an active Builder instance + */ + public boolean hasBatteryBuilder() { + return batteryBuilder != null; + } + + /** + * Clears the value of the 'battery' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.iotdevice.ButtonData.Builder clearBattery() { + battery = null; + batteryBuilder = null; + fieldSetFlags()[1] = false; + return this; + } + + @Override + @SuppressWarnings("unchecked") + public ButtonData build() { + try { + ButtonData record = new ButtonData(); + record.power = fieldSetFlags()[0] ? this.power : (java.lang.CharSequence) defaultValue(fields()[0]); + if (batteryBuilder != null) { + try { + record.battery = this.batteryBuilder.build(); + } catch (org.apache.avro.AvroMissingFieldException e) { + e.addParentField(record.getSchema().getField("battery")); + throw e; + } + } else { + record.battery = fieldSetFlags()[1] ? this.battery : (io.skodjob.datagenerator.models.iotdevice.Battery) defaultValue(fields()[1]); + } + return record; + } catch (org.apache.avro.AvroMissingFieldException e) { + throw e; + } catch (java.lang.Exception e) { + throw new org.apache.avro.AvroRuntimeException(e); + } + } + } + + @SuppressWarnings("unchecked") + private static final org.apache.avro.io.DatumWriter + WRITER$ = (org.apache.avro.io.DatumWriter)MODEL$.createDatumWriter(SCHEMA$); + + @Override public void writeExternal(java.io.ObjectOutput out) + throws java.io.IOException { + WRITER$.write(this, SpecificData.getEncoder(out)); + } + + @SuppressWarnings("unchecked") + private static final org.apache.avro.io.DatumReader + READER$ = (org.apache.avro.io.DatumReader)MODEL$.createDatumReader(SCHEMA$); + + @Override public void readExternal(java.io.ObjectInput in) + throws java.io.IOException { + READER$.read(this, SpecificData.getDecoder(in)); + } + + @Override protected boolean hasCustomCoders() { return true; } + + @Override public void customEncode(org.apache.avro.io.Encoder out) + throws java.io.IOException + { + out.writeString(this.power); + + this.battery.customEncode(out); + + } + + @Override public void customDecode(org.apache.avro.io.ResolvingDecoder in) + throws java.io.IOException + { + org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff(); + if (fieldOrder == null) { + this.power = in.readString(this.power instanceof Utf8 ? (Utf8)this.power : null); + + if (this.battery == null) { + this.battery = new io.skodjob.datagenerator.models.iotdevice.Battery(); + } + this.battery.customDecode(in); + + } else { + for (int i = 0; i < 2; i++) { + switch (fieldOrder[i].pos()) { + case 0: + this.power = in.readString(this.power instanceof Utf8 ? (Utf8)this.power : null); + break; + + case 1: + if (this.battery == null) { + this.battery = new io.skodjob.datagenerator.models.iotdevice.Battery(); + } + this.battery.customDecode(in); + break; + + default: + throw new java.io.IOException("Corrupt ResolvingDecoder."); + } + } + } + } +} + + + + + + + + + + diff --git a/src/main/java/io/skodjob/datagenerator/models/iotdevice/CustomData.java b/src/main/java/io/skodjob/datagenerator/models/iotdevice/CustomData.java new file mode 100644 index 0000000..a453f23 --- /dev/null +++ b/src/main/java/io/skodjob/datagenerator/models/iotdevice/CustomData.java @@ -0,0 +1,399 @@ +/** + * Autogenerated by Avro + * + * DO NOT EDIT DIRECTLY + */ +package io.skodjob.datagenerator.models.iotdevice; + +import org.apache.avro.generic.GenericArray; +import org.apache.avro.specific.SpecificData; +import org.apache.avro.util.Utf8; +import org.apache.avro.message.BinaryMessageEncoder; +import org.apache.avro.message.BinaryMessageDecoder; +import org.apache.avro.message.SchemaStore; + +@org.apache.avro.specific.AvroGenerated +public class CustomData extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord { + private static final long serialVersionUID = 5873049232784909190L; + + + public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"CustomData\",\"namespace\":\"io.skodjob.datagenerator.models.iotdevice\",\"fields\":[{\"name\":\"info\",\"type\":\"string\"},{\"name\":\"state\",\"type\":\"string\"}]}"); + public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } + + private static final SpecificData MODEL$ = new SpecificData(); + + private static final BinaryMessageEncoder ENCODER = + new BinaryMessageEncoder<>(MODEL$, SCHEMA$); + + private static final BinaryMessageDecoder DECODER = + new BinaryMessageDecoder<>(MODEL$, SCHEMA$); + + /** + * Return the BinaryMessageEncoder instance used by this class. + * @return the message encoder used by this class + */ + public static BinaryMessageEncoder getEncoder() { + return ENCODER; + } + + /** + * Return the BinaryMessageDecoder instance used by this class. + * @return the message decoder used by this class + */ + public static BinaryMessageDecoder getDecoder() { + return DECODER; + } + + /** + * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}. + * @param resolver a {@link SchemaStore} used to find schemas by fingerprint + * @return a BinaryMessageDecoder instance for this class backed by the given SchemaStore + */ + public static BinaryMessageDecoder createDecoder(SchemaStore resolver) { + return new BinaryMessageDecoder<>(MODEL$, SCHEMA$, resolver); + } + + /** + * Serializes this CustomData to a ByteBuffer. + * @return a buffer holding the serialized data for this instance + * @throws java.io.IOException if this instance could not be serialized + */ + public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException { + return ENCODER.encode(this); + } + + /** + * Deserializes a CustomData from a ByteBuffer. + * @param b a byte buffer holding serialized data for an instance of this class + * @return a CustomData instance decoded from the given buffer + * @throws java.io.IOException if the given bytes could not be deserialized into an instance of this class + */ + public static CustomData fromByteBuffer( + java.nio.ByteBuffer b) throws java.io.IOException { + return DECODER.decode(b); + } + + private java.lang.CharSequence info; + private java.lang.CharSequence state; + + /** + * Default constructor. Note that this does not initialize fields + * to their default values from the schema. If that is desired then + * one should use newBuilder(). + */ + public CustomData() {} + + /** + * All-args constructor. + * @param info The new value for info + * @param state The new value for state + */ + public CustomData(java.lang.CharSequence info, java.lang.CharSequence state) { + this.info = info; + this.state = state; + } + + @Override + public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; } + + @Override + public org.apache.avro.Schema getSchema() { return SCHEMA$; } + + // Used by DatumWriter. Applications should not call. + @Override + public java.lang.Object get(int field$) { + switch (field$) { + case 0: return info; + case 1: return state; + default: throw new IndexOutOfBoundsException("Invalid index: " + field$); + } + } + + // Used by DatumReader. Applications should not call. + @Override + @SuppressWarnings(value="unchecked") + public void put(int field$, java.lang.Object value$) { + switch (field$) { + case 0: info = (java.lang.CharSequence)value$; break; + case 1: state = (java.lang.CharSequence)value$; break; + default: throw new IndexOutOfBoundsException("Invalid index: " + field$); + } + } + + /** + * Gets the value of the 'info' field. + * @return The value of the 'info' field. + */ + public java.lang.CharSequence getInfo() { + return info; + } + + + /** + * Sets the value of the 'info' field. + * @param value the value to set. + */ + public void setInfo(java.lang.CharSequence value) { + this.info = value; + } + + /** + * Gets the value of the 'state' field. + * @return The value of the 'state' field. + */ + public java.lang.CharSequence getState() { + return state; + } + + + /** + * Sets the value of the 'state' field. + * @param value the value to set. + */ + public void setState(java.lang.CharSequence value) { + this.state = value; + } + + /** + * Creates a new CustomData RecordBuilder. + * @return A new CustomData RecordBuilder + */ + public static io.skodjob.datagenerator.models.iotdevice.CustomData.Builder newBuilder() { + return new io.skodjob.datagenerator.models.iotdevice.CustomData.Builder(); + } + + /** + * Creates a new CustomData RecordBuilder by copying an existing Builder. + * @param other The existing builder to copy. + * @return A new CustomData RecordBuilder + */ + public static io.skodjob.datagenerator.models.iotdevice.CustomData.Builder newBuilder(io.skodjob.datagenerator.models.iotdevice.CustomData.Builder other) { + if (other == null) { + return new io.skodjob.datagenerator.models.iotdevice.CustomData.Builder(); + } else { + return new io.skodjob.datagenerator.models.iotdevice.CustomData.Builder(other); + } + } + + /** + * Creates a new CustomData RecordBuilder by copying an existing CustomData instance. + * @param other The existing instance to copy. + * @return A new CustomData RecordBuilder + */ + public static io.skodjob.datagenerator.models.iotdevice.CustomData.Builder newBuilder(io.skodjob.datagenerator.models.iotdevice.CustomData other) { + if (other == null) { + return new io.skodjob.datagenerator.models.iotdevice.CustomData.Builder(); + } else { + return new io.skodjob.datagenerator.models.iotdevice.CustomData.Builder(other); + } + } + + /** + * RecordBuilder for CustomData instances. + */ + @org.apache.avro.specific.AvroGenerated + public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase + implements org.apache.avro.data.RecordBuilder { + + private java.lang.CharSequence info; + private java.lang.CharSequence state; + + /** Creates a new Builder */ + private Builder() { + super(SCHEMA$, MODEL$); + } + + /** + * Creates a Builder by copying an existing Builder. + * @param other The existing Builder to copy. + */ + private Builder(io.skodjob.datagenerator.models.iotdevice.CustomData.Builder other) { + super(other); + if (isValidValue(fields()[0], other.info)) { + this.info = data().deepCopy(fields()[0].schema(), other.info); + fieldSetFlags()[0] = other.fieldSetFlags()[0]; + } + if (isValidValue(fields()[1], other.state)) { + this.state = data().deepCopy(fields()[1].schema(), other.state); + fieldSetFlags()[1] = other.fieldSetFlags()[1]; + } + } + + /** + * Creates a Builder by copying an existing CustomData instance + * @param other The existing instance to copy. + */ + private Builder(io.skodjob.datagenerator.models.iotdevice.CustomData other) { + super(SCHEMA$, MODEL$); + if (isValidValue(fields()[0], other.info)) { + this.info = data().deepCopy(fields()[0].schema(), other.info); + fieldSetFlags()[0] = true; + } + if (isValidValue(fields()[1], other.state)) { + this.state = data().deepCopy(fields()[1].schema(), other.state); + fieldSetFlags()[1] = true; + } + } + + /** + * Gets the value of the 'info' field. + * @return The value. + */ + public java.lang.CharSequence getInfo() { + return info; + } + + + /** + * Sets the value of the 'info' field. + * @param value The value of 'info'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.iotdevice.CustomData.Builder setInfo(java.lang.CharSequence value) { + validate(fields()[0], value); + this.info = value; + fieldSetFlags()[0] = true; + return this; + } + + /** + * Checks whether the 'info' field has been set. + * @return True if the 'info' field has been set, false otherwise. + */ + public boolean hasInfo() { + return fieldSetFlags()[0]; + } + + + /** + * Clears the value of the 'info' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.iotdevice.CustomData.Builder clearInfo() { + info = null; + fieldSetFlags()[0] = false; + return this; + } + + /** + * Gets the value of the 'state' field. + * @return The value. + */ + public java.lang.CharSequence getState() { + return state; + } + + + /** + * Sets the value of the 'state' field. + * @param value The value of 'state'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.iotdevice.CustomData.Builder setState(java.lang.CharSequence value) { + validate(fields()[1], value); + this.state = value; + fieldSetFlags()[1] = true; + return this; + } + + /** + * Checks whether the 'state' field has been set. + * @return True if the 'state' field has been set, false otherwise. + */ + public boolean hasState() { + return fieldSetFlags()[1]; + } + + + /** + * Clears the value of the 'state' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.iotdevice.CustomData.Builder clearState() { + state = null; + fieldSetFlags()[1] = false; + return this; + } + + @Override + @SuppressWarnings("unchecked") + public CustomData build() { + try { + CustomData record = new CustomData(); + record.info = fieldSetFlags()[0] ? this.info : (java.lang.CharSequence) defaultValue(fields()[0]); + record.state = fieldSetFlags()[1] ? this.state : (java.lang.CharSequence) defaultValue(fields()[1]); + return record; + } catch (org.apache.avro.AvroMissingFieldException e) { + throw e; + } catch (java.lang.Exception e) { + throw new org.apache.avro.AvroRuntimeException(e); + } + } + } + + @SuppressWarnings("unchecked") + private static final org.apache.avro.io.DatumWriter + WRITER$ = (org.apache.avro.io.DatumWriter)MODEL$.createDatumWriter(SCHEMA$); + + @Override public void writeExternal(java.io.ObjectOutput out) + throws java.io.IOException { + WRITER$.write(this, SpecificData.getEncoder(out)); + } + + @SuppressWarnings("unchecked") + private static final org.apache.avro.io.DatumReader + READER$ = (org.apache.avro.io.DatumReader)MODEL$.createDatumReader(SCHEMA$); + + @Override public void readExternal(java.io.ObjectInput in) + throws java.io.IOException { + READER$.read(this, SpecificData.getDecoder(in)); + } + + @Override protected boolean hasCustomCoders() { return true; } + + @Override public void customEncode(org.apache.avro.io.Encoder out) + throws java.io.IOException + { + out.writeString(this.info); + + out.writeString(this.state); + + } + + @Override public void customDecode(org.apache.avro.io.ResolvingDecoder in) + throws java.io.IOException + { + org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff(); + if (fieldOrder == null) { + this.info = in.readString(this.info instanceof Utf8 ? (Utf8)this.info : null); + + this.state = in.readString(this.state instanceof Utf8 ? (Utf8)this.state : null); + + } else { + for (int i = 0; i < 2; i++) { + switch (fieldOrder[i].pos()) { + case 0: + this.info = in.readString(this.info instanceof Utf8 ? (Utf8)this.info : null); + break; + + case 1: + this.state = in.readString(this.state instanceof Utf8 ? (Utf8)this.state : null); + break; + + default: + throw new java.io.IOException("Corrupt ResolvingDecoder."); + } + } + } + } +} + + + + + + + + + + diff --git a/src/main/java/io/skodjob/datagenerator/models/iotdevice/EnergyCurrent.java b/src/main/java/io/skodjob/datagenerator/models/iotdevice/EnergyCurrent.java new file mode 100644 index 0000000..a0839ce --- /dev/null +++ b/src/main/java/io/skodjob/datagenerator/models/iotdevice/EnergyCurrent.java @@ -0,0 +1,398 @@ +/** + * Autogenerated by Avro + * + * DO NOT EDIT DIRECTLY + */ +package io.skodjob.datagenerator.models.iotdevice; + +import org.apache.avro.generic.GenericArray; +import org.apache.avro.specific.SpecificData; +import org.apache.avro.util.Utf8; +import org.apache.avro.message.BinaryMessageEncoder; +import org.apache.avro.message.BinaryMessageDecoder; +import org.apache.avro.message.SchemaStore; + +@org.apache.avro.specific.AvroGenerated +public class EnergyCurrent extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord { + private static final long serialVersionUID = 3815547361048666636L; + + + public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"EnergyCurrent\",\"namespace\":\"io.skodjob.datagenerator.models.iotdevice\",\"fields\":[{\"name\":\"state\",\"type\":\"float\"},{\"name\":\"unit\",\"type\":\"string\"}]}"); + public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } + + private static final SpecificData MODEL$ = new SpecificData(); + + private static final BinaryMessageEncoder ENCODER = + new BinaryMessageEncoder<>(MODEL$, SCHEMA$); + + private static final BinaryMessageDecoder DECODER = + new BinaryMessageDecoder<>(MODEL$, SCHEMA$); + + /** + * Return the BinaryMessageEncoder instance used by this class. + * @return the message encoder used by this class + */ + public static BinaryMessageEncoder getEncoder() { + return ENCODER; + } + + /** + * Return the BinaryMessageDecoder instance used by this class. + * @return the message decoder used by this class + */ + public static BinaryMessageDecoder getDecoder() { + return DECODER; + } + + /** + * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}. + * @param resolver a {@link SchemaStore} used to find schemas by fingerprint + * @return a BinaryMessageDecoder instance for this class backed by the given SchemaStore + */ + public static BinaryMessageDecoder createDecoder(SchemaStore resolver) { + return new BinaryMessageDecoder<>(MODEL$, SCHEMA$, resolver); + } + + /** + * Serializes this EnergyCurrent to a ByteBuffer. + * @return a buffer holding the serialized data for this instance + * @throws java.io.IOException if this instance could not be serialized + */ + public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException { + return ENCODER.encode(this); + } + + /** + * Deserializes a EnergyCurrent from a ByteBuffer. + * @param b a byte buffer holding serialized data for an instance of this class + * @return a EnergyCurrent instance decoded from the given buffer + * @throws java.io.IOException if the given bytes could not be deserialized into an instance of this class + */ + public static EnergyCurrent fromByteBuffer( + java.nio.ByteBuffer b) throws java.io.IOException { + return DECODER.decode(b); + } + + private float state; + private java.lang.CharSequence unit; + + /** + * Default constructor. Note that this does not initialize fields + * to their default values from the schema. If that is desired then + * one should use newBuilder(). + */ + public EnergyCurrent() {} + + /** + * All-args constructor. + * @param state The new value for state + * @param unit The new value for unit + */ + public EnergyCurrent(java.lang.Float state, java.lang.CharSequence unit) { + this.state = state; + this.unit = unit; + } + + @Override + public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; } + + @Override + public org.apache.avro.Schema getSchema() { return SCHEMA$; } + + // Used by DatumWriter. Applications should not call. + @Override + public java.lang.Object get(int field$) { + switch (field$) { + case 0: return state; + case 1: return unit; + default: throw new IndexOutOfBoundsException("Invalid index: " + field$); + } + } + + // Used by DatumReader. Applications should not call. + @Override + @SuppressWarnings(value="unchecked") + public void put(int field$, java.lang.Object value$) { + switch (field$) { + case 0: state = (java.lang.Float)value$; break; + case 1: unit = (java.lang.CharSequence)value$; break; + default: throw new IndexOutOfBoundsException("Invalid index: " + field$); + } + } + + /** + * Gets the value of the 'state' field. + * @return The value of the 'state' field. + */ + public float getState() { + return state; + } + + + /** + * Sets the value of the 'state' field. + * @param value the value to set. + */ + public void setState(float value) { + this.state = value; + } + + /** + * Gets the value of the 'unit' field. + * @return The value of the 'unit' field. + */ + public java.lang.CharSequence getUnit() { + return unit; + } + + + /** + * Sets the value of the 'unit' field. + * @param value the value to set. + */ + public void setUnit(java.lang.CharSequence value) { + this.unit = value; + } + + /** + * Creates a new EnergyCurrent RecordBuilder. + * @return A new EnergyCurrent RecordBuilder + */ + public static io.skodjob.datagenerator.models.iotdevice.EnergyCurrent.Builder newBuilder() { + return new io.skodjob.datagenerator.models.iotdevice.EnergyCurrent.Builder(); + } + + /** + * Creates a new EnergyCurrent RecordBuilder by copying an existing Builder. + * @param other The existing builder to copy. + * @return A new EnergyCurrent RecordBuilder + */ + public static io.skodjob.datagenerator.models.iotdevice.EnergyCurrent.Builder newBuilder(io.skodjob.datagenerator.models.iotdevice.EnergyCurrent.Builder other) { + if (other == null) { + return new io.skodjob.datagenerator.models.iotdevice.EnergyCurrent.Builder(); + } else { + return new io.skodjob.datagenerator.models.iotdevice.EnergyCurrent.Builder(other); + } + } + + /** + * Creates a new EnergyCurrent RecordBuilder by copying an existing EnergyCurrent instance. + * @param other The existing instance to copy. + * @return A new EnergyCurrent RecordBuilder + */ + public static io.skodjob.datagenerator.models.iotdevice.EnergyCurrent.Builder newBuilder(io.skodjob.datagenerator.models.iotdevice.EnergyCurrent other) { + if (other == null) { + return new io.skodjob.datagenerator.models.iotdevice.EnergyCurrent.Builder(); + } else { + return new io.skodjob.datagenerator.models.iotdevice.EnergyCurrent.Builder(other); + } + } + + /** + * RecordBuilder for EnergyCurrent instances. + */ + @org.apache.avro.specific.AvroGenerated + public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase + implements org.apache.avro.data.RecordBuilder { + + private float state; + private java.lang.CharSequence unit; + + /** Creates a new Builder */ + private Builder() { + super(SCHEMA$, MODEL$); + } + + /** + * Creates a Builder by copying an existing Builder. + * @param other The existing Builder to copy. + */ + private Builder(io.skodjob.datagenerator.models.iotdevice.EnergyCurrent.Builder other) { + super(other); + if (isValidValue(fields()[0], other.state)) { + this.state = data().deepCopy(fields()[0].schema(), other.state); + fieldSetFlags()[0] = other.fieldSetFlags()[0]; + } + if (isValidValue(fields()[1], other.unit)) { + this.unit = data().deepCopy(fields()[1].schema(), other.unit); + fieldSetFlags()[1] = other.fieldSetFlags()[1]; + } + } + + /** + * Creates a Builder by copying an existing EnergyCurrent instance + * @param other The existing instance to copy. + */ + private Builder(io.skodjob.datagenerator.models.iotdevice.EnergyCurrent other) { + super(SCHEMA$, MODEL$); + if (isValidValue(fields()[0], other.state)) { + this.state = data().deepCopy(fields()[0].schema(), other.state); + fieldSetFlags()[0] = true; + } + if (isValidValue(fields()[1], other.unit)) { + this.unit = data().deepCopy(fields()[1].schema(), other.unit); + fieldSetFlags()[1] = true; + } + } + + /** + * Gets the value of the 'state' field. + * @return The value. + */ + public float getState() { + return state; + } + + + /** + * Sets the value of the 'state' field. + * @param value The value of 'state'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.iotdevice.EnergyCurrent.Builder setState(float value) { + validate(fields()[0], value); + this.state = value; + fieldSetFlags()[0] = true; + return this; + } + + /** + * Checks whether the 'state' field has been set. + * @return True if the 'state' field has been set, false otherwise. + */ + public boolean hasState() { + return fieldSetFlags()[0]; + } + + + /** + * Clears the value of the 'state' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.iotdevice.EnergyCurrent.Builder clearState() { + fieldSetFlags()[0] = false; + return this; + } + + /** + * Gets the value of the 'unit' field. + * @return The value. + */ + public java.lang.CharSequence getUnit() { + return unit; + } + + + /** + * Sets the value of the 'unit' field. + * @param value The value of 'unit'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.iotdevice.EnergyCurrent.Builder setUnit(java.lang.CharSequence value) { + validate(fields()[1], value); + this.unit = value; + fieldSetFlags()[1] = true; + return this; + } + + /** + * Checks whether the 'unit' field has been set. + * @return True if the 'unit' field has been set, false otherwise. + */ + public boolean hasUnit() { + return fieldSetFlags()[1]; + } + + + /** + * Clears the value of the 'unit' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.iotdevice.EnergyCurrent.Builder clearUnit() { + unit = null; + fieldSetFlags()[1] = false; + return this; + } + + @Override + @SuppressWarnings("unchecked") + public EnergyCurrent build() { + try { + EnergyCurrent record = new EnergyCurrent(); + record.state = fieldSetFlags()[0] ? this.state : (java.lang.Float) defaultValue(fields()[0]); + record.unit = fieldSetFlags()[1] ? this.unit : (java.lang.CharSequence) defaultValue(fields()[1]); + return record; + } catch (org.apache.avro.AvroMissingFieldException e) { + throw e; + } catch (java.lang.Exception e) { + throw new org.apache.avro.AvroRuntimeException(e); + } + } + } + + @SuppressWarnings("unchecked") + private static final org.apache.avro.io.DatumWriter + WRITER$ = (org.apache.avro.io.DatumWriter)MODEL$.createDatumWriter(SCHEMA$); + + @Override public void writeExternal(java.io.ObjectOutput out) + throws java.io.IOException { + WRITER$.write(this, SpecificData.getEncoder(out)); + } + + @SuppressWarnings("unchecked") + private static final org.apache.avro.io.DatumReader + READER$ = (org.apache.avro.io.DatumReader)MODEL$.createDatumReader(SCHEMA$); + + @Override public void readExternal(java.io.ObjectInput in) + throws java.io.IOException { + READER$.read(this, SpecificData.getDecoder(in)); + } + + @Override protected boolean hasCustomCoders() { return true; } + + @Override public void customEncode(org.apache.avro.io.Encoder out) + throws java.io.IOException + { + out.writeFloat(this.state); + + out.writeString(this.unit); + + } + + @Override public void customDecode(org.apache.avro.io.ResolvingDecoder in) + throws java.io.IOException + { + org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff(); + if (fieldOrder == null) { + this.state = in.readFloat(); + + this.unit = in.readString(this.unit instanceof Utf8 ? (Utf8)this.unit : null); + + } else { + for (int i = 0; i < 2; i++) { + switch (fieldOrder[i].pos()) { + case 0: + this.state = in.readFloat(); + break; + + case 1: + this.unit = in.readString(this.unit instanceof Utf8 ? (Utf8)this.unit : null); + break; + + default: + throw new java.io.IOException("Corrupt ResolvingDecoder."); + } + } + } + } +} + + + + + + + + + + diff --git a/src/main/java/io/skodjob/datagenerator/models/iotdevice/EnergyToday.java b/src/main/java/io/skodjob/datagenerator/models/iotdevice/EnergyToday.java new file mode 100644 index 0000000..f4d1955 --- /dev/null +++ b/src/main/java/io/skodjob/datagenerator/models/iotdevice/EnergyToday.java @@ -0,0 +1,398 @@ +/** + * Autogenerated by Avro + * + * DO NOT EDIT DIRECTLY + */ +package io.skodjob.datagenerator.models.iotdevice; + +import org.apache.avro.generic.GenericArray; +import org.apache.avro.specific.SpecificData; +import org.apache.avro.util.Utf8; +import org.apache.avro.message.BinaryMessageEncoder; +import org.apache.avro.message.BinaryMessageDecoder; +import org.apache.avro.message.SchemaStore; + +@org.apache.avro.specific.AvroGenerated +public class EnergyToday extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord { + private static final long serialVersionUID = -3017110563830999034L; + + + public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"EnergyToday\",\"namespace\":\"io.skodjob.datagenerator.models.iotdevice\",\"fields\":[{\"name\":\"state\",\"type\":\"float\"},{\"name\":\"unit\",\"type\":\"string\"}]}"); + public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } + + private static final SpecificData MODEL$ = new SpecificData(); + + private static final BinaryMessageEncoder ENCODER = + new BinaryMessageEncoder<>(MODEL$, SCHEMA$); + + private static final BinaryMessageDecoder DECODER = + new BinaryMessageDecoder<>(MODEL$, SCHEMA$); + + /** + * Return the BinaryMessageEncoder instance used by this class. + * @return the message encoder used by this class + */ + public static BinaryMessageEncoder getEncoder() { + return ENCODER; + } + + /** + * Return the BinaryMessageDecoder instance used by this class. + * @return the message decoder used by this class + */ + public static BinaryMessageDecoder getDecoder() { + return DECODER; + } + + /** + * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}. + * @param resolver a {@link SchemaStore} used to find schemas by fingerprint + * @return a BinaryMessageDecoder instance for this class backed by the given SchemaStore + */ + public static BinaryMessageDecoder createDecoder(SchemaStore resolver) { + return new BinaryMessageDecoder<>(MODEL$, SCHEMA$, resolver); + } + + /** + * Serializes this EnergyToday to a ByteBuffer. + * @return a buffer holding the serialized data for this instance + * @throws java.io.IOException if this instance could not be serialized + */ + public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException { + return ENCODER.encode(this); + } + + /** + * Deserializes a EnergyToday from a ByteBuffer. + * @param b a byte buffer holding serialized data for an instance of this class + * @return a EnergyToday instance decoded from the given buffer + * @throws java.io.IOException if the given bytes could not be deserialized into an instance of this class + */ + public static EnergyToday fromByteBuffer( + java.nio.ByteBuffer b) throws java.io.IOException { + return DECODER.decode(b); + } + + private float state; + private java.lang.CharSequence unit; + + /** + * Default constructor. Note that this does not initialize fields + * to their default values from the schema. If that is desired then + * one should use newBuilder(). + */ + public EnergyToday() {} + + /** + * All-args constructor. + * @param state The new value for state + * @param unit The new value for unit + */ + public EnergyToday(java.lang.Float state, java.lang.CharSequence unit) { + this.state = state; + this.unit = unit; + } + + @Override + public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; } + + @Override + public org.apache.avro.Schema getSchema() { return SCHEMA$; } + + // Used by DatumWriter. Applications should not call. + @Override + public java.lang.Object get(int field$) { + switch (field$) { + case 0: return state; + case 1: return unit; + default: throw new IndexOutOfBoundsException("Invalid index: " + field$); + } + } + + // Used by DatumReader. Applications should not call. + @Override + @SuppressWarnings(value="unchecked") + public void put(int field$, java.lang.Object value$) { + switch (field$) { + case 0: state = (java.lang.Float)value$; break; + case 1: unit = (java.lang.CharSequence)value$; break; + default: throw new IndexOutOfBoundsException("Invalid index: " + field$); + } + } + + /** + * Gets the value of the 'state' field. + * @return The value of the 'state' field. + */ + public float getState() { + return state; + } + + + /** + * Sets the value of the 'state' field. + * @param value the value to set. + */ + public void setState(float value) { + this.state = value; + } + + /** + * Gets the value of the 'unit' field. + * @return The value of the 'unit' field. + */ + public java.lang.CharSequence getUnit() { + return unit; + } + + + /** + * Sets the value of the 'unit' field. + * @param value the value to set. + */ + public void setUnit(java.lang.CharSequence value) { + this.unit = value; + } + + /** + * Creates a new EnergyToday RecordBuilder. + * @return A new EnergyToday RecordBuilder + */ + public static io.skodjob.datagenerator.models.iotdevice.EnergyToday.Builder newBuilder() { + return new io.skodjob.datagenerator.models.iotdevice.EnergyToday.Builder(); + } + + /** + * Creates a new EnergyToday RecordBuilder by copying an existing Builder. + * @param other The existing builder to copy. + * @return A new EnergyToday RecordBuilder + */ + public static io.skodjob.datagenerator.models.iotdevice.EnergyToday.Builder newBuilder(io.skodjob.datagenerator.models.iotdevice.EnergyToday.Builder other) { + if (other == null) { + return new io.skodjob.datagenerator.models.iotdevice.EnergyToday.Builder(); + } else { + return new io.skodjob.datagenerator.models.iotdevice.EnergyToday.Builder(other); + } + } + + /** + * Creates a new EnergyToday RecordBuilder by copying an existing EnergyToday instance. + * @param other The existing instance to copy. + * @return A new EnergyToday RecordBuilder + */ + public static io.skodjob.datagenerator.models.iotdevice.EnergyToday.Builder newBuilder(io.skodjob.datagenerator.models.iotdevice.EnergyToday other) { + if (other == null) { + return new io.skodjob.datagenerator.models.iotdevice.EnergyToday.Builder(); + } else { + return new io.skodjob.datagenerator.models.iotdevice.EnergyToday.Builder(other); + } + } + + /** + * RecordBuilder for EnergyToday instances. + */ + @org.apache.avro.specific.AvroGenerated + public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase + implements org.apache.avro.data.RecordBuilder { + + private float state; + private java.lang.CharSequence unit; + + /** Creates a new Builder */ + private Builder() { + super(SCHEMA$, MODEL$); + } + + /** + * Creates a Builder by copying an existing Builder. + * @param other The existing Builder to copy. + */ + private Builder(io.skodjob.datagenerator.models.iotdevice.EnergyToday.Builder other) { + super(other); + if (isValidValue(fields()[0], other.state)) { + this.state = data().deepCopy(fields()[0].schema(), other.state); + fieldSetFlags()[0] = other.fieldSetFlags()[0]; + } + if (isValidValue(fields()[1], other.unit)) { + this.unit = data().deepCopy(fields()[1].schema(), other.unit); + fieldSetFlags()[1] = other.fieldSetFlags()[1]; + } + } + + /** + * Creates a Builder by copying an existing EnergyToday instance + * @param other The existing instance to copy. + */ + private Builder(io.skodjob.datagenerator.models.iotdevice.EnergyToday other) { + super(SCHEMA$, MODEL$); + if (isValidValue(fields()[0], other.state)) { + this.state = data().deepCopy(fields()[0].schema(), other.state); + fieldSetFlags()[0] = true; + } + if (isValidValue(fields()[1], other.unit)) { + this.unit = data().deepCopy(fields()[1].schema(), other.unit); + fieldSetFlags()[1] = true; + } + } + + /** + * Gets the value of the 'state' field. + * @return The value. + */ + public float getState() { + return state; + } + + + /** + * Sets the value of the 'state' field. + * @param value The value of 'state'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.iotdevice.EnergyToday.Builder setState(float value) { + validate(fields()[0], value); + this.state = value; + fieldSetFlags()[0] = true; + return this; + } + + /** + * Checks whether the 'state' field has been set. + * @return True if the 'state' field has been set, false otherwise. + */ + public boolean hasState() { + return fieldSetFlags()[0]; + } + + + /** + * Clears the value of the 'state' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.iotdevice.EnergyToday.Builder clearState() { + fieldSetFlags()[0] = false; + return this; + } + + /** + * Gets the value of the 'unit' field. + * @return The value. + */ + public java.lang.CharSequence getUnit() { + return unit; + } + + + /** + * Sets the value of the 'unit' field. + * @param value The value of 'unit'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.iotdevice.EnergyToday.Builder setUnit(java.lang.CharSequence value) { + validate(fields()[1], value); + this.unit = value; + fieldSetFlags()[1] = true; + return this; + } + + /** + * Checks whether the 'unit' field has been set. + * @return True if the 'unit' field has been set, false otherwise. + */ + public boolean hasUnit() { + return fieldSetFlags()[1]; + } + + + /** + * Clears the value of the 'unit' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.iotdevice.EnergyToday.Builder clearUnit() { + unit = null; + fieldSetFlags()[1] = false; + return this; + } + + @Override + @SuppressWarnings("unchecked") + public EnergyToday build() { + try { + EnergyToday record = new EnergyToday(); + record.state = fieldSetFlags()[0] ? this.state : (java.lang.Float) defaultValue(fields()[0]); + record.unit = fieldSetFlags()[1] ? this.unit : (java.lang.CharSequence) defaultValue(fields()[1]); + return record; + } catch (org.apache.avro.AvroMissingFieldException e) { + throw e; + } catch (java.lang.Exception e) { + throw new org.apache.avro.AvroRuntimeException(e); + } + } + } + + @SuppressWarnings("unchecked") + private static final org.apache.avro.io.DatumWriter + WRITER$ = (org.apache.avro.io.DatumWriter)MODEL$.createDatumWriter(SCHEMA$); + + @Override public void writeExternal(java.io.ObjectOutput out) + throws java.io.IOException { + WRITER$.write(this, SpecificData.getEncoder(out)); + } + + @SuppressWarnings("unchecked") + private static final org.apache.avro.io.DatumReader + READER$ = (org.apache.avro.io.DatumReader)MODEL$.createDatumReader(SCHEMA$); + + @Override public void readExternal(java.io.ObjectInput in) + throws java.io.IOException { + READER$.read(this, SpecificData.getDecoder(in)); + } + + @Override protected boolean hasCustomCoders() { return true; } + + @Override public void customEncode(org.apache.avro.io.Encoder out) + throws java.io.IOException + { + out.writeFloat(this.state); + + out.writeString(this.unit); + + } + + @Override public void customDecode(org.apache.avro.io.ResolvingDecoder in) + throws java.io.IOException + { + org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff(); + if (fieldOrder == null) { + this.state = in.readFloat(); + + this.unit = in.readString(this.unit instanceof Utf8 ? (Utf8)this.unit : null); + + } else { + for (int i = 0; i < 2; i++) { + switch (fieldOrder[i].pos()) { + case 0: + this.state = in.readFloat(); + break; + + case 1: + this.unit = in.readString(this.unit instanceof Utf8 ? (Utf8)this.unit : null); + break; + + default: + throw new java.io.IOException("Corrupt ResolvingDecoder."); + } + } + } + } +} + + + + + + + + + + diff --git a/src/main/java/io/skodjob/datagenerator/models/iotdevice/GateData.java b/src/main/java/io/skodjob/datagenerator/models/iotdevice/GateData.java new file mode 100644 index 0000000..a946eae --- /dev/null +++ b/src/main/java/io/skodjob/datagenerator/models/iotdevice/GateData.java @@ -0,0 +1,399 @@ +/** + * Autogenerated by Avro + * + * DO NOT EDIT DIRECTLY + */ +package io.skodjob.datagenerator.models.iotdevice; + +import org.apache.avro.generic.GenericArray; +import org.apache.avro.specific.SpecificData; +import org.apache.avro.util.Utf8; +import org.apache.avro.message.BinaryMessageEncoder; +import org.apache.avro.message.BinaryMessageDecoder; +import org.apache.avro.message.SchemaStore; + +@org.apache.avro.specific.AvroGenerated +public class GateData extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord { + private static final long serialVersionUID = -8051302576023405526L; + + + public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"GateData\",\"namespace\":\"io.skodjob.datagenerator.models.iotdevice\",\"fields\":[{\"name\":\"vendor\",\"type\":\"string\"},{\"name\":\"state\",\"type\":\"string\"}]}"); + public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } + + private static final SpecificData MODEL$ = new SpecificData(); + + private static final BinaryMessageEncoder ENCODER = + new BinaryMessageEncoder<>(MODEL$, SCHEMA$); + + private static final BinaryMessageDecoder DECODER = + new BinaryMessageDecoder<>(MODEL$, SCHEMA$); + + /** + * Return the BinaryMessageEncoder instance used by this class. + * @return the message encoder used by this class + */ + public static BinaryMessageEncoder getEncoder() { + return ENCODER; + } + + /** + * Return the BinaryMessageDecoder instance used by this class. + * @return the message decoder used by this class + */ + public static BinaryMessageDecoder getDecoder() { + return DECODER; + } + + /** + * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}. + * @param resolver a {@link SchemaStore} used to find schemas by fingerprint + * @return a BinaryMessageDecoder instance for this class backed by the given SchemaStore + */ + public static BinaryMessageDecoder createDecoder(SchemaStore resolver) { + return new BinaryMessageDecoder<>(MODEL$, SCHEMA$, resolver); + } + + /** + * Serializes this GateData to a ByteBuffer. + * @return a buffer holding the serialized data for this instance + * @throws java.io.IOException if this instance could not be serialized + */ + public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException { + return ENCODER.encode(this); + } + + /** + * Deserializes a GateData from a ByteBuffer. + * @param b a byte buffer holding serialized data for an instance of this class + * @return a GateData instance decoded from the given buffer + * @throws java.io.IOException if the given bytes could not be deserialized into an instance of this class + */ + public static GateData fromByteBuffer( + java.nio.ByteBuffer b) throws java.io.IOException { + return DECODER.decode(b); + } + + private java.lang.CharSequence vendor; + private java.lang.CharSequence state; + + /** + * Default constructor. Note that this does not initialize fields + * to their default values from the schema. If that is desired then + * one should use newBuilder(). + */ + public GateData() {} + + /** + * All-args constructor. + * @param vendor The new value for vendor + * @param state The new value for state + */ + public GateData(java.lang.CharSequence vendor, java.lang.CharSequence state) { + this.vendor = vendor; + this.state = state; + } + + @Override + public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; } + + @Override + public org.apache.avro.Schema getSchema() { return SCHEMA$; } + + // Used by DatumWriter. Applications should not call. + @Override + public java.lang.Object get(int field$) { + switch (field$) { + case 0: return vendor; + case 1: return state; + default: throw new IndexOutOfBoundsException("Invalid index: " + field$); + } + } + + // Used by DatumReader. Applications should not call. + @Override + @SuppressWarnings(value="unchecked") + public void put(int field$, java.lang.Object value$) { + switch (field$) { + case 0: vendor = (java.lang.CharSequence)value$; break; + case 1: state = (java.lang.CharSequence)value$; break; + default: throw new IndexOutOfBoundsException("Invalid index: " + field$); + } + } + + /** + * Gets the value of the 'vendor' field. + * @return The value of the 'vendor' field. + */ + public java.lang.CharSequence getVendor() { + return vendor; + } + + + /** + * Sets the value of the 'vendor' field. + * @param value the value to set. + */ + public void setVendor(java.lang.CharSequence value) { + this.vendor = value; + } + + /** + * Gets the value of the 'state' field. + * @return The value of the 'state' field. + */ + public java.lang.CharSequence getState() { + return state; + } + + + /** + * Sets the value of the 'state' field. + * @param value the value to set. + */ + public void setState(java.lang.CharSequence value) { + this.state = value; + } + + /** + * Creates a new GateData RecordBuilder. + * @return A new GateData RecordBuilder + */ + public static io.skodjob.datagenerator.models.iotdevice.GateData.Builder newBuilder() { + return new io.skodjob.datagenerator.models.iotdevice.GateData.Builder(); + } + + /** + * Creates a new GateData RecordBuilder by copying an existing Builder. + * @param other The existing builder to copy. + * @return A new GateData RecordBuilder + */ + public static io.skodjob.datagenerator.models.iotdevice.GateData.Builder newBuilder(io.skodjob.datagenerator.models.iotdevice.GateData.Builder other) { + if (other == null) { + return new io.skodjob.datagenerator.models.iotdevice.GateData.Builder(); + } else { + return new io.skodjob.datagenerator.models.iotdevice.GateData.Builder(other); + } + } + + /** + * Creates a new GateData RecordBuilder by copying an existing GateData instance. + * @param other The existing instance to copy. + * @return A new GateData RecordBuilder + */ + public static io.skodjob.datagenerator.models.iotdevice.GateData.Builder newBuilder(io.skodjob.datagenerator.models.iotdevice.GateData other) { + if (other == null) { + return new io.skodjob.datagenerator.models.iotdevice.GateData.Builder(); + } else { + return new io.skodjob.datagenerator.models.iotdevice.GateData.Builder(other); + } + } + + /** + * RecordBuilder for GateData instances. + */ + @org.apache.avro.specific.AvroGenerated + public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase + implements org.apache.avro.data.RecordBuilder { + + private java.lang.CharSequence vendor; + private java.lang.CharSequence state; + + /** Creates a new Builder */ + private Builder() { + super(SCHEMA$, MODEL$); + } + + /** + * Creates a Builder by copying an existing Builder. + * @param other The existing Builder to copy. + */ + private Builder(io.skodjob.datagenerator.models.iotdevice.GateData.Builder other) { + super(other); + if (isValidValue(fields()[0], other.vendor)) { + this.vendor = data().deepCopy(fields()[0].schema(), other.vendor); + fieldSetFlags()[0] = other.fieldSetFlags()[0]; + } + if (isValidValue(fields()[1], other.state)) { + this.state = data().deepCopy(fields()[1].schema(), other.state); + fieldSetFlags()[1] = other.fieldSetFlags()[1]; + } + } + + /** + * Creates a Builder by copying an existing GateData instance + * @param other The existing instance to copy. + */ + private Builder(io.skodjob.datagenerator.models.iotdevice.GateData other) { + super(SCHEMA$, MODEL$); + if (isValidValue(fields()[0], other.vendor)) { + this.vendor = data().deepCopy(fields()[0].schema(), other.vendor); + fieldSetFlags()[0] = true; + } + if (isValidValue(fields()[1], other.state)) { + this.state = data().deepCopy(fields()[1].schema(), other.state); + fieldSetFlags()[1] = true; + } + } + + /** + * Gets the value of the 'vendor' field. + * @return The value. + */ + public java.lang.CharSequence getVendor() { + return vendor; + } + + + /** + * Sets the value of the 'vendor' field. + * @param value The value of 'vendor'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.iotdevice.GateData.Builder setVendor(java.lang.CharSequence value) { + validate(fields()[0], value); + this.vendor = value; + fieldSetFlags()[0] = true; + return this; + } + + /** + * Checks whether the 'vendor' field has been set. + * @return True if the 'vendor' field has been set, false otherwise. + */ + public boolean hasVendor() { + return fieldSetFlags()[0]; + } + + + /** + * Clears the value of the 'vendor' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.iotdevice.GateData.Builder clearVendor() { + vendor = null; + fieldSetFlags()[0] = false; + return this; + } + + /** + * Gets the value of the 'state' field. + * @return The value. + */ + public java.lang.CharSequence getState() { + return state; + } + + + /** + * Sets the value of the 'state' field. + * @param value The value of 'state'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.iotdevice.GateData.Builder setState(java.lang.CharSequence value) { + validate(fields()[1], value); + this.state = value; + fieldSetFlags()[1] = true; + return this; + } + + /** + * Checks whether the 'state' field has been set. + * @return True if the 'state' field has been set, false otherwise. + */ + public boolean hasState() { + return fieldSetFlags()[1]; + } + + + /** + * Clears the value of the 'state' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.iotdevice.GateData.Builder clearState() { + state = null; + fieldSetFlags()[1] = false; + return this; + } + + @Override + @SuppressWarnings("unchecked") + public GateData build() { + try { + GateData record = new GateData(); + record.vendor = fieldSetFlags()[0] ? this.vendor : (java.lang.CharSequence) defaultValue(fields()[0]); + record.state = fieldSetFlags()[1] ? this.state : (java.lang.CharSequence) defaultValue(fields()[1]); + return record; + } catch (org.apache.avro.AvroMissingFieldException e) { + throw e; + } catch (java.lang.Exception e) { + throw new org.apache.avro.AvroRuntimeException(e); + } + } + } + + @SuppressWarnings("unchecked") + private static final org.apache.avro.io.DatumWriter + WRITER$ = (org.apache.avro.io.DatumWriter)MODEL$.createDatumWriter(SCHEMA$); + + @Override public void writeExternal(java.io.ObjectOutput out) + throws java.io.IOException { + WRITER$.write(this, SpecificData.getEncoder(out)); + } + + @SuppressWarnings("unchecked") + private static final org.apache.avro.io.DatumReader + READER$ = (org.apache.avro.io.DatumReader)MODEL$.createDatumReader(SCHEMA$); + + @Override public void readExternal(java.io.ObjectInput in) + throws java.io.IOException { + READER$.read(this, SpecificData.getDecoder(in)); + } + + @Override protected boolean hasCustomCoders() { return true; } + + @Override public void customEncode(org.apache.avro.io.Encoder out) + throws java.io.IOException + { + out.writeString(this.vendor); + + out.writeString(this.state); + + } + + @Override public void customDecode(org.apache.avro.io.ResolvingDecoder in) + throws java.io.IOException + { + org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff(); + if (fieldOrder == null) { + this.vendor = in.readString(this.vendor instanceof Utf8 ? (Utf8)this.vendor : null); + + this.state = in.readString(this.state instanceof Utf8 ? (Utf8)this.state : null); + + } else { + for (int i = 0; i < 2; i++) { + switch (fieldOrder[i].pos()) { + case 0: + this.vendor = in.readString(this.vendor instanceof Utf8 ? (Utf8)this.vendor : null); + break; + + case 1: + this.state = in.readString(this.state instanceof Utf8 ? (Utf8)this.state : null); + break; + + default: + throw new java.io.IOException("Corrupt ResolvingDecoder."); + } + } + } + } +} + + + + + + + + + + diff --git a/src/main/java/io/skodjob/datagenerator/models/iotdevice/IotDevice.java b/src/main/java/io/skodjob/datagenerator/models/iotdevice/IotDevice.java new file mode 100644 index 0000000..c4e5be2 --- /dev/null +++ b/src/main/java/io/skodjob/datagenerator/models/iotdevice/IotDevice.java @@ -0,0 +1,721 @@ +/** + * Autogenerated by Avro + * + * DO NOT EDIT DIRECTLY + */ +package io.skodjob.datagenerator.models.iotdevice; + +import org.apache.avro.generic.GenericArray; +import org.apache.avro.specific.SpecificData; +import org.apache.avro.util.Utf8; +import org.apache.avro.message.BinaryMessageEncoder; +import org.apache.avro.message.BinaryMessageDecoder; +import org.apache.avro.message.SchemaStore; + +@org.apache.avro.specific.AvroGenerated +public class IotDevice extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord { + private static final long serialVersionUID = -6035530976238410191L; + + + public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"IotDevice\",\"namespace\":\"io.skodjob.datagenerator.models.iotdevice\",\"fields\":[{\"name\":\"IPV4\",\"type\":\"string\"},{\"name\":\"MAC\",\"type\":\"string\"},{\"name\":\"ID\",\"type\":\"string\"},{\"name\":\"TYPE\",\"type\":\"string\"},{\"name\":\"LAST_UPDATE\",\"type\":\"string\"},{\"name\":\"LINK_QUALITY\",\"type\":\"int\"},{\"name\":\"DATA\",\"type\":[{\"type\":\"record\",\"name\":\"CustomData\",\"fields\":[{\"name\":\"info\",\"type\":\"string\"},{\"name\":\"state\",\"type\":\"string\"}]},{\"type\":\"record\",\"name\":\"ButtonData\",\"fields\":[{\"name\":\"power\",\"type\":\"string\"},{\"name\":\"battery\",\"type\":{\"type\":\"record\",\"name\":\"Battery\",\"fields\":[{\"name\":\"value\",\"type\":\"int\"},{\"name\":\"unit\",\"type\":\"string\"}]}}]},{\"type\":\"record\",\"name\":\"PlugData\",\"fields\":[{\"name\":\"power\",\"type\":\"string\"},{\"name\":\"energy_current\",\"type\":{\"type\":\"record\",\"name\":\"EnergyCurrent\",\"fields\":[{\"name\":\"state\",\"type\":\"float\"},{\"name\":\"unit\",\"type\":\"string\"}]}},{\"name\":\"energy_today\",\"type\":{\"type\":\"record\",\"name\":\"EnergyToday\",\"fields\":[{\"name\":\"state\",\"type\":\"float\"},{\"name\":\"unit\",\"type\":\"string\"}]}}]},{\"type\":\"record\",\"name\":\"ThermometerData\",\"fields\":[{\"name\":\"temperature\",\"type\":\"float\"},{\"name\":\"humidity\",\"type\":\"float\"},{\"name\":\"battery\",\"type\":\"Battery\"}]},{\"type\":\"record\",\"name\":\"GateData\",\"fields\":[{\"name\":\"vendor\",\"type\":\"string\"},{\"name\":\"state\",\"type\":\"string\"}]},{\"type\":\"record\",\"name\":\"LightData\",\"fields\":[{\"name\":\"power\",\"type\":\"string\"},{\"name\":\"brightness\",\"type\":\"int\"},{\"name\":\"power_on_behavior\",\"type\":\"string\"}]}]}]}"); + public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } + + private static final SpecificData MODEL$ = new SpecificData(); + + private static final BinaryMessageEncoder ENCODER = + new BinaryMessageEncoder<>(MODEL$, SCHEMA$); + + private static final BinaryMessageDecoder DECODER = + new BinaryMessageDecoder<>(MODEL$, SCHEMA$); + + /** + * Return the BinaryMessageEncoder instance used by this class. + * @return the message encoder used by this class + */ + public static BinaryMessageEncoder getEncoder() { + return ENCODER; + } + + /** + * Return the BinaryMessageDecoder instance used by this class. + * @return the message decoder used by this class + */ + public static BinaryMessageDecoder getDecoder() { + return DECODER; + } + + /** + * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}. + * @param resolver a {@link SchemaStore} used to find schemas by fingerprint + * @return a BinaryMessageDecoder instance for this class backed by the given SchemaStore + */ + public static BinaryMessageDecoder createDecoder(SchemaStore resolver) { + return new BinaryMessageDecoder<>(MODEL$, SCHEMA$, resolver); + } + + /** + * Serializes this IotDevice to a ByteBuffer. + * @return a buffer holding the serialized data for this instance + * @throws java.io.IOException if this instance could not be serialized + */ + public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException { + return ENCODER.encode(this); + } + + /** + * Deserializes a IotDevice from a ByteBuffer. + * @param b a byte buffer holding serialized data for an instance of this class + * @return a IotDevice instance decoded from the given buffer + * @throws java.io.IOException if the given bytes could not be deserialized into an instance of this class + */ + public static IotDevice fromByteBuffer( + java.nio.ByteBuffer b) throws java.io.IOException { + return DECODER.decode(b); + } + + private java.lang.CharSequence IPV4; + private java.lang.CharSequence MAC; + private java.lang.CharSequence ID; + private java.lang.CharSequence TYPE; + private java.lang.CharSequence LAST_UPDATE; + private int LINK_QUALITY; + private java.lang.Object DATA; + + /** + * Default constructor. Note that this does not initialize fields + * to their default values from the schema. If that is desired then + * one should use newBuilder(). + */ + public IotDevice() {} + + /** + * All-args constructor. + * @param IPV4 The new value for IPV4 + * @param MAC The new value for MAC + * @param ID The new value for ID + * @param TYPE The new value for TYPE + * @param LAST_UPDATE The new value for LAST_UPDATE + * @param LINK_QUALITY The new value for LINK_QUALITY + * @param DATA The new value for DATA + */ + public IotDevice(java.lang.CharSequence IPV4, java.lang.CharSequence MAC, java.lang.CharSequence ID, java.lang.CharSequence TYPE, java.lang.CharSequence LAST_UPDATE, java.lang.Integer LINK_QUALITY, java.lang.Object DATA) { + this.IPV4 = IPV4; + this.MAC = MAC; + this.ID = ID; + this.TYPE = TYPE; + this.LAST_UPDATE = LAST_UPDATE; + this.LINK_QUALITY = LINK_QUALITY; + this.DATA = DATA; + } + + @Override + public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; } + + @Override + public org.apache.avro.Schema getSchema() { return SCHEMA$; } + + // Used by DatumWriter. Applications should not call. + @Override + public java.lang.Object get(int field$) { + switch (field$) { + case 0: return IPV4; + case 1: return MAC; + case 2: return ID; + case 3: return TYPE; + case 4: return LAST_UPDATE; + case 5: return LINK_QUALITY; + case 6: return DATA; + default: throw new IndexOutOfBoundsException("Invalid index: " + field$); + } + } + + // Used by DatumReader. Applications should not call. + @Override + @SuppressWarnings(value="unchecked") + public void put(int field$, java.lang.Object value$) { + switch (field$) { + case 0: IPV4 = (java.lang.CharSequence)value$; break; + case 1: MAC = (java.lang.CharSequence)value$; break; + case 2: ID = (java.lang.CharSequence)value$; break; + case 3: TYPE = (java.lang.CharSequence)value$; break; + case 4: LAST_UPDATE = (java.lang.CharSequence)value$; break; + case 5: LINK_QUALITY = (java.lang.Integer)value$; break; + case 6: DATA = value$; break; + default: throw new IndexOutOfBoundsException("Invalid index: " + field$); + } + } + + /** + * Gets the value of the 'IPV4' field. + * @return The value of the 'IPV4' field. + */ + public java.lang.CharSequence getIPV4() { + return IPV4; + } + + + /** + * Sets the value of the 'IPV4' field. + * @param value the value to set. + */ + public void setIPV4(java.lang.CharSequence value) { + this.IPV4 = value; + } + + /** + * Gets the value of the 'MAC' field. + * @return The value of the 'MAC' field. + */ + public java.lang.CharSequence getMAC() { + return MAC; + } + + + /** + * Sets the value of the 'MAC' field. + * @param value the value to set. + */ + public void setMAC(java.lang.CharSequence value) { + this.MAC = value; + } + + /** + * Gets the value of the 'ID' field. + * @return The value of the 'ID' field. + */ + public java.lang.CharSequence getID() { + return ID; + } + + + /** + * Sets the value of the 'ID' field. + * @param value the value to set. + */ + public void setID(java.lang.CharSequence value) { + this.ID = value; + } + + /** + * Gets the value of the 'TYPE' field. + * @return The value of the 'TYPE' field. + */ + public java.lang.CharSequence getTYPE() { + return TYPE; + } + + + /** + * Sets the value of the 'TYPE' field. + * @param value the value to set. + */ + public void setTYPE(java.lang.CharSequence value) { + this.TYPE = value; + } + + /** + * Gets the value of the 'LAST_UPDATE' field. + * @return The value of the 'LAST_UPDATE' field. + */ + public java.lang.CharSequence getLASTUPDATE() { + return LAST_UPDATE; + } + + + /** + * Sets the value of the 'LAST_UPDATE' field. + * @param value the value to set. + */ + public void setLASTUPDATE(java.lang.CharSequence value) { + this.LAST_UPDATE = value; + } + + /** + * Gets the value of the 'LINK_QUALITY' field. + * @return The value of the 'LINK_QUALITY' field. + */ + public int getLINKQUALITY() { + return LINK_QUALITY; + } + + + /** + * Sets the value of the 'LINK_QUALITY' field. + * @param value the value to set. + */ + public void setLINKQUALITY(int value) { + this.LINK_QUALITY = value; + } + + /** + * Gets the value of the 'DATA' field. + * @return The value of the 'DATA' field. + */ + public java.lang.Object getDATA() { + return DATA; + } + + + /** + * Sets the value of the 'DATA' field. + * @param value the value to set. + */ + public void setDATA(java.lang.Object value) { + this.DATA = value; + } + + /** + * Creates a new IotDevice RecordBuilder. + * @return A new IotDevice RecordBuilder + */ + public static io.skodjob.datagenerator.models.iotdevice.IotDevice.Builder newBuilder() { + return new io.skodjob.datagenerator.models.iotdevice.IotDevice.Builder(); + } + + /** + * Creates a new IotDevice RecordBuilder by copying an existing Builder. + * @param other The existing builder to copy. + * @return A new IotDevice RecordBuilder + */ + public static io.skodjob.datagenerator.models.iotdevice.IotDevice.Builder newBuilder(io.skodjob.datagenerator.models.iotdevice.IotDevice.Builder other) { + if (other == null) { + return new io.skodjob.datagenerator.models.iotdevice.IotDevice.Builder(); + } else { + return new io.skodjob.datagenerator.models.iotdevice.IotDevice.Builder(other); + } + } + + /** + * Creates a new IotDevice RecordBuilder by copying an existing IotDevice instance. + * @param other The existing instance to copy. + * @return A new IotDevice RecordBuilder + */ + public static io.skodjob.datagenerator.models.iotdevice.IotDevice.Builder newBuilder(io.skodjob.datagenerator.models.iotdevice.IotDevice other) { + if (other == null) { + return new io.skodjob.datagenerator.models.iotdevice.IotDevice.Builder(); + } else { + return new io.skodjob.datagenerator.models.iotdevice.IotDevice.Builder(other); + } + } + + /** + * RecordBuilder for IotDevice instances. + */ + @org.apache.avro.specific.AvroGenerated + public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase + implements org.apache.avro.data.RecordBuilder { + + private java.lang.CharSequence IPV4; + private java.lang.CharSequence MAC; + private java.lang.CharSequence ID; + private java.lang.CharSequence TYPE; + private java.lang.CharSequence LAST_UPDATE; + private int LINK_QUALITY; + private java.lang.Object DATA; + + /** Creates a new Builder */ + private Builder() { + super(SCHEMA$, MODEL$); + } + + /** + * Creates a Builder by copying an existing Builder. + * @param other The existing Builder to copy. + */ + private Builder(io.skodjob.datagenerator.models.iotdevice.IotDevice.Builder other) { + super(other); + if (isValidValue(fields()[0], other.IPV4)) { + this.IPV4 = data().deepCopy(fields()[0].schema(), other.IPV4); + fieldSetFlags()[0] = other.fieldSetFlags()[0]; + } + if (isValidValue(fields()[1], other.MAC)) { + this.MAC = data().deepCopy(fields()[1].schema(), other.MAC); + fieldSetFlags()[1] = other.fieldSetFlags()[1]; + } + if (isValidValue(fields()[2], other.ID)) { + this.ID = data().deepCopy(fields()[2].schema(), other.ID); + fieldSetFlags()[2] = other.fieldSetFlags()[2]; + } + if (isValidValue(fields()[3], other.TYPE)) { + this.TYPE = data().deepCopy(fields()[3].schema(), other.TYPE); + fieldSetFlags()[3] = other.fieldSetFlags()[3]; + } + if (isValidValue(fields()[4], other.LAST_UPDATE)) { + this.LAST_UPDATE = data().deepCopy(fields()[4].schema(), other.LAST_UPDATE); + fieldSetFlags()[4] = other.fieldSetFlags()[4]; + } + if (isValidValue(fields()[5], other.LINK_QUALITY)) { + this.LINK_QUALITY = data().deepCopy(fields()[5].schema(), other.LINK_QUALITY); + fieldSetFlags()[5] = other.fieldSetFlags()[5]; + } + if (isValidValue(fields()[6], other.DATA)) { + this.DATA = data().deepCopy(fields()[6].schema(), other.DATA); + fieldSetFlags()[6] = other.fieldSetFlags()[6]; + } + } + + /** + * Creates a Builder by copying an existing IotDevice instance + * @param other The existing instance to copy. + */ + private Builder(io.skodjob.datagenerator.models.iotdevice.IotDevice other) { + super(SCHEMA$, MODEL$); + if (isValidValue(fields()[0], other.IPV4)) { + this.IPV4 = data().deepCopy(fields()[0].schema(), other.IPV4); + fieldSetFlags()[0] = true; + } + if (isValidValue(fields()[1], other.MAC)) { + this.MAC = data().deepCopy(fields()[1].schema(), other.MAC); + fieldSetFlags()[1] = true; + } + if (isValidValue(fields()[2], other.ID)) { + this.ID = data().deepCopy(fields()[2].schema(), other.ID); + fieldSetFlags()[2] = true; + } + if (isValidValue(fields()[3], other.TYPE)) { + this.TYPE = data().deepCopy(fields()[3].schema(), other.TYPE); + fieldSetFlags()[3] = true; + } + if (isValidValue(fields()[4], other.LAST_UPDATE)) { + this.LAST_UPDATE = data().deepCopy(fields()[4].schema(), other.LAST_UPDATE); + fieldSetFlags()[4] = true; + } + if (isValidValue(fields()[5], other.LINK_QUALITY)) { + this.LINK_QUALITY = data().deepCopy(fields()[5].schema(), other.LINK_QUALITY); + fieldSetFlags()[5] = true; + } + if (isValidValue(fields()[6], other.DATA)) { + this.DATA = data().deepCopy(fields()[6].schema(), other.DATA); + fieldSetFlags()[6] = true; + } + } + + /** + * Gets the value of the 'IPV4' field. + * @return The value. + */ + public java.lang.CharSequence getIPV4() { + return IPV4; + } + + + /** + * Sets the value of the 'IPV4' field. + * @param value The value of 'IPV4'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.iotdevice.IotDevice.Builder setIPV4(java.lang.CharSequence value) { + validate(fields()[0], value); + this.IPV4 = value; + fieldSetFlags()[0] = true; + return this; + } + + /** + * Checks whether the 'IPV4' field has been set. + * @return True if the 'IPV4' field has been set, false otherwise. + */ + public boolean hasIPV4() { + return fieldSetFlags()[0]; + } + + + /** + * Clears the value of the 'IPV4' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.iotdevice.IotDevice.Builder clearIPV4() { + IPV4 = null; + fieldSetFlags()[0] = false; + return this; + } + + /** + * Gets the value of the 'MAC' field. + * @return The value. + */ + public java.lang.CharSequence getMAC() { + return MAC; + } + + + /** + * Sets the value of the 'MAC' field. + * @param value The value of 'MAC'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.iotdevice.IotDevice.Builder setMAC(java.lang.CharSequence value) { + validate(fields()[1], value); + this.MAC = value; + fieldSetFlags()[1] = true; + return this; + } + + /** + * Checks whether the 'MAC' field has been set. + * @return True if the 'MAC' field has been set, false otherwise. + */ + public boolean hasMAC() { + return fieldSetFlags()[1]; + } + + + /** + * Clears the value of the 'MAC' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.iotdevice.IotDevice.Builder clearMAC() { + MAC = null; + fieldSetFlags()[1] = false; + return this; + } + + /** + * Gets the value of the 'ID' field. + * @return The value. + */ + public java.lang.CharSequence getID() { + return ID; + } + + + /** + * Sets the value of the 'ID' field. + * @param value The value of 'ID'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.iotdevice.IotDevice.Builder setID(java.lang.CharSequence value) { + validate(fields()[2], value); + this.ID = value; + fieldSetFlags()[2] = true; + return this; + } + + /** + * Checks whether the 'ID' field has been set. + * @return True if the 'ID' field has been set, false otherwise. + */ + public boolean hasID() { + return fieldSetFlags()[2]; + } + + + /** + * Clears the value of the 'ID' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.iotdevice.IotDevice.Builder clearID() { + ID = null; + fieldSetFlags()[2] = false; + return this; + } + + /** + * Gets the value of the 'TYPE' field. + * @return The value. + */ + public java.lang.CharSequence getTYPE() { + return TYPE; + } + + + /** + * Sets the value of the 'TYPE' field. + * @param value The value of 'TYPE'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.iotdevice.IotDevice.Builder setTYPE(java.lang.CharSequence value) { + validate(fields()[3], value); + this.TYPE = value; + fieldSetFlags()[3] = true; + return this; + } + + /** + * Checks whether the 'TYPE' field has been set. + * @return True if the 'TYPE' field has been set, false otherwise. + */ + public boolean hasTYPE() { + return fieldSetFlags()[3]; + } + + + /** + * Clears the value of the 'TYPE' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.iotdevice.IotDevice.Builder clearTYPE() { + TYPE = null; + fieldSetFlags()[3] = false; + return this; + } + + /** + * Gets the value of the 'LAST_UPDATE' field. + * @return The value. + */ + public java.lang.CharSequence getLASTUPDATE() { + return LAST_UPDATE; + } + + + /** + * Sets the value of the 'LAST_UPDATE' field. + * @param value The value of 'LAST_UPDATE'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.iotdevice.IotDevice.Builder setLASTUPDATE(java.lang.CharSequence value) { + validate(fields()[4], value); + this.LAST_UPDATE = value; + fieldSetFlags()[4] = true; + return this; + } + + /** + * Checks whether the 'LAST_UPDATE' field has been set. + * @return True if the 'LAST_UPDATE' field has been set, false otherwise. + */ + public boolean hasLASTUPDATE() { + return fieldSetFlags()[4]; + } + + + /** + * Clears the value of the 'LAST_UPDATE' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.iotdevice.IotDevice.Builder clearLASTUPDATE() { + LAST_UPDATE = null; + fieldSetFlags()[4] = false; + return this; + } + + /** + * Gets the value of the 'LINK_QUALITY' field. + * @return The value. + */ + public int getLINKQUALITY() { + return LINK_QUALITY; + } + + + /** + * Sets the value of the 'LINK_QUALITY' field. + * @param value The value of 'LINK_QUALITY'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.iotdevice.IotDevice.Builder setLINKQUALITY(int value) { + validate(fields()[5], value); + this.LINK_QUALITY = value; + fieldSetFlags()[5] = true; + return this; + } + + /** + * Checks whether the 'LINK_QUALITY' field has been set. + * @return True if the 'LINK_QUALITY' field has been set, false otherwise. + */ + public boolean hasLINKQUALITY() { + return fieldSetFlags()[5]; + } + + + /** + * Clears the value of the 'LINK_QUALITY' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.iotdevice.IotDevice.Builder clearLINKQUALITY() { + fieldSetFlags()[5] = false; + return this; + } + + /** + * Gets the value of the 'DATA' field. + * @return The value. + */ + public java.lang.Object getDATA() { + return DATA; + } + + + /** + * Sets the value of the 'DATA' field. + * @param value The value of 'DATA'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.iotdevice.IotDevice.Builder setDATA(java.lang.Object value) { + validate(fields()[6], value); + this.DATA = value; + fieldSetFlags()[6] = true; + return this; + } + + /** + * Checks whether the 'DATA' field has been set. + * @return True if the 'DATA' field has been set, false otherwise. + */ + public boolean hasDATA() { + return fieldSetFlags()[6]; + } + + + /** + * Clears the value of the 'DATA' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.iotdevice.IotDevice.Builder clearDATA() { + DATA = null; + fieldSetFlags()[6] = false; + return this; + } + + @Override + @SuppressWarnings("unchecked") + public IotDevice build() { + try { + IotDevice record = new IotDevice(); + record.IPV4 = fieldSetFlags()[0] ? this.IPV4 : (java.lang.CharSequence) defaultValue(fields()[0]); + record.MAC = fieldSetFlags()[1] ? this.MAC : (java.lang.CharSequence) defaultValue(fields()[1]); + record.ID = fieldSetFlags()[2] ? this.ID : (java.lang.CharSequence) defaultValue(fields()[2]); + record.TYPE = fieldSetFlags()[3] ? this.TYPE : (java.lang.CharSequence) defaultValue(fields()[3]); + record.LAST_UPDATE = fieldSetFlags()[4] ? this.LAST_UPDATE : (java.lang.CharSequence) defaultValue(fields()[4]); + record.LINK_QUALITY = fieldSetFlags()[5] ? this.LINK_QUALITY : (java.lang.Integer) defaultValue(fields()[5]); + record.DATA = fieldSetFlags()[6] ? this.DATA : defaultValue(fields()[6]); + return record; + } catch (org.apache.avro.AvroMissingFieldException e) { + throw e; + } catch (java.lang.Exception e) { + throw new org.apache.avro.AvroRuntimeException(e); + } + } + } + + @SuppressWarnings("unchecked") + private static final org.apache.avro.io.DatumWriter + WRITER$ = (org.apache.avro.io.DatumWriter)MODEL$.createDatumWriter(SCHEMA$); + + @Override public void writeExternal(java.io.ObjectOutput out) + throws java.io.IOException { + WRITER$.write(this, SpecificData.getEncoder(out)); + } + + @SuppressWarnings("unchecked") + private static final org.apache.avro.io.DatumReader + READER$ = (org.apache.avro.io.DatumReader)MODEL$.createDatumReader(SCHEMA$); + + @Override public void readExternal(java.io.ObjectInput in) + throws java.io.IOException { + READER$.read(this, SpecificData.getDecoder(in)); + } + +} + + + + + + + + + + diff --git a/src/main/java/io/skodjob/datagenerator/models/iotdevice/LightData.java b/src/main/java/io/skodjob/datagenerator/models/iotdevice/LightData.java new file mode 100644 index 0000000..eaa4c62 --- /dev/null +++ b/src/main/java/io/skodjob/datagenerator/models/iotdevice/LightData.java @@ -0,0 +1,478 @@ +/** + * Autogenerated by Avro + * + * DO NOT EDIT DIRECTLY + */ +package io.skodjob.datagenerator.models.iotdevice; + +import org.apache.avro.generic.GenericArray; +import org.apache.avro.specific.SpecificData; +import org.apache.avro.util.Utf8; +import org.apache.avro.message.BinaryMessageEncoder; +import org.apache.avro.message.BinaryMessageDecoder; +import org.apache.avro.message.SchemaStore; + +@org.apache.avro.specific.AvroGenerated +public class LightData extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord { + private static final long serialVersionUID = 2564045829790584903L; + + + public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"LightData\",\"namespace\":\"io.skodjob.datagenerator.models.iotdevice\",\"fields\":[{\"name\":\"power\",\"type\":\"string\"},{\"name\":\"brightness\",\"type\":\"int\"},{\"name\":\"power_on_behavior\",\"type\":\"string\"}]}"); + public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } + + private static final SpecificData MODEL$ = new SpecificData(); + + private static final BinaryMessageEncoder ENCODER = + new BinaryMessageEncoder<>(MODEL$, SCHEMA$); + + private static final BinaryMessageDecoder DECODER = + new BinaryMessageDecoder<>(MODEL$, SCHEMA$); + + /** + * Return the BinaryMessageEncoder instance used by this class. + * @return the message encoder used by this class + */ + public static BinaryMessageEncoder getEncoder() { + return ENCODER; + } + + /** + * Return the BinaryMessageDecoder instance used by this class. + * @return the message decoder used by this class + */ + public static BinaryMessageDecoder getDecoder() { + return DECODER; + } + + /** + * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}. + * @param resolver a {@link SchemaStore} used to find schemas by fingerprint + * @return a BinaryMessageDecoder instance for this class backed by the given SchemaStore + */ + public static BinaryMessageDecoder createDecoder(SchemaStore resolver) { + return new BinaryMessageDecoder<>(MODEL$, SCHEMA$, resolver); + } + + /** + * Serializes this LightData to a ByteBuffer. + * @return a buffer holding the serialized data for this instance + * @throws java.io.IOException if this instance could not be serialized + */ + public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException { + return ENCODER.encode(this); + } + + /** + * Deserializes a LightData from a ByteBuffer. + * @param b a byte buffer holding serialized data for an instance of this class + * @return a LightData instance decoded from the given buffer + * @throws java.io.IOException if the given bytes could not be deserialized into an instance of this class + */ + public static LightData fromByteBuffer( + java.nio.ByteBuffer b) throws java.io.IOException { + return DECODER.decode(b); + } + + private java.lang.CharSequence power; + private int brightness; + private java.lang.CharSequence power_on_behavior; + + /** + * Default constructor. Note that this does not initialize fields + * to their default values from the schema. If that is desired then + * one should use newBuilder(). + */ + public LightData() {} + + /** + * All-args constructor. + * @param power The new value for power + * @param brightness The new value for brightness + * @param power_on_behavior The new value for power_on_behavior + */ + public LightData(java.lang.CharSequence power, java.lang.Integer brightness, java.lang.CharSequence power_on_behavior) { + this.power = power; + this.brightness = brightness; + this.power_on_behavior = power_on_behavior; + } + + @Override + public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; } + + @Override + public org.apache.avro.Schema getSchema() { return SCHEMA$; } + + // Used by DatumWriter. Applications should not call. + @Override + public java.lang.Object get(int field$) { + switch (field$) { + case 0: return power; + case 1: return brightness; + case 2: return power_on_behavior; + default: throw new IndexOutOfBoundsException("Invalid index: " + field$); + } + } + + // Used by DatumReader. Applications should not call. + @Override + @SuppressWarnings(value="unchecked") + public void put(int field$, java.lang.Object value$) { + switch (field$) { + case 0: power = (java.lang.CharSequence)value$; break; + case 1: brightness = (java.lang.Integer)value$; break; + case 2: power_on_behavior = (java.lang.CharSequence)value$; break; + default: throw new IndexOutOfBoundsException("Invalid index: " + field$); + } + } + + /** + * Gets the value of the 'power' field. + * @return The value of the 'power' field. + */ + public java.lang.CharSequence getPower() { + return power; + } + + + /** + * Sets the value of the 'power' field. + * @param value the value to set. + */ + public void setPower(java.lang.CharSequence value) { + this.power = value; + } + + /** + * Gets the value of the 'brightness' field. + * @return The value of the 'brightness' field. + */ + public int getBrightness() { + return brightness; + } + + + /** + * Sets the value of the 'brightness' field. + * @param value the value to set. + */ + public void setBrightness(int value) { + this.brightness = value; + } + + /** + * Gets the value of the 'power_on_behavior' field. + * @return The value of the 'power_on_behavior' field. + */ + public java.lang.CharSequence getPowerOnBehavior() { + return power_on_behavior; + } + + + /** + * Sets the value of the 'power_on_behavior' field. + * @param value the value to set. + */ + public void setPowerOnBehavior(java.lang.CharSequence value) { + this.power_on_behavior = value; + } + + /** + * Creates a new LightData RecordBuilder. + * @return A new LightData RecordBuilder + */ + public static io.skodjob.datagenerator.models.iotdevice.LightData.Builder newBuilder() { + return new io.skodjob.datagenerator.models.iotdevice.LightData.Builder(); + } + + /** + * Creates a new LightData RecordBuilder by copying an existing Builder. + * @param other The existing builder to copy. + * @return A new LightData RecordBuilder + */ + public static io.skodjob.datagenerator.models.iotdevice.LightData.Builder newBuilder(io.skodjob.datagenerator.models.iotdevice.LightData.Builder other) { + if (other == null) { + return new io.skodjob.datagenerator.models.iotdevice.LightData.Builder(); + } else { + return new io.skodjob.datagenerator.models.iotdevice.LightData.Builder(other); + } + } + + /** + * Creates a new LightData RecordBuilder by copying an existing LightData instance. + * @param other The existing instance to copy. + * @return A new LightData RecordBuilder + */ + public static io.skodjob.datagenerator.models.iotdevice.LightData.Builder newBuilder(io.skodjob.datagenerator.models.iotdevice.LightData other) { + if (other == null) { + return new io.skodjob.datagenerator.models.iotdevice.LightData.Builder(); + } else { + return new io.skodjob.datagenerator.models.iotdevice.LightData.Builder(other); + } + } + + /** + * RecordBuilder for LightData instances. + */ + @org.apache.avro.specific.AvroGenerated + public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase + implements org.apache.avro.data.RecordBuilder { + + private java.lang.CharSequence power; + private int brightness; + private java.lang.CharSequence power_on_behavior; + + /** Creates a new Builder */ + private Builder() { + super(SCHEMA$, MODEL$); + } + + /** + * Creates a Builder by copying an existing Builder. + * @param other The existing Builder to copy. + */ + private Builder(io.skodjob.datagenerator.models.iotdevice.LightData.Builder other) { + super(other); + if (isValidValue(fields()[0], other.power)) { + this.power = data().deepCopy(fields()[0].schema(), other.power); + fieldSetFlags()[0] = other.fieldSetFlags()[0]; + } + if (isValidValue(fields()[1], other.brightness)) { + this.brightness = data().deepCopy(fields()[1].schema(), other.brightness); + fieldSetFlags()[1] = other.fieldSetFlags()[1]; + } + if (isValidValue(fields()[2], other.power_on_behavior)) { + this.power_on_behavior = data().deepCopy(fields()[2].schema(), other.power_on_behavior); + fieldSetFlags()[2] = other.fieldSetFlags()[2]; + } + } + + /** + * Creates a Builder by copying an existing LightData instance + * @param other The existing instance to copy. + */ + private Builder(io.skodjob.datagenerator.models.iotdevice.LightData other) { + super(SCHEMA$, MODEL$); + if (isValidValue(fields()[0], other.power)) { + this.power = data().deepCopy(fields()[0].schema(), other.power); + fieldSetFlags()[0] = true; + } + if (isValidValue(fields()[1], other.brightness)) { + this.brightness = data().deepCopy(fields()[1].schema(), other.brightness); + fieldSetFlags()[1] = true; + } + if (isValidValue(fields()[2], other.power_on_behavior)) { + this.power_on_behavior = data().deepCopy(fields()[2].schema(), other.power_on_behavior); + fieldSetFlags()[2] = true; + } + } + + /** + * Gets the value of the 'power' field. + * @return The value. + */ + public java.lang.CharSequence getPower() { + return power; + } + + + /** + * Sets the value of the 'power' field. + * @param value The value of 'power'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.iotdevice.LightData.Builder setPower(java.lang.CharSequence value) { + validate(fields()[0], value); + this.power = value; + fieldSetFlags()[0] = true; + return this; + } + + /** + * Checks whether the 'power' field has been set. + * @return True if the 'power' field has been set, false otherwise. + */ + public boolean hasPower() { + return fieldSetFlags()[0]; + } + + + /** + * Clears the value of the 'power' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.iotdevice.LightData.Builder clearPower() { + power = null; + fieldSetFlags()[0] = false; + return this; + } + + /** + * Gets the value of the 'brightness' field. + * @return The value. + */ + public int getBrightness() { + return brightness; + } + + + /** + * Sets the value of the 'brightness' field. + * @param value The value of 'brightness'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.iotdevice.LightData.Builder setBrightness(int value) { + validate(fields()[1], value); + this.brightness = value; + fieldSetFlags()[1] = true; + return this; + } + + /** + * Checks whether the 'brightness' field has been set. + * @return True if the 'brightness' field has been set, false otherwise. + */ + public boolean hasBrightness() { + return fieldSetFlags()[1]; + } + + + /** + * Clears the value of the 'brightness' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.iotdevice.LightData.Builder clearBrightness() { + fieldSetFlags()[1] = false; + return this; + } + + /** + * Gets the value of the 'power_on_behavior' field. + * @return The value. + */ + public java.lang.CharSequence getPowerOnBehavior() { + return power_on_behavior; + } + + + /** + * Sets the value of the 'power_on_behavior' field. + * @param value The value of 'power_on_behavior'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.iotdevice.LightData.Builder setPowerOnBehavior(java.lang.CharSequence value) { + validate(fields()[2], value); + this.power_on_behavior = value; + fieldSetFlags()[2] = true; + return this; + } + + /** + * Checks whether the 'power_on_behavior' field has been set. + * @return True if the 'power_on_behavior' field has been set, false otherwise. + */ + public boolean hasPowerOnBehavior() { + return fieldSetFlags()[2]; + } + + + /** + * Clears the value of the 'power_on_behavior' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.iotdevice.LightData.Builder clearPowerOnBehavior() { + power_on_behavior = null; + fieldSetFlags()[2] = false; + return this; + } + + @Override + @SuppressWarnings("unchecked") + public LightData build() { + try { + LightData record = new LightData(); + record.power = fieldSetFlags()[0] ? this.power : (java.lang.CharSequence) defaultValue(fields()[0]); + record.brightness = fieldSetFlags()[1] ? this.brightness : (java.lang.Integer) defaultValue(fields()[1]); + record.power_on_behavior = fieldSetFlags()[2] ? this.power_on_behavior : (java.lang.CharSequence) defaultValue(fields()[2]); + return record; + } catch (org.apache.avro.AvroMissingFieldException e) { + throw e; + } catch (java.lang.Exception e) { + throw new org.apache.avro.AvroRuntimeException(e); + } + } + } + + @SuppressWarnings("unchecked") + private static final org.apache.avro.io.DatumWriter + WRITER$ = (org.apache.avro.io.DatumWriter)MODEL$.createDatumWriter(SCHEMA$); + + @Override public void writeExternal(java.io.ObjectOutput out) + throws java.io.IOException { + WRITER$.write(this, SpecificData.getEncoder(out)); + } + + @SuppressWarnings("unchecked") + private static final org.apache.avro.io.DatumReader + READER$ = (org.apache.avro.io.DatumReader)MODEL$.createDatumReader(SCHEMA$); + + @Override public void readExternal(java.io.ObjectInput in) + throws java.io.IOException { + READER$.read(this, SpecificData.getDecoder(in)); + } + + @Override protected boolean hasCustomCoders() { return true; } + + @Override public void customEncode(org.apache.avro.io.Encoder out) + throws java.io.IOException + { + out.writeString(this.power); + + out.writeInt(this.brightness); + + out.writeString(this.power_on_behavior); + + } + + @Override public void customDecode(org.apache.avro.io.ResolvingDecoder in) + throws java.io.IOException + { + org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff(); + if (fieldOrder == null) { + this.power = in.readString(this.power instanceof Utf8 ? (Utf8)this.power : null); + + this.brightness = in.readInt(); + + this.power_on_behavior = in.readString(this.power_on_behavior instanceof Utf8 ? (Utf8)this.power_on_behavior : null); + + } else { + for (int i = 0; i < 3; i++) { + switch (fieldOrder[i].pos()) { + case 0: + this.power = in.readString(this.power instanceof Utf8 ? (Utf8)this.power : null); + break; + + case 1: + this.brightness = in.readInt(); + break; + + case 2: + this.power_on_behavior = in.readString(this.power_on_behavior instanceof Utf8 ? (Utf8)this.power_on_behavior : null); + break; + + default: + throw new java.io.IOException("Corrupt ResolvingDecoder."); + } + } + } + } +} + + + + + + + + + + diff --git a/src/main/java/io/skodjob/datagenerator/models/iotdevice/PlugData.java b/src/main/java/io/skodjob/datagenerator/models/iotdevice/PlugData.java new file mode 100644 index 0000000..6703042 --- /dev/null +++ b/src/main/java/io/skodjob/datagenerator/models/iotdevice/PlugData.java @@ -0,0 +1,591 @@ +/** + * Autogenerated by Avro + * + * DO NOT EDIT DIRECTLY + */ +package io.skodjob.datagenerator.models.iotdevice; + +import org.apache.avro.generic.GenericArray; +import org.apache.avro.specific.SpecificData; +import org.apache.avro.util.Utf8; +import org.apache.avro.message.BinaryMessageEncoder; +import org.apache.avro.message.BinaryMessageDecoder; +import org.apache.avro.message.SchemaStore; + +@org.apache.avro.specific.AvroGenerated +public class PlugData extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord { + private static final long serialVersionUID = -8358036197985024305L; + + + public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"PlugData\",\"namespace\":\"io.skodjob.datagenerator.models.iotdevice\",\"fields\":[{\"name\":\"power\",\"type\":\"string\"},{\"name\":\"energy_current\",\"type\":{\"type\":\"record\",\"name\":\"EnergyCurrent\",\"fields\":[{\"name\":\"state\",\"type\":\"float\"},{\"name\":\"unit\",\"type\":\"string\"}]}},{\"name\":\"energy_today\",\"type\":{\"type\":\"record\",\"name\":\"EnergyToday\",\"fields\":[{\"name\":\"state\",\"type\":\"float\"},{\"name\":\"unit\",\"type\":\"string\"}]}}]}"); + public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } + + private static final SpecificData MODEL$ = new SpecificData(); + + private static final BinaryMessageEncoder ENCODER = + new BinaryMessageEncoder<>(MODEL$, SCHEMA$); + + private static final BinaryMessageDecoder DECODER = + new BinaryMessageDecoder<>(MODEL$, SCHEMA$); + + /** + * Return the BinaryMessageEncoder instance used by this class. + * @return the message encoder used by this class + */ + public static BinaryMessageEncoder getEncoder() { + return ENCODER; + } + + /** + * Return the BinaryMessageDecoder instance used by this class. + * @return the message decoder used by this class + */ + public static BinaryMessageDecoder getDecoder() { + return DECODER; + } + + /** + * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}. + * @param resolver a {@link SchemaStore} used to find schemas by fingerprint + * @return a BinaryMessageDecoder instance for this class backed by the given SchemaStore + */ + public static BinaryMessageDecoder createDecoder(SchemaStore resolver) { + return new BinaryMessageDecoder<>(MODEL$, SCHEMA$, resolver); + } + + /** + * Serializes this PlugData to a ByteBuffer. + * @return a buffer holding the serialized data for this instance + * @throws java.io.IOException if this instance could not be serialized + */ + public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException { + return ENCODER.encode(this); + } + + /** + * Deserializes a PlugData from a ByteBuffer. + * @param b a byte buffer holding serialized data for an instance of this class + * @return a PlugData instance decoded from the given buffer + * @throws java.io.IOException if the given bytes could not be deserialized into an instance of this class + */ + public static PlugData fromByteBuffer( + java.nio.ByteBuffer b) throws java.io.IOException { + return DECODER.decode(b); + } + + private java.lang.CharSequence power; + private io.skodjob.datagenerator.models.iotdevice.EnergyCurrent energy_current; + private io.skodjob.datagenerator.models.iotdevice.EnergyToday energy_today; + + /** + * Default constructor. Note that this does not initialize fields + * to their default values from the schema. If that is desired then + * one should use newBuilder(). + */ + public PlugData() {} + + /** + * All-args constructor. + * @param power The new value for power + * @param energy_current The new value for energy_current + * @param energy_today The new value for energy_today + */ + public PlugData(java.lang.CharSequence power, io.skodjob.datagenerator.models.iotdevice.EnergyCurrent energy_current, io.skodjob.datagenerator.models.iotdevice.EnergyToday energy_today) { + this.power = power; + this.energy_current = energy_current; + this.energy_today = energy_today; + } + + @Override + public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; } + + @Override + public org.apache.avro.Schema getSchema() { return SCHEMA$; } + + // Used by DatumWriter. Applications should not call. + @Override + public java.lang.Object get(int field$) { + switch (field$) { + case 0: return power; + case 1: return energy_current; + case 2: return energy_today; + default: throw new IndexOutOfBoundsException("Invalid index: " + field$); + } + } + + // Used by DatumReader. Applications should not call. + @Override + @SuppressWarnings(value="unchecked") + public void put(int field$, java.lang.Object value$) { + switch (field$) { + case 0: power = (java.lang.CharSequence)value$; break; + case 1: energy_current = (io.skodjob.datagenerator.models.iotdevice.EnergyCurrent)value$; break; + case 2: energy_today = (io.skodjob.datagenerator.models.iotdevice.EnergyToday)value$; break; + default: throw new IndexOutOfBoundsException("Invalid index: " + field$); + } + } + + /** + * Gets the value of the 'power' field. + * @return The value of the 'power' field. + */ + public java.lang.CharSequence getPower() { + return power; + } + + + /** + * Sets the value of the 'power' field. + * @param value the value to set. + */ + public void setPower(java.lang.CharSequence value) { + this.power = value; + } + + /** + * Gets the value of the 'energy_current' field. + * @return The value of the 'energy_current' field. + */ + public io.skodjob.datagenerator.models.iotdevice.EnergyCurrent getEnergyCurrent() { + return energy_current; + } + + + /** + * Sets the value of the 'energy_current' field. + * @param value the value to set. + */ + public void setEnergyCurrent(io.skodjob.datagenerator.models.iotdevice.EnergyCurrent value) { + this.energy_current = value; + } + + /** + * Gets the value of the 'energy_today' field. + * @return The value of the 'energy_today' field. + */ + public io.skodjob.datagenerator.models.iotdevice.EnergyToday getEnergyToday() { + return energy_today; + } + + + /** + * Sets the value of the 'energy_today' field. + * @param value the value to set. + */ + public void setEnergyToday(io.skodjob.datagenerator.models.iotdevice.EnergyToday value) { + this.energy_today = value; + } + + /** + * Creates a new PlugData RecordBuilder. + * @return A new PlugData RecordBuilder + */ + public static io.skodjob.datagenerator.models.iotdevice.PlugData.Builder newBuilder() { + return new io.skodjob.datagenerator.models.iotdevice.PlugData.Builder(); + } + + /** + * Creates a new PlugData RecordBuilder by copying an existing Builder. + * @param other The existing builder to copy. + * @return A new PlugData RecordBuilder + */ + public static io.skodjob.datagenerator.models.iotdevice.PlugData.Builder newBuilder(io.skodjob.datagenerator.models.iotdevice.PlugData.Builder other) { + if (other == null) { + return new io.skodjob.datagenerator.models.iotdevice.PlugData.Builder(); + } else { + return new io.skodjob.datagenerator.models.iotdevice.PlugData.Builder(other); + } + } + + /** + * Creates a new PlugData RecordBuilder by copying an existing PlugData instance. + * @param other The existing instance to copy. + * @return A new PlugData RecordBuilder + */ + public static io.skodjob.datagenerator.models.iotdevice.PlugData.Builder newBuilder(io.skodjob.datagenerator.models.iotdevice.PlugData other) { + if (other == null) { + return new io.skodjob.datagenerator.models.iotdevice.PlugData.Builder(); + } else { + return new io.skodjob.datagenerator.models.iotdevice.PlugData.Builder(other); + } + } + + /** + * RecordBuilder for PlugData instances. + */ + @org.apache.avro.specific.AvroGenerated + public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase + implements org.apache.avro.data.RecordBuilder { + + private java.lang.CharSequence power; + private io.skodjob.datagenerator.models.iotdevice.EnergyCurrent energy_current; + private io.skodjob.datagenerator.models.iotdevice.EnergyCurrent.Builder energy_currentBuilder; + private io.skodjob.datagenerator.models.iotdevice.EnergyToday energy_today; + private io.skodjob.datagenerator.models.iotdevice.EnergyToday.Builder energy_todayBuilder; + + /** Creates a new Builder */ + private Builder() { + super(SCHEMA$, MODEL$); + } + + /** + * Creates a Builder by copying an existing Builder. + * @param other The existing Builder to copy. + */ + private Builder(io.skodjob.datagenerator.models.iotdevice.PlugData.Builder other) { + super(other); + if (isValidValue(fields()[0], other.power)) { + this.power = data().deepCopy(fields()[0].schema(), other.power); + fieldSetFlags()[0] = other.fieldSetFlags()[0]; + } + if (isValidValue(fields()[1], other.energy_current)) { + this.energy_current = data().deepCopy(fields()[1].schema(), other.energy_current); + fieldSetFlags()[1] = other.fieldSetFlags()[1]; + } + if (other.hasEnergyCurrentBuilder()) { + this.energy_currentBuilder = io.skodjob.datagenerator.models.iotdevice.EnergyCurrent.newBuilder(other.getEnergyCurrentBuilder()); + } + if (isValidValue(fields()[2], other.energy_today)) { + this.energy_today = data().deepCopy(fields()[2].schema(), other.energy_today); + fieldSetFlags()[2] = other.fieldSetFlags()[2]; + } + if (other.hasEnergyTodayBuilder()) { + this.energy_todayBuilder = io.skodjob.datagenerator.models.iotdevice.EnergyToday.newBuilder(other.getEnergyTodayBuilder()); + } + } + + /** + * Creates a Builder by copying an existing PlugData instance + * @param other The existing instance to copy. + */ + private Builder(io.skodjob.datagenerator.models.iotdevice.PlugData other) { + super(SCHEMA$, MODEL$); + if (isValidValue(fields()[0], other.power)) { + this.power = data().deepCopy(fields()[0].schema(), other.power); + fieldSetFlags()[0] = true; + } + if (isValidValue(fields()[1], other.energy_current)) { + this.energy_current = data().deepCopy(fields()[1].schema(), other.energy_current); + fieldSetFlags()[1] = true; + } + this.energy_currentBuilder = null; + if (isValidValue(fields()[2], other.energy_today)) { + this.energy_today = data().deepCopy(fields()[2].schema(), other.energy_today); + fieldSetFlags()[2] = true; + } + this.energy_todayBuilder = null; + } + + /** + * Gets the value of the 'power' field. + * @return The value. + */ + public java.lang.CharSequence getPower() { + return power; + } + + + /** + * Sets the value of the 'power' field. + * @param value The value of 'power'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.iotdevice.PlugData.Builder setPower(java.lang.CharSequence value) { + validate(fields()[0], value); + this.power = value; + fieldSetFlags()[0] = true; + return this; + } + + /** + * Checks whether the 'power' field has been set. + * @return True if the 'power' field has been set, false otherwise. + */ + public boolean hasPower() { + return fieldSetFlags()[0]; + } + + + /** + * Clears the value of the 'power' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.iotdevice.PlugData.Builder clearPower() { + power = null; + fieldSetFlags()[0] = false; + return this; + } + + /** + * Gets the value of the 'energy_current' field. + * @return The value. + */ + public io.skodjob.datagenerator.models.iotdevice.EnergyCurrent getEnergyCurrent() { + return energy_current; + } + + + /** + * Sets the value of the 'energy_current' field. + * @param value The value of 'energy_current'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.iotdevice.PlugData.Builder setEnergyCurrent(io.skodjob.datagenerator.models.iotdevice.EnergyCurrent value) { + validate(fields()[1], value); + this.energy_currentBuilder = null; + this.energy_current = value; + fieldSetFlags()[1] = true; + return this; + } + + /** + * Checks whether the 'energy_current' field has been set. + * @return True if the 'energy_current' field has been set, false otherwise. + */ + public boolean hasEnergyCurrent() { + return fieldSetFlags()[1]; + } + + /** + * Gets the Builder instance for the 'energy_current' field and creates one if it doesn't exist yet. + * @return This builder. + */ + public io.skodjob.datagenerator.models.iotdevice.EnergyCurrent.Builder getEnergyCurrentBuilder() { + if (energy_currentBuilder == null) { + if (hasEnergyCurrent()) { + setEnergyCurrentBuilder(io.skodjob.datagenerator.models.iotdevice.EnergyCurrent.newBuilder(energy_current)); + } else { + setEnergyCurrentBuilder(io.skodjob.datagenerator.models.iotdevice.EnergyCurrent.newBuilder()); + } + } + return energy_currentBuilder; + } + + /** + * Sets the Builder instance for the 'energy_current' field + * @param value The builder instance that must be set. + * @return This builder. + */ + + public io.skodjob.datagenerator.models.iotdevice.PlugData.Builder setEnergyCurrentBuilder(io.skodjob.datagenerator.models.iotdevice.EnergyCurrent.Builder value) { + clearEnergyCurrent(); + energy_currentBuilder = value; + return this; + } + + /** + * Checks whether the 'energy_current' field has an active Builder instance + * @return True if the 'energy_current' field has an active Builder instance + */ + public boolean hasEnergyCurrentBuilder() { + return energy_currentBuilder != null; + } + + /** + * Clears the value of the 'energy_current' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.iotdevice.PlugData.Builder clearEnergyCurrent() { + energy_current = null; + energy_currentBuilder = null; + fieldSetFlags()[1] = false; + return this; + } + + /** + * Gets the value of the 'energy_today' field. + * @return The value. + */ + public io.skodjob.datagenerator.models.iotdevice.EnergyToday getEnergyToday() { + return energy_today; + } + + + /** + * Sets the value of the 'energy_today' field. + * @param value The value of 'energy_today'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.iotdevice.PlugData.Builder setEnergyToday(io.skodjob.datagenerator.models.iotdevice.EnergyToday value) { + validate(fields()[2], value); + this.energy_todayBuilder = null; + this.energy_today = value; + fieldSetFlags()[2] = true; + return this; + } + + /** + * Checks whether the 'energy_today' field has been set. + * @return True if the 'energy_today' field has been set, false otherwise. + */ + public boolean hasEnergyToday() { + return fieldSetFlags()[2]; + } + + /** + * Gets the Builder instance for the 'energy_today' field and creates one if it doesn't exist yet. + * @return This builder. + */ + public io.skodjob.datagenerator.models.iotdevice.EnergyToday.Builder getEnergyTodayBuilder() { + if (energy_todayBuilder == null) { + if (hasEnergyToday()) { + setEnergyTodayBuilder(io.skodjob.datagenerator.models.iotdevice.EnergyToday.newBuilder(energy_today)); + } else { + setEnergyTodayBuilder(io.skodjob.datagenerator.models.iotdevice.EnergyToday.newBuilder()); + } + } + return energy_todayBuilder; + } + + /** + * Sets the Builder instance for the 'energy_today' field + * @param value The builder instance that must be set. + * @return This builder. + */ + + public io.skodjob.datagenerator.models.iotdevice.PlugData.Builder setEnergyTodayBuilder(io.skodjob.datagenerator.models.iotdevice.EnergyToday.Builder value) { + clearEnergyToday(); + energy_todayBuilder = value; + return this; + } + + /** + * Checks whether the 'energy_today' field has an active Builder instance + * @return True if the 'energy_today' field has an active Builder instance + */ + public boolean hasEnergyTodayBuilder() { + return energy_todayBuilder != null; + } + + /** + * Clears the value of the 'energy_today' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.iotdevice.PlugData.Builder clearEnergyToday() { + energy_today = null; + energy_todayBuilder = null; + fieldSetFlags()[2] = false; + return this; + } + + @Override + @SuppressWarnings("unchecked") + public PlugData build() { + try { + PlugData record = new PlugData(); + record.power = fieldSetFlags()[0] ? this.power : (java.lang.CharSequence) defaultValue(fields()[0]); + if (energy_currentBuilder != null) { + try { + record.energy_current = this.energy_currentBuilder.build(); + } catch (org.apache.avro.AvroMissingFieldException e) { + e.addParentField(record.getSchema().getField("energy_current")); + throw e; + } + } else { + record.energy_current = fieldSetFlags()[1] ? this.energy_current : (io.skodjob.datagenerator.models.iotdevice.EnergyCurrent) defaultValue(fields()[1]); + } + if (energy_todayBuilder != null) { + try { + record.energy_today = this.energy_todayBuilder.build(); + } catch (org.apache.avro.AvroMissingFieldException e) { + e.addParentField(record.getSchema().getField("energy_today")); + throw e; + } + } else { + record.energy_today = fieldSetFlags()[2] ? this.energy_today : (io.skodjob.datagenerator.models.iotdevice.EnergyToday) defaultValue(fields()[2]); + } + return record; + } catch (org.apache.avro.AvroMissingFieldException e) { + throw e; + } catch (java.lang.Exception e) { + throw new org.apache.avro.AvroRuntimeException(e); + } + } + } + + @SuppressWarnings("unchecked") + private static final org.apache.avro.io.DatumWriter + WRITER$ = (org.apache.avro.io.DatumWriter)MODEL$.createDatumWriter(SCHEMA$); + + @Override public void writeExternal(java.io.ObjectOutput out) + throws java.io.IOException { + WRITER$.write(this, SpecificData.getEncoder(out)); + } + + @SuppressWarnings("unchecked") + private static final org.apache.avro.io.DatumReader + READER$ = (org.apache.avro.io.DatumReader)MODEL$.createDatumReader(SCHEMA$); + + @Override public void readExternal(java.io.ObjectInput in) + throws java.io.IOException { + READER$.read(this, SpecificData.getDecoder(in)); + } + + @Override protected boolean hasCustomCoders() { return true; } + + @Override public void customEncode(org.apache.avro.io.Encoder out) + throws java.io.IOException + { + out.writeString(this.power); + + this.energy_current.customEncode(out); + + this.energy_today.customEncode(out); + + } + + @Override public void customDecode(org.apache.avro.io.ResolvingDecoder in) + throws java.io.IOException + { + org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff(); + if (fieldOrder == null) { + this.power = in.readString(this.power instanceof Utf8 ? (Utf8)this.power : null); + + if (this.energy_current == null) { + this.energy_current = new io.skodjob.datagenerator.models.iotdevice.EnergyCurrent(); + } + this.energy_current.customDecode(in); + + if (this.energy_today == null) { + this.energy_today = new io.skodjob.datagenerator.models.iotdevice.EnergyToday(); + } + this.energy_today.customDecode(in); + + } else { + for (int i = 0; i < 3; i++) { + switch (fieldOrder[i].pos()) { + case 0: + this.power = in.readString(this.power instanceof Utf8 ? (Utf8)this.power : null); + break; + + case 1: + if (this.energy_current == null) { + this.energy_current = new io.skodjob.datagenerator.models.iotdevice.EnergyCurrent(); + } + this.energy_current.customDecode(in); + break; + + case 2: + if (this.energy_today == null) { + this.energy_today = new io.skodjob.datagenerator.models.iotdevice.EnergyToday(); + } + this.energy_today.customDecode(in); + break; + + default: + throw new java.io.IOException("Corrupt ResolvingDecoder."); + } + } + } + } +} + + + + + + + + + + diff --git a/src/main/java/io/skodjob/datagenerator/models/iotdevice/ThermometerData.java b/src/main/java/io/skodjob/datagenerator/models/iotdevice/ThermometerData.java new file mode 100644 index 0000000..f7fc5d5 --- /dev/null +++ b/src/main/java/io/skodjob/datagenerator/models/iotdevice/ThermometerData.java @@ -0,0 +1,533 @@ +/** + * Autogenerated by Avro + * + * DO NOT EDIT DIRECTLY + */ +package io.skodjob.datagenerator.models.iotdevice; + +import org.apache.avro.generic.GenericArray; +import org.apache.avro.specific.SpecificData; +import org.apache.avro.util.Utf8; +import org.apache.avro.message.BinaryMessageEncoder; +import org.apache.avro.message.BinaryMessageDecoder; +import org.apache.avro.message.SchemaStore; + +@org.apache.avro.specific.AvroGenerated +public class ThermometerData extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord { + private static final long serialVersionUID = 4268847101870090241L; + + + public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"ThermometerData\",\"namespace\":\"io.skodjob.datagenerator.models.iotdevice\",\"fields\":[{\"name\":\"temperature\",\"type\":\"float\"},{\"name\":\"humidity\",\"type\":\"float\"},{\"name\":\"battery\",\"type\":{\"type\":\"record\",\"name\":\"Battery\",\"fields\":[{\"name\":\"value\",\"type\":\"int\"},{\"name\":\"unit\",\"type\":\"string\"}]}}]}"); + public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } + + private static final SpecificData MODEL$ = new SpecificData(); + + private static final BinaryMessageEncoder ENCODER = + new BinaryMessageEncoder<>(MODEL$, SCHEMA$); + + private static final BinaryMessageDecoder DECODER = + new BinaryMessageDecoder<>(MODEL$, SCHEMA$); + + /** + * Return the BinaryMessageEncoder instance used by this class. + * @return the message encoder used by this class + */ + public static BinaryMessageEncoder getEncoder() { + return ENCODER; + } + + /** + * Return the BinaryMessageDecoder instance used by this class. + * @return the message decoder used by this class + */ + public static BinaryMessageDecoder getDecoder() { + return DECODER; + } + + /** + * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}. + * @param resolver a {@link SchemaStore} used to find schemas by fingerprint + * @return a BinaryMessageDecoder instance for this class backed by the given SchemaStore + */ + public static BinaryMessageDecoder createDecoder(SchemaStore resolver) { + return new BinaryMessageDecoder<>(MODEL$, SCHEMA$, resolver); + } + + /** + * Serializes this ThermometerData to a ByteBuffer. + * @return a buffer holding the serialized data for this instance + * @throws java.io.IOException if this instance could not be serialized + */ + public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException { + return ENCODER.encode(this); + } + + /** + * Deserializes a ThermometerData from a ByteBuffer. + * @param b a byte buffer holding serialized data for an instance of this class + * @return a ThermometerData instance decoded from the given buffer + * @throws java.io.IOException if the given bytes could not be deserialized into an instance of this class + */ + public static ThermometerData fromByteBuffer( + java.nio.ByteBuffer b) throws java.io.IOException { + return DECODER.decode(b); + } + + private float temperature; + private float humidity; + private io.skodjob.datagenerator.models.iotdevice.Battery battery; + + /** + * Default constructor. Note that this does not initialize fields + * to their default values from the schema. If that is desired then + * one should use newBuilder(). + */ + public ThermometerData() {} + + /** + * All-args constructor. + * @param temperature The new value for temperature + * @param humidity The new value for humidity + * @param battery The new value for battery + */ + public ThermometerData(java.lang.Float temperature, java.lang.Float humidity, io.skodjob.datagenerator.models.iotdevice.Battery battery) { + this.temperature = temperature; + this.humidity = humidity; + this.battery = battery; + } + + @Override + public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; } + + @Override + public org.apache.avro.Schema getSchema() { return SCHEMA$; } + + // Used by DatumWriter. Applications should not call. + @Override + public java.lang.Object get(int field$) { + switch (field$) { + case 0: return temperature; + case 1: return humidity; + case 2: return battery; + default: throw new IndexOutOfBoundsException("Invalid index: " + field$); + } + } + + // Used by DatumReader. Applications should not call. + @Override + @SuppressWarnings(value="unchecked") + public void put(int field$, java.lang.Object value$) { + switch (field$) { + case 0: temperature = (java.lang.Float)value$; break; + case 1: humidity = (java.lang.Float)value$; break; + case 2: battery = (io.skodjob.datagenerator.models.iotdevice.Battery)value$; break; + default: throw new IndexOutOfBoundsException("Invalid index: " + field$); + } + } + + /** + * Gets the value of the 'temperature' field. + * @return The value of the 'temperature' field. + */ + public float getTemperature() { + return temperature; + } + + + /** + * Sets the value of the 'temperature' field. + * @param value the value to set. + */ + public void setTemperature(float value) { + this.temperature = value; + } + + /** + * Gets the value of the 'humidity' field. + * @return The value of the 'humidity' field. + */ + public float getHumidity() { + return humidity; + } + + + /** + * Sets the value of the 'humidity' field. + * @param value the value to set. + */ + public void setHumidity(float value) { + this.humidity = value; + } + + /** + * Gets the value of the 'battery' field. + * @return The value of the 'battery' field. + */ + public io.skodjob.datagenerator.models.iotdevice.Battery getBattery() { + return battery; + } + + + /** + * Sets the value of the 'battery' field. + * @param value the value to set. + */ + public void setBattery(io.skodjob.datagenerator.models.iotdevice.Battery value) { + this.battery = value; + } + + /** + * Creates a new ThermometerData RecordBuilder. + * @return A new ThermometerData RecordBuilder + */ + public static io.skodjob.datagenerator.models.iotdevice.ThermometerData.Builder newBuilder() { + return new io.skodjob.datagenerator.models.iotdevice.ThermometerData.Builder(); + } + + /** + * Creates a new ThermometerData RecordBuilder by copying an existing Builder. + * @param other The existing builder to copy. + * @return A new ThermometerData RecordBuilder + */ + public static io.skodjob.datagenerator.models.iotdevice.ThermometerData.Builder newBuilder(io.skodjob.datagenerator.models.iotdevice.ThermometerData.Builder other) { + if (other == null) { + return new io.skodjob.datagenerator.models.iotdevice.ThermometerData.Builder(); + } else { + return new io.skodjob.datagenerator.models.iotdevice.ThermometerData.Builder(other); + } + } + + /** + * Creates a new ThermometerData RecordBuilder by copying an existing ThermometerData instance. + * @param other The existing instance to copy. + * @return A new ThermometerData RecordBuilder + */ + public static io.skodjob.datagenerator.models.iotdevice.ThermometerData.Builder newBuilder(io.skodjob.datagenerator.models.iotdevice.ThermometerData other) { + if (other == null) { + return new io.skodjob.datagenerator.models.iotdevice.ThermometerData.Builder(); + } else { + return new io.skodjob.datagenerator.models.iotdevice.ThermometerData.Builder(other); + } + } + + /** + * RecordBuilder for ThermometerData instances. + */ + @org.apache.avro.specific.AvroGenerated + public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase + implements org.apache.avro.data.RecordBuilder { + + private float temperature; + private float humidity; + private io.skodjob.datagenerator.models.iotdevice.Battery battery; + private io.skodjob.datagenerator.models.iotdevice.Battery.Builder batteryBuilder; + + /** Creates a new Builder */ + private Builder() { + super(SCHEMA$, MODEL$); + } + + /** + * Creates a Builder by copying an existing Builder. + * @param other The existing Builder to copy. + */ + private Builder(io.skodjob.datagenerator.models.iotdevice.ThermometerData.Builder other) { + super(other); + if (isValidValue(fields()[0], other.temperature)) { + this.temperature = data().deepCopy(fields()[0].schema(), other.temperature); + fieldSetFlags()[0] = other.fieldSetFlags()[0]; + } + if (isValidValue(fields()[1], other.humidity)) { + this.humidity = data().deepCopy(fields()[1].schema(), other.humidity); + fieldSetFlags()[1] = other.fieldSetFlags()[1]; + } + if (isValidValue(fields()[2], other.battery)) { + this.battery = data().deepCopy(fields()[2].schema(), other.battery); + fieldSetFlags()[2] = other.fieldSetFlags()[2]; + } + if (other.hasBatteryBuilder()) { + this.batteryBuilder = io.skodjob.datagenerator.models.iotdevice.Battery.newBuilder(other.getBatteryBuilder()); + } + } + + /** + * Creates a Builder by copying an existing ThermometerData instance + * @param other The existing instance to copy. + */ + private Builder(io.skodjob.datagenerator.models.iotdevice.ThermometerData other) { + super(SCHEMA$, MODEL$); + if (isValidValue(fields()[0], other.temperature)) { + this.temperature = data().deepCopy(fields()[0].schema(), other.temperature); + fieldSetFlags()[0] = true; + } + if (isValidValue(fields()[1], other.humidity)) { + this.humidity = data().deepCopy(fields()[1].schema(), other.humidity); + fieldSetFlags()[1] = true; + } + if (isValidValue(fields()[2], other.battery)) { + this.battery = data().deepCopy(fields()[2].schema(), other.battery); + fieldSetFlags()[2] = true; + } + this.batteryBuilder = null; + } + + /** + * Gets the value of the 'temperature' field. + * @return The value. + */ + public float getTemperature() { + return temperature; + } + + + /** + * Sets the value of the 'temperature' field. + * @param value The value of 'temperature'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.iotdevice.ThermometerData.Builder setTemperature(float value) { + validate(fields()[0], value); + this.temperature = value; + fieldSetFlags()[0] = true; + return this; + } + + /** + * Checks whether the 'temperature' field has been set. + * @return True if the 'temperature' field has been set, false otherwise. + */ + public boolean hasTemperature() { + return fieldSetFlags()[0]; + } + + + /** + * Clears the value of the 'temperature' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.iotdevice.ThermometerData.Builder clearTemperature() { + fieldSetFlags()[0] = false; + return this; + } + + /** + * Gets the value of the 'humidity' field. + * @return The value. + */ + public float getHumidity() { + return humidity; + } + + + /** + * Sets the value of the 'humidity' field. + * @param value The value of 'humidity'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.iotdevice.ThermometerData.Builder setHumidity(float value) { + validate(fields()[1], value); + this.humidity = value; + fieldSetFlags()[1] = true; + return this; + } + + /** + * Checks whether the 'humidity' field has been set. + * @return True if the 'humidity' field has been set, false otherwise. + */ + public boolean hasHumidity() { + return fieldSetFlags()[1]; + } + + + /** + * Clears the value of the 'humidity' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.iotdevice.ThermometerData.Builder clearHumidity() { + fieldSetFlags()[1] = false; + return this; + } + + /** + * Gets the value of the 'battery' field. + * @return The value. + */ + public io.skodjob.datagenerator.models.iotdevice.Battery getBattery() { + return battery; + } + + + /** + * Sets the value of the 'battery' field. + * @param value The value of 'battery'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.iotdevice.ThermometerData.Builder setBattery(io.skodjob.datagenerator.models.iotdevice.Battery value) { + validate(fields()[2], value); + this.batteryBuilder = null; + this.battery = value; + fieldSetFlags()[2] = true; + return this; + } + + /** + * Checks whether the 'battery' field has been set. + * @return True if the 'battery' field has been set, false otherwise. + */ + public boolean hasBattery() { + return fieldSetFlags()[2]; + } + + /** + * Gets the Builder instance for the 'battery' field and creates one if it doesn't exist yet. + * @return This builder. + */ + public io.skodjob.datagenerator.models.iotdevice.Battery.Builder getBatteryBuilder() { + if (batteryBuilder == null) { + if (hasBattery()) { + setBatteryBuilder(io.skodjob.datagenerator.models.iotdevice.Battery.newBuilder(battery)); + } else { + setBatteryBuilder(io.skodjob.datagenerator.models.iotdevice.Battery.newBuilder()); + } + } + return batteryBuilder; + } + + /** + * Sets the Builder instance for the 'battery' field + * @param value The builder instance that must be set. + * @return This builder. + */ + + public io.skodjob.datagenerator.models.iotdevice.ThermometerData.Builder setBatteryBuilder(io.skodjob.datagenerator.models.iotdevice.Battery.Builder value) { + clearBattery(); + batteryBuilder = value; + return this; + } + + /** + * Checks whether the 'battery' field has an active Builder instance + * @return True if the 'battery' field has an active Builder instance + */ + public boolean hasBatteryBuilder() { + return batteryBuilder != null; + } + + /** + * Clears the value of the 'battery' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.iotdevice.ThermometerData.Builder clearBattery() { + battery = null; + batteryBuilder = null; + fieldSetFlags()[2] = false; + return this; + } + + @Override + @SuppressWarnings("unchecked") + public ThermometerData build() { + try { + ThermometerData record = new ThermometerData(); + record.temperature = fieldSetFlags()[0] ? this.temperature : (java.lang.Float) defaultValue(fields()[0]); + record.humidity = fieldSetFlags()[1] ? this.humidity : (java.lang.Float) defaultValue(fields()[1]); + if (batteryBuilder != null) { + try { + record.battery = this.batteryBuilder.build(); + } catch (org.apache.avro.AvroMissingFieldException e) { + e.addParentField(record.getSchema().getField("battery")); + throw e; + } + } else { + record.battery = fieldSetFlags()[2] ? this.battery : (io.skodjob.datagenerator.models.iotdevice.Battery) defaultValue(fields()[2]); + } + return record; + } catch (org.apache.avro.AvroMissingFieldException e) { + throw e; + } catch (java.lang.Exception e) { + throw new org.apache.avro.AvroRuntimeException(e); + } + } + } + + @SuppressWarnings("unchecked") + private static final org.apache.avro.io.DatumWriter + WRITER$ = (org.apache.avro.io.DatumWriter)MODEL$.createDatumWriter(SCHEMA$); + + @Override public void writeExternal(java.io.ObjectOutput out) + throws java.io.IOException { + WRITER$.write(this, SpecificData.getEncoder(out)); + } + + @SuppressWarnings("unchecked") + private static final org.apache.avro.io.DatumReader + READER$ = (org.apache.avro.io.DatumReader)MODEL$.createDatumReader(SCHEMA$); + + @Override public void readExternal(java.io.ObjectInput in) + throws java.io.IOException { + READER$.read(this, SpecificData.getDecoder(in)); + } + + @Override protected boolean hasCustomCoders() { return true; } + + @Override public void customEncode(org.apache.avro.io.Encoder out) + throws java.io.IOException + { + out.writeFloat(this.temperature); + + out.writeFloat(this.humidity); + + this.battery.customEncode(out); + + } + + @Override public void customDecode(org.apache.avro.io.ResolvingDecoder in) + throws java.io.IOException + { + org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff(); + if (fieldOrder == null) { + this.temperature = in.readFloat(); + + this.humidity = in.readFloat(); + + if (this.battery == null) { + this.battery = new io.skodjob.datagenerator.models.iotdevice.Battery(); + } + this.battery.customDecode(in); + + } else { + for (int i = 0; i < 3; i++) { + switch (fieldOrder[i].pos()) { + case 0: + this.temperature = in.readFloat(); + break; + + case 1: + this.humidity = in.readFloat(); + break; + + case 2: + if (this.battery == null) { + this.battery = new io.skodjob.datagenerator.models.iotdevice.Battery(); + } + this.battery.customDecode(in); + break; + + default: + throw new java.io.IOException("Corrupt ResolvingDecoder."); + } + } + } + } +} + + + + + + + + + + diff --git a/src/main/java/io/skodjob/datagenerator/models/paymentfiat/Address.java b/src/main/java/io/skodjob/datagenerator/models/paymentfiat/Address.java new file mode 100644 index 0000000..a71abed --- /dev/null +++ b/src/main/java/io/skodjob/datagenerator/models/paymentfiat/Address.java @@ -0,0 +1,639 @@ +/** + * Autogenerated by Avro + * + * DO NOT EDIT DIRECTLY + */ +package io.skodjob.datagenerator.models.paymentfiat; + +import org.apache.avro.generic.GenericArray; +import org.apache.avro.specific.SpecificData; +import org.apache.avro.util.Utf8; +import org.apache.avro.message.BinaryMessageEncoder; +import org.apache.avro.message.BinaryMessageDecoder; +import org.apache.avro.message.SchemaStore; + +@org.apache.avro.specific.AvroGenerated +public class Address extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord { + private static final long serialVersionUID = 8829654573407560916L; + + + public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"Address\",\"namespace\":\"io.skodjob.datagenerator.models.paymentfiat\",\"fields\":[{\"name\":\"street\",\"type\":\"string\"},{\"name\":\"city\",\"type\":\"string\"},{\"name\":\"state\",\"type\":\"string\"},{\"name\":\"country\",\"type\":\"string\"},{\"name\":\"postalCode\",\"type\":\"string\"}]}"); + public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } + + private static final SpecificData MODEL$ = new SpecificData(); + + private static final BinaryMessageEncoder
ENCODER = + new BinaryMessageEncoder<>(MODEL$, SCHEMA$); + + private static final BinaryMessageDecoder
DECODER = + new BinaryMessageDecoder<>(MODEL$, SCHEMA$); + + /** + * Return the BinaryMessageEncoder instance used by this class. + * @return the message encoder used by this class + */ + public static BinaryMessageEncoder
getEncoder() { + return ENCODER; + } + + /** + * Return the BinaryMessageDecoder instance used by this class. + * @return the message decoder used by this class + */ + public static BinaryMessageDecoder
getDecoder() { + return DECODER; + } + + /** + * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}. + * @param resolver a {@link SchemaStore} used to find schemas by fingerprint + * @return a BinaryMessageDecoder instance for this class backed by the given SchemaStore + */ + public static BinaryMessageDecoder
createDecoder(SchemaStore resolver) { + return new BinaryMessageDecoder<>(MODEL$, SCHEMA$, resolver); + } + + /** + * Serializes this Address to a ByteBuffer. + * @return a buffer holding the serialized data for this instance + * @throws java.io.IOException if this instance could not be serialized + */ + public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException { + return ENCODER.encode(this); + } + + /** + * Deserializes a Address from a ByteBuffer. + * @param b a byte buffer holding serialized data for an instance of this class + * @return a Address instance decoded from the given buffer + * @throws java.io.IOException if the given bytes could not be deserialized into an instance of this class + */ + public static Address fromByteBuffer( + java.nio.ByteBuffer b) throws java.io.IOException { + return DECODER.decode(b); + } + + private java.lang.CharSequence street; + private java.lang.CharSequence city; + private java.lang.CharSequence state; + private java.lang.CharSequence country; + private java.lang.CharSequence postalCode; + + /** + * Default constructor. Note that this does not initialize fields + * to their default values from the schema. If that is desired then + * one should use newBuilder(). + */ + public Address() {} + + /** + * All-args constructor. + * @param street The new value for street + * @param city The new value for city + * @param state The new value for state + * @param country The new value for country + * @param postalCode The new value for postalCode + */ + public Address(java.lang.CharSequence street, java.lang.CharSequence city, java.lang.CharSequence state, java.lang.CharSequence country, java.lang.CharSequence postalCode) { + this.street = street; + this.city = city; + this.state = state; + this.country = country; + this.postalCode = postalCode; + } + + @Override + public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; } + + @Override + public org.apache.avro.Schema getSchema() { return SCHEMA$; } + + // Used by DatumWriter. Applications should not call. + @Override + public java.lang.Object get(int field$) { + switch (field$) { + case 0: return street; + case 1: return city; + case 2: return state; + case 3: return country; + case 4: return postalCode; + default: throw new IndexOutOfBoundsException("Invalid index: " + field$); + } + } + + // Used by DatumReader. Applications should not call. + @Override + @SuppressWarnings(value="unchecked") + public void put(int field$, java.lang.Object value$) { + switch (field$) { + case 0: street = (java.lang.CharSequence)value$; break; + case 1: city = (java.lang.CharSequence)value$; break; + case 2: state = (java.lang.CharSequence)value$; break; + case 3: country = (java.lang.CharSequence)value$; break; + case 4: postalCode = (java.lang.CharSequence)value$; break; + default: throw new IndexOutOfBoundsException("Invalid index: " + field$); + } + } + + /** + * Gets the value of the 'street' field. + * @return The value of the 'street' field. + */ + public java.lang.CharSequence getStreet() { + return street; + } + + + /** + * Sets the value of the 'street' field. + * @param value the value to set. + */ + public void setStreet(java.lang.CharSequence value) { + this.street = value; + } + + /** + * Gets the value of the 'city' field. + * @return The value of the 'city' field. + */ + public java.lang.CharSequence getCity() { + return city; + } + + + /** + * Sets the value of the 'city' field. + * @param value the value to set. + */ + public void setCity(java.lang.CharSequence value) { + this.city = value; + } + + /** + * Gets the value of the 'state' field. + * @return The value of the 'state' field. + */ + public java.lang.CharSequence getState() { + return state; + } + + + /** + * Sets the value of the 'state' field. + * @param value the value to set. + */ + public void setState(java.lang.CharSequence value) { + this.state = value; + } + + /** + * Gets the value of the 'country' field. + * @return The value of the 'country' field. + */ + public java.lang.CharSequence getCountry() { + return country; + } + + + /** + * Sets the value of the 'country' field. + * @param value the value to set. + */ + public void setCountry(java.lang.CharSequence value) { + this.country = value; + } + + /** + * Gets the value of the 'postalCode' field. + * @return The value of the 'postalCode' field. + */ + public java.lang.CharSequence getPostalCode() { + return postalCode; + } + + + /** + * Sets the value of the 'postalCode' field. + * @param value the value to set. + */ + public void setPostalCode(java.lang.CharSequence value) { + this.postalCode = value; + } + + /** + * Creates a new Address RecordBuilder. + * @return A new Address RecordBuilder + */ + public static io.skodjob.datagenerator.models.paymentfiat.Address.Builder newBuilder() { + return new io.skodjob.datagenerator.models.paymentfiat.Address.Builder(); + } + + /** + * Creates a new Address RecordBuilder by copying an existing Builder. + * @param other The existing builder to copy. + * @return A new Address RecordBuilder + */ + public static io.skodjob.datagenerator.models.paymentfiat.Address.Builder newBuilder(io.skodjob.datagenerator.models.paymentfiat.Address.Builder other) { + if (other == null) { + return new io.skodjob.datagenerator.models.paymentfiat.Address.Builder(); + } else { + return new io.skodjob.datagenerator.models.paymentfiat.Address.Builder(other); + } + } + + /** + * Creates a new Address RecordBuilder by copying an existing Address instance. + * @param other The existing instance to copy. + * @return A new Address RecordBuilder + */ + public static io.skodjob.datagenerator.models.paymentfiat.Address.Builder newBuilder(io.skodjob.datagenerator.models.paymentfiat.Address other) { + if (other == null) { + return new io.skodjob.datagenerator.models.paymentfiat.Address.Builder(); + } else { + return new io.skodjob.datagenerator.models.paymentfiat.Address.Builder(other); + } + } + + /** + * RecordBuilder for Address instances. + */ + @org.apache.avro.specific.AvroGenerated + public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase
+ implements org.apache.avro.data.RecordBuilder
{ + + private java.lang.CharSequence street; + private java.lang.CharSequence city; + private java.lang.CharSequence state; + private java.lang.CharSequence country; + private java.lang.CharSequence postalCode; + + /** Creates a new Builder */ + private Builder() { + super(SCHEMA$, MODEL$); + } + + /** + * Creates a Builder by copying an existing Builder. + * @param other The existing Builder to copy. + */ + private Builder(io.skodjob.datagenerator.models.paymentfiat.Address.Builder other) { + super(other); + if (isValidValue(fields()[0], other.street)) { + this.street = data().deepCopy(fields()[0].schema(), other.street); + fieldSetFlags()[0] = other.fieldSetFlags()[0]; + } + if (isValidValue(fields()[1], other.city)) { + this.city = data().deepCopy(fields()[1].schema(), other.city); + fieldSetFlags()[1] = other.fieldSetFlags()[1]; + } + if (isValidValue(fields()[2], other.state)) { + this.state = data().deepCopy(fields()[2].schema(), other.state); + fieldSetFlags()[2] = other.fieldSetFlags()[2]; + } + if (isValidValue(fields()[3], other.country)) { + this.country = data().deepCopy(fields()[3].schema(), other.country); + fieldSetFlags()[3] = other.fieldSetFlags()[3]; + } + if (isValidValue(fields()[4], other.postalCode)) { + this.postalCode = data().deepCopy(fields()[4].schema(), other.postalCode); + fieldSetFlags()[4] = other.fieldSetFlags()[4]; + } + } + + /** + * Creates a Builder by copying an existing Address instance + * @param other The existing instance to copy. + */ + private Builder(io.skodjob.datagenerator.models.paymentfiat.Address other) { + super(SCHEMA$, MODEL$); + if (isValidValue(fields()[0], other.street)) { + this.street = data().deepCopy(fields()[0].schema(), other.street); + fieldSetFlags()[0] = true; + } + if (isValidValue(fields()[1], other.city)) { + this.city = data().deepCopy(fields()[1].schema(), other.city); + fieldSetFlags()[1] = true; + } + if (isValidValue(fields()[2], other.state)) { + this.state = data().deepCopy(fields()[2].schema(), other.state); + fieldSetFlags()[2] = true; + } + if (isValidValue(fields()[3], other.country)) { + this.country = data().deepCopy(fields()[3].schema(), other.country); + fieldSetFlags()[3] = true; + } + if (isValidValue(fields()[4], other.postalCode)) { + this.postalCode = data().deepCopy(fields()[4].schema(), other.postalCode); + fieldSetFlags()[4] = true; + } + } + + /** + * Gets the value of the 'street' field. + * @return The value. + */ + public java.lang.CharSequence getStreet() { + return street; + } + + + /** + * Sets the value of the 'street' field. + * @param value The value of 'street'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.paymentfiat.Address.Builder setStreet(java.lang.CharSequence value) { + validate(fields()[0], value); + this.street = value; + fieldSetFlags()[0] = true; + return this; + } + + /** + * Checks whether the 'street' field has been set. + * @return True if the 'street' field has been set, false otherwise. + */ + public boolean hasStreet() { + return fieldSetFlags()[0]; + } + + + /** + * Clears the value of the 'street' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.paymentfiat.Address.Builder clearStreet() { + street = null; + fieldSetFlags()[0] = false; + return this; + } + + /** + * Gets the value of the 'city' field. + * @return The value. + */ + public java.lang.CharSequence getCity() { + return city; + } + + + /** + * Sets the value of the 'city' field. + * @param value The value of 'city'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.paymentfiat.Address.Builder setCity(java.lang.CharSequence value) { + validate(fields()[1], value); + this.city = value; + fieldSetFlags()[1] = true; + return this; + } + + /** + * Checks whether the 'city' field has been set. + * @return True if the 'city' field has been set, false otherwise. + */ + public boolean hasCity() { + return fieldSetFlags()[1]; + } + + + /** + * Clears the value of the 'city' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.paymentfiat.Address.Builder clearCity() { + city = null; + fieldSetFlags()[1] = false; + return this; + } + + /** + * Gets the value of the 'state' field. + * @return The value. + */ + public java.lang.CharSequence getState() { + return state; + } + + + /** + * Sets the value of the 'state' field. + * @param value The value of 'state'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.paymentfiat.Address.Builder setState(java.lang.CharSequence value) { + validate(fields()[2], value); + this.state = value; + fieldSetFlags()[2] = true; + return this; + } + + /** + * Checks whether the 'state' field has been set. + * @return True if the 'state' field has been set, false otherwise. + */ + public boolean hasState() { + return fieldSetFlags()[2]; + } + + + /** + * Clears the value of the 'state' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.paymentfiat.Address.Builder clearState() { + state = null; + fieldSetFlags()[2] = false; + return this; + } + + /** + * Gets the value of the 'country' field. + * @return The value. + */ + public java.lang.CharSequence getCountry() { + return country; + } + + + /** + * Sets the value of the 'country' field. + * @param value The value of 'country'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.paymentfiat.Address.Builder setCountry(java.lang.CharSequence value) { + validate(fields()[3], value); + this.country = value; + fieldSetFlags()[3] = true; + return this; + } + + /** + * Checks whether the 'country' field has been set. + * @return True if the 'country' field has been set, false otherwise. + */ + public boolean hasCountry() { + return fieldSetFlags()[3]; + } + + + /** + * Clears the value of the 'country' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.paymentfiat.Address.Builder clearCountry() { + country = null; + fieldSetFlags()[3] = false; + return this; + } + + /** + * Gets the value of the 'postalCode' field. + * @return The value. + */ + public java.lang.CharSequence getPostalCode() { + return postalCode; + } + + + /** + * Sets the value of the 'postalCode' field. + * @param value The value of 'postalCode'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.paymentfiat.Address.Builder setPostalCode(java.lang.CharSequence value) { + validate(fields()[4], value); + this.postalCode = value; + fieldSetFlags()[4] = true; + return this; + } + + /** + * Checks whether the 'postalCode' field has been set. + * @return True if the 'postalCode' field has been set, false otherwise. + */ + public boolean hasPostalCode() { + return fieldSetFlags()[4]; + } + + + /** + * Clears the value of the 'postalCode' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.paymentfiat.Address.Builder clearPostalCode() { + postalCode = null; + fieldSetFlags()[4] = false; + return this; + } + + @Override + @SuppressWarnings("unchecked") + public Address build() { + try { + Address record = new Address(); + record.street = fieldSetFlags()[0] ? this.street : (java.lang.CharSequence) defaultValue(fields()[0]); + record.city = fieldSetFlags()[1] ? this.city : (java.lang.CharSequence) defaultValue(fields()[1]); + record.state = fieldSetFlags()[2] ? this.state : (java.lang.CharSequence) defaultValue(fields()[2]); + record.country = fieldSetFlags()[3] ? this.country : (java.lang.CharSequence) defaultValue(fields()[3]); + record.postalCode = fieldSetFlags()[4] ? this.postalCode : (java.lang.CharSequence) defaultValue(fields()[4]); + return record; + } catch (org.apache.avro.AvroMissingFieldException e) { + throw e; + } catch (java.lang.Exception e) { + throw new org.apache.avro.AvroRuntimeException(e); + } + } + } + + @SuppressWarnings("unchecked") + private static final org.apache.avro.io.DatumWriter
+ WRITER$ = (org.apache.avro.io.DatumWriter
)MODEL$.createDatumWriter(SCHEMA$); + + @Override public void writeExternal(java.io.ObjectOutput out) + throws java.io.IOException { + WRITER$.write(this, SpecificData.getEncoder(out)); + } + + @SuppressWarnings("unchecked") + private static final org.apache.avro.io.DatumReader
+ READER$ = (org.apache.avro.io.DatumReader
)MODEL$.createDatumReader(SCHEMA$); + + @Override public void readExternal(java.io.ObjectInput in) + throws java.io.IOException { + READER$.read(this, SpecificData.getDecoder(in)); + } + + @Override protected boolean hasCustomCoders() { return true; } + + @Override public void customEncode(org.apache.avro.io.Encoder out) + throws java.io.IOException + { + out.writeString(this.street); + + out.writeString(this.city); + + out.writeString(this.state); + + out.writeString(this.country); + + out.writeString(this.postalCode); + + } + + @Override public void customDecode(org.apache.avro.io.ResolvingDecoder in) + throws java.io.IOException + { + org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff(); + if (fieldOrder == null) { + this.street = in.readString(this.street instanceof Utf8 ? (Utf8)this.street : null); + + this.city = in.readString(this.city instanceof Utf8 ? (Utf8)this.city : null); + + this.state = in.readString(this.state instanceof Utf8 ? (Utf8)this.state : null); + + this.country = in.readString(this.country instanceof Utf8 ? (Utf8)this.country : null); + + this.postalCode = in.readString(this.postalCode instanceof Utf8 ? (Utf8)this.postalCode : null); + + } else { + for (int i = 0; i < 5; i++) { + switch (fieldOrder[i].pos()) { + case 0: + this.street = in.readString(this.street instanceof Utf8 ? (Utf8)this.street : null); + break; + + case 1: + this.city = in.readString(this.city instanceof Utf8 ? (Utf8)this.city : null); + break; + + case 2: + this.state = in.readString(this.state instanceof Utf8 ? (Utf8)this.state : null); + break; + + case 3: + this.country = in.readString(this.country instanceof Utf8 ? (Utf8)this.country : null); + break; + + case 4: + this.postalCode = in.readString(this.postalCode instanceof Utf8 ? (Utf8)this.postalCode : null); + break; + + default: + throw new java.io.IOException("Corrupt ResolvingDecoder."); + } + } + } + } +} + + + + + + + + + + diff --git a/src/main/java/io/skodjob/datagenerator/models/paymentfiat/Payee.java b/src/main/java/io/skodjob/datagenerator/models/paymentfiat/Payee.java new file mode 100644 index 0000000..3dec3cf --- /dev/null +++ b/src/main/java/io/skodjob/datagenerator/models/paymentfiat/Payee.java @@ -0,0 +1,694 @@ +/** + * Autogenerated by Avro + * + * DO NOT EDIT DIRECTLY + */ +package io.skodjob.datagenerator.models.paymentfiat; + +import org.apache.avro.specific.SpecificData; +import org.apache.avro.util.Utf8; +import org.apache.avro.message.BinaryMessageEncoder; +import org.apache.avro.message.BinaryMessageDecoder; +import org.apache.avro.message.SchemaStore; + +@org.apache.avro.specific.AvroGenerated +public class Payee extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord { + private static final long serialVersionUID = -4078330169720103566L; + + + public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"Payee\",\"namespace\":\"io.skodjob.datagenerator.models\",\"fields\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"payeeType\",\"type\":\"string\"},{\"name\":\"accountNumber\",\"type\":\"string\"},{\"name\":\"bank\",\"type\":\"string\"},{\"name\":\"address\",\"type\":{\"type\":\"record\",\"name\":\"Address\",\"fields\":[{\"name\":\"street\",\"type\":\"string\"},{\"name\":\"city\",\"type\":\"string\"},{\"name\":\"state\",\"type\":\"string\"},{\"name\":\"country\",\"type\":\"string\"},{\"name\":\"postalCode\",\"type\":\"string\"}]}}]}"); + public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } + + private static final SpecificData MODEL$ = new SpecificData(); + + private static final BinaryMessageEncoder ENCODER = + new BinaryMessageEncoder<>(MODEL$, SCHEMA$); + + private static final BinaryMessageDecoder DECODER = + new BinaryMessageDecoder<>(MODEL$, SCHEMA$); + + /** + * Return the BinaryMessageEncoder instance used by this class. + * @return the message encoder used by this class + */ + public static BinaryMessageEncoder getEncoder() { + return ENCODER; + } + + /** + * Return the BinaryMessageDecoder instance used by this class. + * @return the message decoder used by this class + */ + public static BinaryMessageDecoder getDecoder() { + return DECODER; + } + + /** + * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}. + * @param resolver a {@link SchemaStore} used to find schemas by fingerprint + * @return a BinaryMessageDecoder instance for this class backed by the given SchemaStore + */ + public static BinaryMessageDecoder createDecoder(SchemaStore resolver) { + return new BinaryMessageDecoder<>(MODEL$, SCHEMA$, resolver); + } + + /** + * Serializes this Payee to a ByteBuffer. + * @return a buffer holding the serialized data for this instance + * @throws java.io.IOException if this instance could not be serialized + */ + public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException { + return ENCODER.encode(this); + } + + /** + * Deserializes a Payee from a ByteBuffer. + * @param b a byte buffer holding serialized data for an instance of this class + * @return a Payee instance decoded from the given buffer + * @throws java.io.IOException if the given bytes could not be deserialized into an instance of this class + */ + public static Payee fromByteBuffer( + java.nio.ByteBuffer b) throws java.io.IOException { + return DECODER.decode(b); + } + + private java.lang.CharSequence name; + private java.lang.CharSequence payeeType; + private java.lang.CharSequence accountNumber; + private java.lang.CharSequence bank; + private Address address; + + /** + * Default constructor. Note that this does not initialize fields + * to their default values from the schema. If that is desired then + * one should use newBuilder(). + */ + public Payee() {} + + /** + * All-args constructor. + * @param name The new value for name + * @param payeeType The new value for payeeType + * @param accountNumber The new value for accountNumber + * @param bank The new value for bank + * @param address The new value for address + */ + public Payee(java.lang.CharSequence name, java.lang.CharSequence payeeType, java.lang.CharSequence accountNumber, java.lang.CharSequence bank, Address address) { + this.name = name; + this.payeeType = payeeType; + this.accountNumber = accountNumber; + this.bank = bank; + this.address = address; + } + + @Override + public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; } + + @Override + public org.apache.avro.Schema getSchema() { return SCHEMA$; } + + // Used by DatumWriter. Applications should not call. + @Override + public java.lang.Object get(int field$) { + switch (field$) { + case 0: return name; + case 1: return payeeType; + case 2: return accountNumber; + case 3: return bank; + case 4: return address; + default: throw new IndexOutOfBoundsException("Invalid index: " + field$); + } + } + + // Used by DatumReader. Applications should not call. + @Override + @SuppressWarnings(value="unchecked") + public void put(int field$, java.lang.Object value$) { + switch (field$) { + case 0: name = (java.lang.CharSequence)value$; break; + case 1: payeeType = (java.lang.CharSequence)value$; break; + case 2: accountNumber = (java.lang.CharSequence)value$; break; + case 3: bank = (java.lang.CharSequence)value$; break; + case 4: address = (Address)value$; break; + default: throw new IndexOutOfBoundsException("Invalid index: " + field$); + } + } + + /** + * Gets the value of the 'name' field. + * @return The value of the 'name' field. + */ + public java.lang.CharSequence getName() { + return name; + } + + + /** + * Sets the value of the 'name' field. + * @param value the value to set. + */ + public void setName(java.lang.CharSequence value) { + this.name = value; + } + + /** + * Gets the value of the 'payeeType' field. + * @return The value of the 'payeeType' field. + */ + public java.lang.CharSequence getPayeeType() { + return payeeType; + } + + + /** + * Sets the value of the 'payeeType' field. + * @param value the value to set. + */ + public void setPayeeType(java.lang.CharSequence value) { + this.payeeType = value; + } + + /** + * Gets the value of the 'accountNumber' field. + * @return The value of the 'accountNumber' field. + */ + public java.lang.CharSequence getAccountNumber() { + return accountNumber; + } + + + /** + * Sets the value of the 'accountNumber' field. + * @param value the value to set. + */ + public void setAccountNumber(java.lang.CharSequence value) { + this.accountNumber = value; + } + + /** + * Gets the value of the 'bank' field. + * @return The value of the 'bank' field. + */ + public java.lang.CharSequence getBank() { + return bank; + } + + + /** + * Sets the value of the 'bank' field. + * @param value the value to set. + */ + public void setBank(java.lang.CharSequence value) { + this.bank = value; + } + + /** + * Gets the value of the 'address' field. + * @return The value of the 'address' field. + */ + public Address getAddress() { + return address; + } + + + /** + * Sets the value of the 'address' field. + * @param value the value to set. + */ + public void setAddress(Address value) { + this.address = value; + } + + /** + * Creates a new Payee RecordBuilder. + * @return A new Payee RecordBuilder + */ + public static Payee.Builder newBuilder() { + return new Payee.Builder(); + } + + /** + * Creates a new Payee RecordBuilder by copying an existing Builder. + * @param other The existing builder to copy. + * @return A new Payee RecordBuilder + */ + public static Payee.Builder newBuilder(Payee.Builder other) { + if (other == null) { + return new Payee.Builder(); + } else { + return new Payee.Builder(other); + } + } + + /** + * Creates a new Payee RecordBuilder by copying an existing Payee instance. + * @param other The existing instance to copy. + * @return A new Payee RecordBuilder + */ + public static Payee.Builder newBuilder(Payee other) { + if (other == null) { + return new Payee.Builder(); + } else { + return new Payee.Builder(other); + } + } + + /** + * RecordBuilder for Payee instances. + */ + @org.apache.avro.specific.AvroGenerated + public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase + implements org.apache.avro.data.RecordBuilder { + + private java.lang.CharSequence name; + private java.lang.CharSequence payeeType; + private java.lang.CharSequence accountNumber; + private java.lang.CharSequence bank; + private Address address; + private Address.Builder addressBuilder; + + /** Creates a new Builder */ + private Builder() { + super(SCHEMA$, MODEL$); + } + + /** + * Creates a Builder by copying an existing Builder. + * @param other The existing Builder to copy. + */ + private Builder(Payee.Builder other) { + super(other); + if (isValidValue(fields()[0], other.name)) { + this.name = data().deepCopy(fields()[0].schema(), other.name); + fieldSetFlags()[0] = other.fieldSetFlags()[0]; + } + if (isValidValue(fields()[1], other.payeeType)) { + this.payeeType = data().deepCopy(fields()[1].schema(), other.payeeType); + fieldSetFlags()[1] = other.fieldSetFlags()[1]; + } + if (isValidValue(fields()[2], other.accountNumber)) { + this.accountNumber = data().deepCopy(fields()[2].schema(), other.accountNumber); + fieldSetFlags()[2] = other.fieldSetFlags()[2]; + } + if (isValidValue(fields()[3], other.bank)) { + this.bank = data().deepCopy(fields()[3].schema(), other.bank); + fieldSetFlags()[3] = other.fieldSetFlags()[3]; + } + if (isValidValue(fields()[4], other.address)) { + this.address = data().deepCopy(fields()[4].schema(), other.address); + fieldSetFlags()[4] = other.fieldSetFlags()[4]; + } + if (other.hasAddressBuilder()) { + this.addressBuilder = Address.newBuilder(other.getAddressBuilder()); + } + } + + /** + * Creates a Builder by copying an existing Payee instance + * @param other The existing instance to copy. + */ + private Builder(Payee other) { + super(SCHEMA$, MODEL$); + if (isValidValue(fields()[0], other.name)) { + this.name = data().deepCopy(fields()[0].schema(), other.name); + fieldSetFlags()[0] = true; + } + if (isValidValue(fields()[1], other.payeeType)) { + this.payeeType = data().deepCopy(fields()[1].schema(), other.payeeType); + fieldSetFlags()[1] = true; + } + if (isValidValue(fields()[2], other.accountNumber)) { + this.accountNumber = data().deepCopy(fields()[2].schema(), other.accountNumber); + fieldSetFlags()[2] = true; + } + if (isValidValue(fields()[3], other.bank)) { + this.bank = data().deepCopy(fields()[3].schema(), other.bank); + fieldSetFlags()[3] = true; + } + if (isValidValue(fields()[4], other.address)) { + this.address = data().deepCopy(fields()[4].schema(), other.address); + fieldSetFlags()[4] = true; + } + this.addressBuilder = null; + } + + /** + * Gets the value of the 'name' field. + * @return The value. + */ + public java.lang.CharSequence getName() { + return name; + } + + + /** + * Sets the value of the 'name' field. + * @param value The value of 'name'. + * @return This builder. + */ + public Payee.Builder setName(java.lang.CharSequence value) { + validate(fields()[0], value); + this.name = value; + fieldSetFlags()[0] = true; + return this; + } + + /** + * Checks whether the 'name' field has been set. + * @return True if the 'name' field has been set, false otherwise. + */ + public boolean hasName() { + return fieldSetFlags()[0]; + } + + + /** + * Clears the value of the 'name' field. + * @return This builder. + */ + public Payee.Builder clearName() { + name = null; + fieldSetFlags()[0] = false; + return this; + } + + /** + * Gets the value of the 'payeeType' field. + * @return The value. + */ + public java.lang.CharSequence getPayeeType() { + return payeeType; + } + + + /** + * Sets the value of the 'payeeType' field. + * @param value The value of 'payeeType'. + * @return This builder. + */ + public Payee.Builder setPayeeType(java.lang.CharSequence value) { + validate(fields()[1], value); + this.payeeType = value; + fieldSetFlags()[1] = true; + return this; + } + + /** + * Checks whether the 'payeeType' field has been set. + * @return True if the 'payeeType' field has been set, false otherwise. + */ + public boolean hasPayeeType() { + return fieldSetFlags()[1]; + } + + + /** + * Clears the value of the 'payeeType' field. + * @return This builder. + */ + public Payee.Builder clearPayeeType() { + payeeType = null; + fieldSetFlags()[1] = false; + return this; + } + + /** + * Gets the value of the 'accountNumber' field. + * @return The value. + */ + public java.lang.CharSequence getAccountNumber() { + return accountNumber; + } + + + /** + * Sets the value of the 'accountNumber' field. + * @param value The value of 'accountNumber'. + * @return This builder. + */ + public Payee.Builder setAccountNumber(java.lang.CharSequence value) { + validate(fields()[2], value); + this.accountNumber = value; + fieldSetFlags()[2] = true; + return this; + } + + /** + * Checks whether the 'accountNumber' field has been set. + * @return True if the 'accountNumber' field has been set, false otherwise. + */ + public boolean hasAccountNumber() { + return fieldSetFlags()[2]; + } + + + /** + * Clears the value of the 'accountNumber' field. + * @return This builder. + */ + public Payee.Builder clearAccountNumber() { + accountNumber = null; + fieldSetFlags()[2] = false; + return this; + } + + /** + * Gets the value of the 'bank' field. + * @return The value. + */ + public java.lang.CharSequence getBank() { + return bank; + } + + + /** + * Sets the value of the 'bank' field. + * @param value The value of 'bank'. + * @return This builder. + */ + public Payee.Builder setBank(java.lang.CharSequence value) { + validate(fields()[3], value); + this.bank = value; + fieldSetFlags()[3] = true; + return this; + } + + /** + * Checks whether the 'bank' field has been set. + * @return True if the 'bank' field has been set, false otherwise. + */ + public boolean hasBank() { + return fieldSetFlags()[3]; + } + + + /** + * Clears the value of the 'bank' field. + * @return This builder. + */ + public Payee.Builder clearBank() { + bank = null; + fieldSetFlags()[3] = false; + return this; + } + + /** + * Gets the value of the 'address' field. + * @return The value. + */ + public Address getAddress() { + return address; + } + + + /** + * Sets the value of the 'address' field. + * @param value The value of 'address'. + * @return This builder. + */ + public Payee.Builder setAddress(Address value) { + validate(fields()[4], value); + this.addressBuilder = null; + this.address = value; + fieldSetFlags()[4] = true; + return this; + } + + /** + * Checks whether the 'address' field has been set. + * @return True if the 'address' field has been set, false otherwise. + */ + public boolean hasAddress() { + return fieldSetFlags()[4]; + } + + /** + * Gets the Builder instance for the 'address' field and creates one if it doesn't exist yet. + * @return This builder. + */ + public Address.Builder getAddressBuilder() { + if (addressBuilder == null) { + if (hasAddress()) { + setAddressBuilder(Address.newBuilder(address)); + } else { + setAddressBuilder(Address.newBuilder()); + } + } + return addressBuilder; + } + + /** + * Sets the Builder instance for the 'address' field + * @param value The builder instance that must be set. + * @return This builder. + */ + + public Payee.Builder setAddressBuilder(Address.Builder value) { + clearAddress(); + addressBuilder = value; + return this; + } + + /** + * Checks whether the 'address' field has an active Builder instance + * @return True if the 'address' field has an active Builder instance + */ + public boolean hasAddressBuilder() { + return addressBuilder != null; + } + + /** + * Clears the value of the 'address' field. + * @return This builder. + */ + public Payee.Builder clearAddress() { + address = null; + addressBuilder = null; + fieldSetFlags()[4] = false; + return this; + } + + @Override + @SuppressWarnings("unchecked") + public Payee build() { + try { + Payee record = new Payee(); + record.name = fieldSetFlags()[0] ? this.name : (java.lang.CharSequence) defaultValue(fields()[0]); + record.payeeType = fieldSetFlags()[1] ? this.payeeType : (java.lang.CharSequence) defaultValue(fields()[1]); + record.accountNumber = fieldSetFlags()[2] ? this.accountNumber : (java.lang.CharSequence) defaultValue(fields()[2]); + record.bank = fieldSetFlags()[3] ? this.bank : (java.lang.CharSequence) defaultValue(fields()[3]); + if (addressBuilder != null) { + try { + record.address = this.addressBuilder.build(); + } catch (org.apache.avro.AvroMissingFieldException e) { + e.addParentField(record.getSchema().getField("address")); + throw e; + } + } else { + record.address = fieldSetFlags()[4] ? this.address : (Address) defaultValue(fields()[4]); + } + return record; + } catch (org.apache.avro.AvroMissingFieldException e) { + throw e; + } catch (java.lang.Exception e) { + throw new org.apache.avro.AvroRuntimeException(e); + } + } + } + + @SuppressWarnings("unchecked") + private static final org.apache.avro.io.DatumWriter + WRITER$ = (org.apache.avro.io.DatumWriter)MODEL$.createDatumWriter(SCHEMA$); + + @Override public void writeExternal(java.io.ObjectOutput out) + throws java.io.IOException { + WRITER$.write(this, SpecificData.getEncoder(out)); + } + + @SuppressWarnings("unchecked") + private static final org.apache.avro.io.DatumReader + READER$ = (org.apache.avro.io.DatumReader)MODEL$.createDatumReader(SCHEMA$); + + @Override public void readExternal(java.io.ObjectInput in) + throws java.io.IOException { + READER$.read(this, SpecificData.getDecoder(in)); + } + + @Override protected boolean hasCustomCoders() { return true; } + + @Override public void customEncode(org.apache.avro.io.Encoder out) + throws java.io.IOException + { + out.writeString(this.name); + + out.writeString(this.payeeType); + + out.writeString(this.accountNumber); + + out.writeString(this.bank); + + this.address.customEncode(out); + + } + + @Override public void customDecode(org.apache.avro.io.ResolvingDecoder in) + throws java.io.IOException + { + org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff(); + if (fieldOrder == null) { + this.name = in.readString(this.name instanceof Utf8 ? (Utf8)this.name : null); + + this.payeeType = in.readString(this.payeeType instanceof Utf8 ? (Utf8)this.payeeType : null); + + this.accountNumber = in.readString(this.accountNumber instanceof Utf8 ? (Utf8)this.accountNumber : null); + + this.bank = in.readString(this.bank instanceof Utf8 ? (Utf8)this.bank : null); + + if (this.address == null) { + this.address = new Address(); + } + this.address.customDecode(in); + + } else { + for (int i = 0; i < 5; i++) { + switch (fieldOrder[i].pos()) { + case 0: + this.name = in.readString(this.name instanceof Utf8 ? (Utf8)this.name : null); + break; + + case 1: + this.payeeType = in.readString(this.payeeType instanceof Utf8 ? (Utf8)this.payeeType : null); + break; + + case 2: + this.accountNumber = in.readString(this.accountNumber instanceof Utf8 ? (Utf8)this.accountNumber : null); + break; + + case 3: + this.bank = in.readString(this.bank instanceof Utf8 ? (Utf8)this.bank : null); + break; + + case 4: + if (this.address == null) { + this.address = new Address(); + } + this.address.customDecode(in); + break; + + default: + throw new java.io.IOException("Corrupt ResolvingDecoder."); + } + } + } + } +} + + + + + + + + + + diff --git a/src/main/java/io/skodjob/datagenerator/models/paymentfiat/Payer.java b/src/main/java/io/skodjob/datagenerator/models/paymentfiat/Payer.java new file mode 100644 index 0000000..373c6c9 --- /dev/null +++ b/src/main/java/io/skodjob/datagenerator/models/paymentfiat/Payer.java @@ -0,0 +1,983 @@ +/** + * Autogenerated by Avro + * + * DO NOT EDIT DIRECTLY + */ +package io.skodjob.datagenerator.models.paymentfiat; + +import org.apache.avro.generic.GenericArray; +import org.apache.avro.specific.SpecificData; +import org.apache.avro.util.Utf8; +import org.apache.avro.message.BinaryMessageEncoder; +import org.apache.avro.message.BinaryMessageDecoder; +import org.apache.avro.message.SchemaStore; + +@org.apache.avro.specific.AvroGenerated +public class Payer extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord { + private static final long serialVersionUID = 5810398614907498299L; + + + public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"Payer\",\"namespace\":\"io.skodjob.datagenerator.models.paymentfiat\",\"fields\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"payerType\",\"type\":\"string\"},{\"name\":\"accountNumber\",\"type\":\"string\"},{\"name\":\"bank\",\"type\":\"string\"},{\"name\":\"billingAddress\",\"type\":{\"type\":\"record\",\"name\":\"Address\",\"fields\":[{\"name\":\"street\",\"type\":\"string\"},{\"name\":\"city\",\"type\":\"string\"},{\"name\":\"state\",\"type\":\"string\"},{\"name\":\"country\",\"type\":\"string\"},{\"name\":\"postalCode\",\"type\":\"string\"}]}},{\"name\":\"cardNumber\",\"type\":[\"null\",\"string\"],\"default\":null},{\"name\":\"cardType\",\"type\":[\"null\",\"string\"],\"default\":null},{\"name\":\"expiryDate\",\"type\":[\"null\",\"string\"],\"default\":null}]}"); + public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } + + private static final SpecificData MODEL$ = new SpecificData(); + + private static final BinaryMessageEncoder ENCODER = + new BinaryMessageEncoder<>(MODEL$, SCHEMA$); + + private static final BinaryMessageDecoder DECODER = + new BinaryMessageDecoder<>(MODEL$, SCHEMA$); + + /** + * Return the BinaryMessageEncoder instance used by this class. + * @return the message encoder used by this class + */ + public static BinaryMessageEncoder getEncoder() { + return ENCODER; + } + + /** + * Return the BinaryMessageDecoder instance used by this class. + * @return the message decoder used by this class + */ + public static BinaryMessageDecoder getDecoder() { + return DECODER; + } + + /** + * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}. + * @param resolver a {@link SchemaStore} used to find schemas by fingerprint + * @return a BinaryMessageDecoder instance for this class backed by the given SchemaStore + */ + public static BinaryMessageDecoder createDecoder(SchemaStore resolver) { + return new BinaryMessageDecoder<>(MODEL$, SCHEMA$, resolver); + } + + /** + * Serializes this Payer to a ByteBuffer. + * @return a buffer holding the serialized data for this instance + * @throws java.io.IOException if this instance could not be serialized + */ + public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException { + return ENCODER.encode(this); + } + + /** + * Deserializes a Payer from a ByteBuffer. + * @param b a byte buffer holding serialized data for an instance of this class + * @return a Payer instance decoded from the given buffer + * @throws java.io.IOException if the given bytes could not be deserialized into an instance of this class + */ + public static Payer fromByteBuffer( + java.nio.ByteBuffer b) throws java.io.IOException { + return DECODER.decode(b); + } + + private java.lang.CharSequence name; + private java.lang.CharSequence payerType; + private java.lang.CharSequence accountNumber; + private java.lang.CharSequence bank; + private io.skodjob.datagenerator.models.paymentfiat.Address billingAddress; + private java.lang.CharSequence cardNumber; + private java.lang.CharSequence cardType; + private java.lang.CharSequence expiryDate; + + /** + * Default constructor. Note that this does not initialize fields + * to their default values from the schema. If that is desired then + * one should use newBuilder(). + */ + public Payer() {} + + /** + * All-args constructor. + * @param name The new value for name + * @param payerType The new value for payerType + * @param accountNumber The new value for accountNumber + * @param bank The new value for bank + * @param billingAddress The new value for billingAddress + * @param cardNumber The new value for cardNumber + * @param cardType The new value for cardType + * @param expiryDate The new value for expiryDate + */ + public Payer(java.lang.CharSequence name, java.lang.CharSequence payerType, java.lang.CharSequence accountNumber, java.lang.CharSequence bank, io.skodjob.datagenerator.models.paymentfiat.Address billingAddress, java.lang.CharSequence cardNumber, java.lang.CharSequence cardType, java.lang.CharSequence expiryDate) { + this.name = name; + this.payerType = payerType; + this.accountNumber = accountNumber; + this.bank = bank; + this.billingAddress = billingAddress; + this.cardNumber = cardNumber; + this.cardType = cardType; + this.expiryDate = expiryDate; + } + + @Override + public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; } + + @Override + public org.apache.avro.Schema getSchema() { return SCHEMA$; } + + // Used by DatumWriter. Applications should not call. + @Override + public java.lang.Object get(int field$) { + switch (field$) { + case 0: return name; + case 1: return payerType; + case 2: return accountNumber; + case 3: return bank; + case 4: return billingAddress; + case 5: return cardNumber; + case 6: return cardType; + case 7: return expiryDate; + default: throw new IndexOutOfBoundsException("Invalid index: " + field$); + } + } + + // Used by DatumReader. Applications should not call. + @Override + @SuppressWarnings(value="unchecked") + public void put(int field$, java.lang.Object value$) { + switch (field$) { + case 0: name = (java.lang.CharSequence)value$; break; + case 1: payerType = (java.lang.CharSequence)value$; break; + case 2: accountNumber = (java.lang.CharSequence)value$; break; + case 3: bank = (java.lang.CharSequence)value$; break; + case 4: billingAddress = (io.skodjob.datagenerator.models.paymentfiat.Address)value$; break; + case 5: cardNumber = (java.lang.CharSequence)value$; break; + case 6: cardType = (java.lang.CharSequence)value$; break; + case 7: expiryDate = (java.lang.CharSequence)value$; break; + default: throw new IndexOutOfBoundsException("Invalid index: " + field$); + } + } + + /** + * Gets the value of the 'name' field. + * @return The value of the 'name' field. + */ + public java.lang.CharSequence getName() { + return name; + } + + + /** + * Sets the value of the 'name' field. + * @param value the value to set. + */ + public void setName(java.lang.CharSequence value) { + this.name = value; + } + + /** + * Gets the value of the 'payerType' field. + * @return The value of the 'payerType' field. + */ + public java.lang.CharSequence getPayerType() { + return payerType; + } + + + /** + * Sets the value of the 'payerType' field. + * @param value the value to set. + */ + public void setPayerType(java.lang.CharSequence value) { + this.payerType = value; + } + + /** + * Gets the value of the 'accountNumber' field. + * @return The value of the 'accountNumber' field. + */ + public java.lang.CharSequence getAccountNumber() { + return accountNumber; + } + + + /** + * Sets the value of the 'accountNumber' field. + * @param value the value to set. + */ + public void setAccountNumber(java.lang.CharSequence value) { + this.accountNumber = value; + } + + /** + * Gets the value of the 'bank' field. + * @return The value of the 'bank' field. + */ + public java.lang.CharSequence getBank() { + return bank; + } + + + /** + * Sets the value of the 'bank' field. + * @param value the value to set. + */ + public void setBank(java.lang.CharSequence value) { + this.bank = value; + } + + /** + * Gets the value of the 'billingAddress' field. + * @return The value of the 'billingAddress' field. + */ + public io.skodjob.datagenerator.models.paymentfiat.Address getBillingAddress() { + return billingAddress; + } + + + /** + * Sets the value of the 'billingAddress' field. + * @param value the value to set. + */ + public void setBillingAddress(io.skodjob.datagenerator.models.paymentfiat.Address value) { + this.billingAddress = value; + } + + /** + * Gets the value of the 'cardNumber' field. + * @return The value of the 'cardNumber' field. + */ + public java.lang.CharSequence getCardNumber() { + return cardNumber; + } + + + /** + * Sets the value of the 'cardNumber' field. + * @param value the value to set. + */ + public void setCardNumber(java.lang.CharSequence value) { + this.cardNumber = value; + } + + /** + * Gets the value of the 'cardType' field. + * @return The value of the 'cardType' field. + */ + public java.lang.CharSequence getCardType() { + return cardType; + } + + + /** + * Sets the value of the 'cardType' field. + * @param value the value to set. + */ + public void setCardType(java.lang.CharSequence value) { + this.cardType = value; + } + + /** + * Gets the value of the 'expiryDate' field. + * @return The value of the 'expiryDate' field. + */ + public java.lang.CharSequence getExpiryDate() { + return expiryDate; + } + + + /** + * Sets the value of the 'expiryDate' field. + * @param value the value to set. + */ + public void setExpiryDate(java.lang.CharSequence value) { + this.expiryDate = value; + } + + /** + * Creates a new Payer RecordBuilder. + * @return A new Payer RecordBuilder + */ + public static io.skodjob.datagenerator.models.paymentfiat.Payer.Builder newBuilder() { + return new io.skodjob.datagenerator.models.paymentfiat.Payer.Builder(); + } + + /** + * Creates a new Payer RecordBuilder by copying an existing Builder. + * @param other The existing builder to copy. + * @return A new Payer RecordBuilder + */ + public static io.skodjob.datagenerator.models.paymentfiat.Payer.Builder newBuilder(io.skodjob.datagenerator.models.paymentfiat.Payer.Builder other) { + if (other == null) { + return new io.skodjob.datagenerator.models.paymentfiat.Payer.Builder(); + } else { + return new io.skodjob.datagenerator.models.paymentfiat.Payer.Builder(other); + } + } + + /** + * Creates a new Payer RecordBuilder by copying an existing Payer instance. + * @param other The existing instance to copy. + * @return A new Payer RecordBuilder + */ + public static io.skodjob.datagenerator.models.paymentfiat.Payer.Builder newBuilder(io.skodjob.datagenerator.models.paymentfiat.Payer other) { + if (other == null) { + return new io.skodjob.datagenerator.models.paymentfiat.Payer.Builder(); + } else { + return new io.skodjob.datagenerator.models.paymentfiat.Payer.Builder(other); + } + } + + /** + * RecordBuilder for Payer instances. + */ + @org.apache.avro.specific.AvroGenerated + public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase + implements org.apache.avro.data.RecordBuilder { + + private java.lang.CharSequence name; + private java.lang.CharSequence payerType; + private java.lang.CharSequence accountNumber; + private java.lang.CharSequence bank; + private io.skodjob.datagenerator.models.paymentfiat.Address billingAddress; + private io.skodjob.datagenerator.models.paymentfiat.Address.Builder billingAddressBuilder; + private java.lang.CharSequence cardNumber; + private java.lang.CharSequence cardType; + private java.lang.CharSequence expiryDate; + + /** Creates a new Builder */ + private Builder() { + super(SCHEMA$, MODEL$); + } + + /** + * Creates a Builder by copying an existing Builder. + * @param other The existing Builder to copy. + */ + private Builder(io.skodjob.datagenerator.models.paymentfiat.Payer.Builder other) { + super(other); + if (isValidValue(fields()[0], other.name)) { + this.name = data().deepCopy(fields()[0].schema(), other.name); + fieldSetFlags()[0] = other.fieldSetFlags()[0]; + } + if (isValidValue(fields()[1], other.payerType)) { + this.payerType = data().deepCopy(fields()[1].schema(), other.payerType); + fieldSetFlags()[1] = other.fieldSetFlags()[1]; + } + if (isValidValue(fields()[2], other.accountNumber)) { + this.accountNumber = data().deepCopy(fields()[2].schema(), other.accountNumber); + fieldSetFlags()[2] = other.fieldSetFlags()[2]; + } + if (isValidValue(fields()[3], other.bank)) { + this.bank = data().deepCopy(fields()[3].schema(), other.bank); + fieldSetFlags()[3] = other.fieldSetFlags()[3]; + } + if (isValidValue(fields()[4], other.billingAddress)) { + this.billingAddress = data().deepCopy(fields()[4].schema(), other.billingAddress); + fieldSetFlags()[4] = other.fieldSetFlags()[4]; + } + if (other.hasBillingAddressBuilder()) { + this.billingAddressBuilder = io.skodjob.datagenerator.models.paymentfiat.Address.newBuilder(other.getBillingAddressBuilder()); + } + if (isValidValue(fields()[5], other.cardNumber)) { + this.cardNumber = data().deepCopy(fields()[5].schema(), other.cardNumber); + fieldSetFlags()[5] = other.fieldSetFlags()[5]; + } + if (isValidValue(fields()[6], other.cardType)) { + this.cardType = data().deepCopy(fields()[6].schema(), other.cardType); + fieldSetFlags()[6] = other.fieldSetFlags()[6]; + } + if (isValidValue(fields()[7], other.expiryDate)) { + this.expiryDate = data().deepCopy(fields()[7].schema(), other.expiryDate); + fieldSetFlags()[7] = other.fieldSetFlags()[7]; + } + } + + /** + * Creates a Builder by copying an existing Payer instance + * @param other The existing instance to copy. + */ + private Builder(io.skodjob.datagenerator.models.paymentfiat.Payer other) { + super(SCHEMA$, MODEL$); + if (isValidValue(fields()[0], other.name)) { + this.name = data().deepCopy(fields()[0].schema(), other.name); + fieldSetFlags()[0] = true; + } + if (isValidValue(fields()[1], other.payerType)) { + this.payerType = data().deepCopy(fields()[1].schema(), other.payerType); + fieldSetFlags()[1] = true; + } + if (isValidValue(fields()[2], other.accountNumber)) { + this.accountNumber = data().deepCopy(fields()[2].schema(), other.accountNumber); + fieldSetFlags()[2] = true; + } + if (isValidValue(fields()[3], other.bank)) { + this.bank = data().deepCopy(fields()[3].schema(), other.bank); + fieldSetFlags()[3] = true; + } + if (isValidValue(fields()[4], other.billingAddress)) { + this.billingAddress = data().deepCopy(fields()[4].schema(), other.billingAddress); + fieldSetFlags()[4] = true; + } + this.billingAddressBuilder = null; + if (isValidValue(fields()[5], other.cardNumber)) { + this.cardNumber = data().deepCopy(fields()[5].schema(), other.cardNumber); + fieldSetFlags()[5] = true; + } + if (isValidValue(fields()[6], other.cardType)) { + this.cardType = data().deepCopy(fields()[6].schema(), other.cardType); + fieldSetFlags()[6] = true; + } + if (isValidValue(fields()[7], other.expiryDate)) { + this.expiryDate = data().deepCopy(fields()[7].schema(), other.expiryDate); + fieldSetFlags()[7] = true; + } + } + + /** + * Gets the value of the 'name' field. + * @return The value. + */ + public java.lang.CharSequence getName() { + return name; + } + + + /** + * Sets the value of the 'name' field. + * @param value The value of 'name'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.paymentfiat.Payer.Builder setName(java.lang.CharSequence value) { + validate(fields()[0], value); + this.name = value; + fieldSetFlags()[0] = true; + return this; + } + + /** + * Checks whether the 'name' field has been set. + * @return True if the 'name' field has been set, false otherwise. + */ + public boolean hasName() { + return fieldSetFlags()[0]; + } + + + /** + * Clears the value of the 'name' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.paymentfiat.Payer.Builder clearName() { + name = null; + fieldSetFlags()[0] = false; + return this; + } + + /** + * Gets the value of the 'payerType' field. + * @return The value. + */ + public java.lang.CharSequence getPayerType() { + return payerType; + } + + + /** + * Sets the value of the 'payerType' field. + * @param value The value of 'payerType'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.paymentfiat.Payer.Builder setPayerType(java.lang.CharSequence value) { + validate(fields()[1], value); + this.payerType = value; + fieldSetFlags()[1] = true; + return this; + } + + /** + * Checks whether the 'payerType' field has been set. + * @return True if the 'payerType' field has been set, false otherwise. + */ + public boolean hasPayerType() { + return fieldSetFlags()[1]; + } + + + /** + * Clears the value of the 'payerType' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.paymentfiat.Payer.Builder clearPayerType() { + payerType = null; + fieldSetFlags()[1] = false; + return this; + } + + /** + * Gets the value of the 'accountNumber' field. + * @return The value. + */ + public java.lang.CharSequence getAccountNumber() { + return accountNumber; + } + + + /** + * Sets the value of the 'accountNumber' field. + * @param value The value of 'accountNumber'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.paymentfiat.Payer.Builder setAccountNumber(java.lang.CharSequence value) { + validate(fields()[2], value); + this.accountNumber = value; + fieldSetFlags()[2] = true; + return this; + } + + /** + * Checks whether the 'accountNumber' field has been set. + * @return True if the 'accountNumber' field has been set, false otherwise. + */ + public boolean hasAccountNumber() { + return fieldSetFlags()[2]; + } + + + /** + * Clears the value of the 'accountNumber' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.paymentfiat.Payer.Builder clearAccountNumber() { + accountNumber = null; + fieldSetFlags()[2] = false; + return this; + } + + /** + * Gets the value of the 'bank' field. + * @return The value. + */ + public java.lang.CharSequence getBank() { + return bank; + } + + + /** + * Sets the value of the 'bank' field. + * @param value The value of 'bank'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.paymentfiat.Payer.Builder setBank(java.lang.CharSequence value) { + validate(fields()[3], value); + this.bank = value; + fieldSetFlags()[3] = true; + return this; + } + + /** + * Checks whether the 'bank' field has been set. + * @return True if the 'bank' field has been set, false otherwise. + */ + public boolean hasBank() { + return fieldSetFlags()[3]; + } + + + /** + * Clears the value of the 'bank' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.paymentfiat.Payer.Builder clearBank() { + bank = null; + fieldSetFlags()[3] = false; + return this; + } + + /** + * Gets the value of the 'billingAddress' field. + * @return The value. + */ + public io.skodjob.datagenerator.models.paymentfiat.Address getBillingAddress() { + return billingAddress; + } + + + /** + * Sets the value of the 'billingAddress' field. + * @param value The value of 'billingAddress'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.paymentfiat.Payer.Builder setBillingAddress(io.skodjob.datagenerator.models.paymentfiat.Address value) { + validate(fields()[4], value); + this.billingAddressBuilder = null; + this.billingAddress = value; + fieldSetFlags()[4] = true; + return this; + } + + /** + * Checks whether the 'billingAddress' field has been set. + * @return True if the 'billingAddress' field has been set, false otherwise. + */ + public boolean hasBillingAddress() { + return fieldSetFlags()[4]; + } + + /** + * Gets the Builder instance for the 'billingAddress' field and creates one if it doesn't exist yet. + * @return This builder. + */ + public io.skodjob.datagenerator.models.paymentfiat.Address.Builder getBillingAddressBuilder() { + if (billingAddressBuilder == null) { + if (hasBillingAddress()) { + setBillingAddressBuilder(io.skodjob.datagenerator.models.paymentfiat.Address.newBuilder(billingAddress)); + } else { + setBillingAddressBuilder(io.skodjob.datagenerator.models.paymentfiat.Address.newBuilder()); + } + } + return billingAddressBuilder; + } + + /** + * Sets the Builder instance for the 'billingAddress' field + * @param value The builder instance that must be set. + * @return This builder. + */ + + public io.skodjob.datagenerator.models.paymentfiat.Payer.Builder setBillingAddressBuilder(io.skodjob.datagenerator.models.paymentfiat.Address.Builder value) { + clearBillingAddress(); + billingAddressBuilder = value; + return this; + } + + /** + * Checks whether the 'billingAddress' field has an active Builder instance + * @return True if the 'billingAddress' field has an active Builder instance + */ + public boolean hasBillingAddressBuilder() { + return billingAddressBuilder != null; + } + + /** + * Clears the value of the 'billingAddress' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.paymentfiat.Payer.Builder clearBillingAddress() { + billingAddress = null; + billingAddressBuilder = null; + fieldSetFlags()[4] = false; + return this; + } + + /** + * Gets the value of the 'cardNumber' field. + * @return The value. + */ + public java.lang.CharSequence getCardNumber() { + return cardNumber; + } + + + /** + * Sets the value of the 'cardNumber' field. + * @param value The value of 'cardNumber'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.paymentfiat.Payer.Builder setCardNumber(java.lang.CharSequence value) { + validate(fields()[5], value); + this.cardNumber = value; + fieldSetFlags()[5] = true; + return this; + } + + /** + * Checks whether the 'cardNumber' field has been set. + * @return True if the 'cardNumber' field has been set, false otherwise. + */ + public boolean hasCardNumber() { + return fieldSetFlags()[5]; + } + + + /** + * Clears the value of the 'cardNumber' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.paymentfiat.Payer.Builder clearCardNumber() { + cardNumber = null; + fieldSetFlags()[5] = false; + return this; + } + + /** + * Gets the value of the 'cardType' field. + * @return The value. + */ + public java.lang.CharSequence getCardType() { + return cardType; + } + + + /** + * Sets the value of the 'cardType' field. + * @param value The value of 'cardType'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.paymentfiat.Payer.Builder setCardType(java.lang.CharSequence value) { + validate(fields()[6], value); + this.cardType = value; + fieldSetFlags()[6] = true; + return this; + } + + /** + * Checks whether the 'cardType' field has been set. + * @return True if the 'cardType' field has been set, false otherwise. + */ + public boolean hasCardType() { + return fieldSetFlags()[6]; + } + + + /** + * Clears the value of the 'cardType' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.paymentfiat.Payer.Builder clearCardType() { + cardType = null; + fieldSetFlags()[6] = false; + return this; + } + + /** + * Gets the value of the 'expiryDate' field. + * @return The value. + */ + public java.lang.CharSequence getExpiryDate() { + return expiryDate; + } + + + /** + * Sets the value of the 'expiryDate' field. + * @param value The value of 'expiryDate'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.paymentfiat.Payer.Builder setExpiryDate(java.lang.CharSequence value) { + validate(fields()[7], value); + this.expiryDate = value; + fieldSetFlags()[7] = true; + return this; + } + + /** + * Checks whether the 'expiryDate' field has been set. + * @return True if the 'expiryDate' field has been set, false otherwise. + */ + public boolean hasExpiryDate() { + return fieldSetFlags()[7]; + } + + + /** + * Clears the value of the 'expiryDate' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.paymentfiat.Payer.Builder clearExpiryDate() { + expiryDate = null; + fieldSetFlags()[7] = false; + return this; + } + + @Override + @SuppressWarnings("unchecked") + public Payer build() { + try { + Payer record = new Payer(); + record.name = fieldSetFlags()[0] ? this.name : (java.lang.CharSequence) defaultValue(fields()[0]); + record.payerType = fieldSetFlags()[1] ? this.payerType : (java.lang.CharSequence) defaultValue(fields()[1]); + record.accountNumber = fieldSetFlags()[2] ? this.accountNumber : (java.lang.CharSequence) defaultValue(fields()[2]); + record.bank = fieldSetFlags()[3] ? this.bank : (java.lang.CharSequence) defaultValue(fields()[3]); + if (billingAddressBuilder != null) { + try { + record.billingAddress = this.billingAddressBuilder.build(); + } catch (org.apache.avro.AvroMissingFieldException e) { + e.addParentField(record.getSchema().getField("billingAddress")); + throw e; + } + } else { + record.billingAddress = fieldSetFlags()[4] ? this.billingAddress : (io.skodjob.datagenerator.models.paymentfiat.Address) defaultValue(fields()[4]); + } + record.cardNumber = fieldSetFlags()[5] ? this.cardNumber : (java.lang.CharSequence) defaultValue(fields()[5]); + record.cardType = fieldSetFlags()[6] ? this.cardType : (java.lang.CharSequence) defaultValue(fields()[6]); + record.expiryDate = fieldSetFlags()[7] ? this.expiryDate : (java.lang.CharSequence) defaultValue(fields()[7]); + return record; + } catch (org.apache.avro.AvroMissingFieldException e) { + throw e; + } catch (java.lang.Exception e) { + throw new org.apache.avro.AvroRuntimeException(e); + } + } + } + + @SuppressWarnings("unchecked") + private static final org.apache.avro.io.DatumWriter + WRITER$ = (org.apache.avro.io.DatumWriter)MODEL$.createDatumWriter(SCHEMA$); + + @Override public void writeExternal(java.io.ObjectOutput out) + throws java.io.IOException { + WRITER$.write(this, SpecificData.getEncoder(out)); + } + + @SuppressWarnings("unchecked") + private static final org.apache.avro.io.DatumReader + READER$ = (org.apache.avro.io.DatumReader)MODEL$.createDatumReader(SCHEMA$); + + @Override public void readExternal(java.io.ObjectInput in) + throws java.io.IOException { + READER$.read(this, SpecificData.getDecoder(in)); + } + + @Override protected boolean hasCustomCoders() { return true; } + + @Override public void customEncode(org.apache.avro.io.Encoder out) + throws java.io.IOException + { + out.writeString(this.name); + + out.writeString(this.payerType); + + out.writeString(this.accountNumber); + + out.writeString(this.bank); + + this.billingAddress.customEncode(out); + + if (this.cardNumber == null) { + out.writeIndex(0); + out.writeNull(); + } else { + out.writeIndex(1); + out.writeString(this.cardNumber); + } + + if (this.cardType == null) { + out.writeIndex(0); + out.writeNull(); + } else { + out.writeIndex(1); + out.writeString(this.cardType); + } + + if (this.expiryDate == null) { + out.writeIndex(0); + out.writeNull(); + } else { + out.writeIndex(1); + out.writeString(this.expiryDate); + } + + } + + @Override public void customDecode(org.apache.avro.io.ResolvingDecoder in) + throws java.io.IOException + { + org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff(); + if (fieldOrder == null) { + this.name = in.readString(this.name instanceof Utf8 ? (Utf8)this.name : null); + + this.payerType = in.readString(this.payerType instanceof Utf8 ? (Utf8)this.payerType : null); + + this.accountNumber = in.readString(this.accountNumber instanceof Utf8 ? (Utf8)this.accountNumber : null); + + this.bank = in.readString(this.bank instanceof Utf8 ? (Utf8)this.bank : null); + + if (this.billingAddress == null) { + this.billingAddress = new io.skodjob.datagenerator.models.paymentfiat.Address(); + } + this.billingAddress.customDecode(in); + + if (in.readIndex() != 1) { + in.readNull(); + this.cardNumber = null; + } else { + this.cardNumber = in.readString(this.cardNumber instanceof Utf8 ? (Utf8)this.cardNumber : null); + } + + if (in.readIndex() != 1) { + in.readNull(); + this.cardType = null; + } else { + this.cardType = in.readString(this.cardType instanceof Utf8 ? (Utf8)this.cardType : null); + } + + if (in.readIndex() != 1) { + in.readNull(); + this.expiryDate = null; + } else { + this.expiryDate = in.readString(this.expiryDate instanceof Utf8 ? (Utf8)this.expiryDate : null); + } + + } else { + for (int i = 0; i < 8; i++) { + switch (fieldOrder[i].pos()) { + case 0: + this.name = in.readString(this.name instanceof Utf8 ? (Utf8)this.name : null); + break; + + case 1: + this.payerType = in.readString(this.payerType instanceof Utf8 ? (Utf8)this.payerType : null); + break; + + case 2: + this.accountNumber = in.readString(this.accountNumber instanceof Utf8 ? (Utf8)this.accountNumber : null); + break; + + case 3: + this.bank = in.readString(this.bank instanceof Utf8 ? (Utf8)this.bank : null); + break; + + case 4: + if (this.billingAddress == null) { + this.billingAddress = new io.skodjob.datagenerator.models.paymentfiat.Address(); + } + this.billingAddress.customDecode(in); + break; + + case 5: + if (in.readIndex() != 1) { + in.readNull(); + this.cardNumber = null; + } else { + this.cardNumber = in.readString(this.cardNumber instanceof Utf8 ? (Utf8)this.cardNumber : null); + } + break; + + case 6: + if (in.readIndex() != 1) { + in.readNull(); + this.cardType = null; + } else { + this.cardType = in.readString(this.cardType instanceof Utf8 ? (Utf8)this.cardType : null); + } + break; + + case 7: + if (in.readIndex() != 1) { + in.readNull(); + this.expiryDate = null; + } else { + this.expiryDate = in.readString(this.expiryDate instanceof Utf8 ? (Utf8)this.expiryDate : null); + } + break; + + default: + throw new java.io.IOException("Corrupt ResolvingDecoder."); + } + } + } + } +} + + + + + + + + + + diff --git a/src/main/java/io/skodjob/datagenerator/models/paymentfiat/Payment.java b/src/main/java/io/skodjob/datagenerator/models/paymentfiat/Payment.java new file mode 100644 index 0000000..3904239 --- /dev/null +++ b/src/main/java/io/skodjob/datagenerator/models/paymentfiat/Payment.java @@ -0,0 +1,717 @@ +/** + * Autogenerated by Avro + * + * DO NOT EDIT DIRECTLY + */ +package io.skodjob.datagenerator.models.paymentfiat; + +import org.apache.avro.specific.SpecificData; +import org.apache.avro.util.Utf8; +import org.apache.avro.message.BinaryMessageEncoder; +import org.apache.avro.message.BinaryMessageDecoder; +import org.apache.avro.message.SchemaStore; + +@org.apache.avro.specific.AvroGenerated +public class Payment extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord { + private static final long serialVersionUID = 12828759078550806L; + + + public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"Payment\",\"namespace\":\"io.skodjob.datagenerator.models\",\"fields\":[{\"name\":\"transactionId\",\"type\":\"string\"},{\"name\":\"type\",\"type\":\"string\"},{\"name\":\"amount\",\"type\":\"double\"},{\"name\":\"currency\",\"type\":\"string\"},{\"name\":\"date\",\"type\":\"string\"},{\"name\":\"status\",\"type\":\"string\"}]}"); + public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } + + private static final SpecificData MODEL$ = new SpecificData(); + + private static final BinaryMessageEncoder ENCODER = + new BinaryMessageEncoder<>(MODEL$, SCHEMA$); + + private static final BinaryMessageDecoder DECODER = + new BinaryMessageDecoder<>(MODEL$, SCHEMA$); + + /** + * Return the BinaryMessageEncoder instance used by this class. + * @return the message encoder used by this class + */ + public static BinaryMessageEncoder getEncoder() { + return ENCODER; + } + + /** + * Return the BinaryMessageDecoder instance used by this class. + * @return the message decoder used by this class + */ + public static BinaryMessageDecoder getDecoder() { + return DECODER; + } + + /** + * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}. + * @param resolver a {@link SchemaStore} used to find schemas by fingerprint + * @return a BinaryMessageDecoder instance for this class backed by the given SchemaStore + */ + public static BinaryMessageDecoder createDecoder(SchemaStore resolver) { + return new BinaryMessageDecoder<>(MODEL$, SCHEMA$, resolver); + } + + /** + * Serializes this Payment to a ByteBuffer. + * @return a buffer holding the serialized data for this instance + * @throws java.io.IOException if this instance could not be serialized + */ + public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException { + return ENCODER.encode(this); + } + + /** + * Deserializes a Payment from a ByteBuffer. + * @param b a byte buffer holding serialized data for an instance of this class + * @return a Payment instance decoded from the given buffer + * @throws java.io.IOException if the given bytes could not be deserialized into an instance of this class + */ + public static Payment fromByteBuffer( + java.nio.ByteBuffer b) throws java.io.IOException { + return DECODER.decode(b); + } + + private java.lang.CharSequence transactionId; + private java.lang.CharSequence type; + private double amount; + private java.lang.CharSequence currency; + private java.lang.CharSequence date; + private java.lang.CharSequence status; + + /** + * Default constructor. Note that this does not initialize fields + * to their default values from the schema. If that is desired then + * one should use newBuilder(). + */ + public Payment() {} + + /** + * All-args constructor. + * @param transactionId The new value for transactionId + * @param type The new value for type + * @param amount The new value for amount + * @param currency The new value for currency + * @param date The new value for date + * @param status The new value for status + */ + public Payment(java.lang.CharSequence transactionId, java.lang.CharSequence type, java.lang.Double amount, java.lang.CharSequence currency, java.lang.CharSequence date, java.lang.CharSequence status) { + this.transactionId = transactionId; + this.type = type; + this.amount = amount; + this.currency = currency; + this.date = date; + this.status = status; + } + + @Override + public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; } + + @Override + public org.apache.avro.Schema getSchema() { return SCHEMA$; } + + // Used by DatumWriter. Applications should not call. + @Override + public java.lang.Object get(int field$) { + switch (field$) { + case 0: return transactionId; + case 1: return type; + case 2: return amount; + case 3: return currency; + case 4: return date; + case 5: return status; + default: throw new IndexOutOfBoundsException("Invalid index: " + field$); + } + } + + // Used by DatumReader. Applications should not call. + @Override + @SuppressWarnings(value="unchecked") + public void put(int field$, java.lang.Object value$) { + switch (field$) { + case 0: transactionId = (java.lang.CharSequence)value$; break; + case 1: type = (java.lang.CharSequence)value$; break; + case 2: amount = (java.lang.Double)value$; break; + case 3: currency = (java.lang.CharSequence)value$; break; + case 4: date = (java.lang.CharSequence)value$; break; + case 5: status = (java.lang.CharSequence)value$; break; + default: throw new IndexOutOfBoundsException("Invalid index: " + field$); + } + } + + /** + * Gets the value of the 'transactionId' field. + * @return The value of the 'transactionId' field. + */ + public java.lang.CharSequence getTransactionId() { + return transactionId; + } + + + /** + * Sets the value of the 'transactionId' field. + * @param value the value to set. + */ + public void setTransactionId(java.lang.CharSequence value) { + this.transactionId = value; + } + + /** + * Gets the value of the 'type' field. + * @return The value of the 'type' field. + */ + public java.lang.CharSequence getType() { + return type; + } + + + /** + * Sets the value of the 'type' field. + * @param value the value to set. + */ + public void setType(java.lang.CharSequence value) { + this.type = value; + } + + /** + * Gets the value of the 'amount' field. + * @return The value of the 'amount' field. + */ + public double getAmount() { + return amount; + } + + + /** + * Sets the value of the 'amount' field. + * @param value the value to set. + */ + public void setAmount(double value) { + this.amount = value; + } + + /** + * Gets the value of the 'currency' field. + * @return The value of the 'currency' field. + */ + public java.lang.CharSequence getCurrency() { + return currency; + } + + + /** + * Sets the value of the 'currency' field. + * @param value the value to set. + */ + public void setCurrency(java.lang.CharSequence value) { + this.currency = value; + } + + /** + * Gets the value of the 'date' field. + * @return The value of the 'date' field. + */ + public java.lang.CharSequence getDate() { + return date; + } + + + /** + * Sets the value of the 'date' field. + * @param value the value to set. + */ + public void setDate(java.lang.CharSequence value) { + this.date = value; + } + + /** + * Gets the value of the 'status' field. + * @return The value of the 'status' field. + */ + public java.lang.CharSequence getStatus() { + return status; + } + + + /** + * Sets the value of the 'status' field. + * @param value the value to set. + */ + public void setStatus(java.lang.CharSequence value) { + this.status = value; + } + + /** + * Creates a new Payment RecordBuilder. + * @return A new Payment RecordBuilder + */ + public static Payment.Builder newBuilder() { + return new Payment.Builder(); + } + + /** + * Creates a new Payment RecordBuilder by copying an existing Builder. + * @param other The existing builder to copy. + * @return A new Payment RecordBuilder + */ + public static Payment.Builder newBuilder(Payment.Builder other) { + if (other == null) { + return new Payment.Builder(); + } else { + return new Payment.Builder(other); + } + } + + /** + * Creates a new Payment RecordBuilder by copying an existing Payment instance. + * @param other The existing instance to copy. + * @return A new Payment RecordBuilder + */ + public static Payment.Builder newBuilder(Payment other) { + if (other == null) { + return new Payment.Builder(); + } else { + return new Payment.Builder(other); + } + } + + /** + * RecordBuilder for Payment instances. + */ + @org.apache.avro.specific.AvroGenerated + public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase + implements org.apache.avro.data.RecordBuilder { + + private java.lang.CharSequence transactionId; + private java.lang.CharSequence type; + private double amount; + private java.lang.CharSequence currency; + private java.lang.CharSequence date; + private java.lang.CharSequence status; + + /** Creates a new Builder */ + private Builder() { + super(SCHEMA$, MODEL$); + } + + /** + * Creates a Builder by copying an existing Builder. + * @param other The existing Builder to copy. + */ + private Builder(Payment.Builder other) { + super(other); + if (isValidValue(fields()[0], other.transactionId)) { + this.transactionId = data().deepCopy(fields()[0].schema(), other.transactionId); + fieldSetFlags()[0] = other.fieldSetFlags()[0]; + } + if (isValidValue(fields()[1], other.type)) { + this.type = data().deepCopy(fields()[1].schema(), other.type); + fieldSetFlags()[1] = other.fieldSetFlags()[1]; + } + if (isValidValue(fields()[2], other.amount)) { + this.amount = data().deepCopy(fields()[2].schema(), other.amount); + fieldSetFlags()[2] = other.fieldSetFlags()[2]; + } + if (isValidValue(fields()[3], other.currency)) { + this.currency = data().deepCopy(fields()[3].schema(), other.currency); + fieldSetFlags()[3] = other.fieldSetFlags()[3]; + } + if (isValidValue(fields()[4], other.date)) { + this.date = data().deepCopy(fields()[4].schema(), other.date); + fieldSetFlags()[4] = other.fieldSetFlags()[4]; + } + if (isValidValue(fields()[5], other.status)) { + this.status = data().deepCopy(fields()[5].schema(), other.status); + fieldSetFlags()[5] = other.fieldSetFlags()[5]; + } + } + + /** + * Creates a Builder by copying an existing Payment instance + * @param other The existing instance to copy. + */ + private Builder(Payment other) { + super(SCHEMA$, MODEL$); + if (isValidValue(fields()[0], other.transactionId)) { + this.transactionId = data().deepCopy(fields()[0].schema(), other.transactionId); + fieldSetFlags()[0] = true; + } + if (isValidValue(fields()[1], other.type)) { + this.type = data().deepCopy(fields()[1].schema(), other.type); + fieldSetFlags()[1] = true; + } + if (isValidValue(fields()[2], other.amount)) { + this.amount = data().deepCopy(fields()[2].schema(), other.amount); + fieldSetFlags()[2] = true; + } + if (isValidValue(fields()[3], other.currency)) { + this.currency = data().deepCopy(fields()[3].schema(), other.currency); + fieldSetFlags()[3] = true; + } + if (isValidValue(fields()[4], other.date)) { + this.date = data().deepCopy(fields()[4].schema(), other.date); + fieldSetFlags()[4] = true; + } + if (isValidValue(fields()[5], other.status)) { + this.status = data().deepCopy(fields()[5].schema(), other.status); + fieldSetFlags()[5] = true; + } + } + + /** + * Gets the value of the 'transactionId' field. + * @return The value. + */ + public java.lang.CharSequence getTransactionId() { + return transactionId; + } + + + /** + * Sets the value of the 'transactionId' field. + * @param value The value of 'transactionId'. + * @return This builder. + */ + public Payment.Builder setTransactionId(java.lang.CharSequence value) { + validate(fields()[0], value); + this.transactionId = value; + fieldSetFlags()[0] = true; + return this; + } + + /** + * Checks whether the 'transactionId' field has been set. + * @return True if the 'transactionId' field has been set, false otherwise. + */ + public boolean hasTransactionId() { + return fieldSetFlags()[0]; + } + + + /** + * Clears the value of the 'transactionId' field. + * @return This builder. + */ + public Payment.Builder clearTransactionId() { + transactionId = null; + fieldSetFlags()[0] = false; + return this; + } + + /** + * Gets the value of the 'type' field. + * @return The value. + */ + public java.lang.CharSequence getType() { + return type; + } + + + /** + * Sets the value of the 'type' field. + * @param value The value of 'type'. + * @return This builder. + */ + public Payment.Builder setType(java.lang.CharSequence value) { + validate(fields()[1], value); + this.type = value; + fieldSetFlags()[1] = true; + return this; + } + + /** + * Checks whether the 'type' field has been set. + * @return True if the 'type' field has been set, false otherwise. + */ + public boolean hasType() { + return fieldSetFlags()[1]; + } + + + /** + * Clears the value of the 'type' field. + * @return This builder. + */ + public Payment.Builder clearType() { + type = null; + fieldSetFlags()[1] = false; + return this; + } + + /** + * Gets the value of the 'amount' field. + * @return The value. + */ + public double getAmount() { + return amount; + } + + + /** + * Sets the value of the 'amount' field. + * @param value The value of 'amount'. + * @return This builder. + */ + public Payment.Builder setAmount(double value) { + validate(fields()[2], value); + this.amount = value; + fieldSetFlags()[2] = true; + return this; + } + + /** + * Checks whether the 'amount' field has been set. + * @return True if the 'amount' field has been set, false otherwise. + */ + public boolean hasAmount() { + return fieldSetFlags()[2]; + } + + + /** + * Clears the value of the 'amount' field. + * @return This builder. + */ + public Payment.Builder clearAmount() { + fieldSetFlags()[2] = false; + return this; + } + + /** + * Gets the value of the 'currency' field. + * @return The value. + */ + public java.lang.CharSequence getCurrency() { + return currency; + } + + + /** + * Sets the value of the 'currency' field. + * @param value The value of 'currency'. + * @return This builder. + */ + public Payment.Builder setCurrency(java.lang.CharSequence value) { + validate(fields()[3], value); + this.currency = value; + fieldSetFlags()[3] = true; + return this; + } + + /** + * Checks whether the 'currency' field has been set. + * @return True if the 'currency' field has been set, false otherwise. + */ + public boolean hasCurrency() { + return fieldSetFlags()[3]; + } + + + /** + * Clears the value of the 'currency' field. + * @return This builder. + */ + public Payment.Builder clearCurrency() { + currency = null; + fieldSetFlags()[3] = false; + return this; + } + + /** + * Gets the value of the 'date' field. + * @return The value. + */ + public java.lang.CharSequence getDate() { + return date; + } + + + /** + * Sets the value of the 'date' field. + * @param value The value of 'date'. + * @return This builder. + */ + public Payment.Builder setDate(java.lang.CharSequence value) { + validate(fields()[4], value); + this.date = value; + fieldSetFlags()[4] = true; + return this; + } + + /** + * Checks whether the 'date' field has been set. + * @return True if the 'date' field has been set, false otherwise. + */ + public boolean hasDate() { + return fieldSetFlags()[4]; + } + + + /** + * Clears the value of the 'date' field. + * @return This builder. + */ + public Payment.Builder clearDate() { + date = null; + fieldSetFlags()[4] = false; + return this; + } + + /** + * Gets the value of the 'status' field. + * @return The value. + */ + public java.lang.CharSequence getStatus() { + return status; + } + + + /** + * Sets the value of the 'status' field. + * @param value The value of 'status'. + * @return This builder. + */ + public Payment.Builder setStatus(java.lang.CharSequence value) { + validate(fields()[5], value); + this.status = value; + fieldSetFlags()[5] = true; + return this; + } + + /** + * Checks whether the 'status' field has been set. + * @return True if the 'status' field has been set, false otherwise. + */ + public boolean hasStatus() { + return fieldSetFlags()[5]; + } + + + /** + * Clears the value of the 'status' field. + * @return This builder. + */ + public Payment.Builder clearStatus() { + status = null; + fieldSetFlags()[5] = false; + return this; + } + + @Override + @SuppressWarnings("unchecked") + public Payment build() { + try { + Payment record = new Payment(); + record.transactionId = fieldSetFlags()[0] ? this.transactionId : (java.lang.CharSequence) defaultValue(fields()[0]); + record.type = fieldSetFlags()[1] ? this.type : (java.lang.CharSequence) defaultValue(fields()[1]); + record.amount = fieldSetFlags()[2] ? this.amount : (java.lang.Double) defaultValue(fields()[2]); + record.currency = fieldSetFlags()[3] ? this.currency : (java.lang.CharSequence) defaultValue(fields()[3]); + record.date = fieldSetFlags()[4] ? this.date : (java.lang.CharSequence) defaultValue(fields()[4]); + record.status = fieldSetFlags()[5] ? this.status : (java.lang.CharSequence) defaultValue(fields()[5]); + return record; + } catch (org.apache.avro.AvroMissingFieldException e) { + throw e; + } catch (java.lang.Exception e) { + throw new org.apache.avro.AvroRuntimeException(e); + } + } + } + + @SuppressWarnings("unchecked") + private static final org.apache.avro.io.DatumWriter + WRITER$ = (org.apache.avro.io.DatumWriter)MODEL$.createDatumWriter(SCHEMA$); + + @Override public void writeExternal(java.io.ObjectOutput out) + throws java.io.IOException { + WRITER$.write(this, SpecificData.getEncoder(out)); + } + + @SuppressWarnings("unchecked") + private static final org.apache.avro.io.DatumReader + READER$ = (org.apache.avro.io.DatumReader)MODEL$.createDatumReader(SCHEMA$); + + @Override public void readExternal(java.io.ObjectInput in) + throws java.io.IOException { + READER$.read(this, SpecificData.getDecoder(in)); + } + + @Override protected boolean hasCustomCoders() { return true; } + + @Override public void customEncode(org.apache.avro.io.Encoder out) + throws java.io.IOException + { + out.writeString(this.transactionId); + + out.writeString(this.type); + + out.writeDouble(this.amount); + + out.writeString(this.currency); + + out.writeString(this.date); + + out.writeString(this.status); + + } + + @Override public void customDecode(org.apache.avro.io.ResolvingDecoder in) + throws java.io.IOException + { + org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff(); + if (fieldOrder == null) { + this.transactionId = in.readString(this.transactionId instanceof Utf8 ? (Utf8)this.transactionId : null); + + this.type = in.readString(this.type instanceof Utf8 ? (Utf8)this.type : null); + + this.amount = in.readDouble(); + + this.currency = in.readString(this.currency instanceof Utf8 ? (Utf8)this.currency : null); + + this.date = in.readString(this.date instanceof Utf8 ? (Utf8)this.date : null); + + this.status = in.readString(this.status instanceof Utf8 ? (Utf8)this.status : null); + + } else { + for (int i = 0; i < 6; i++) { + switch (fieldOrder[i].pos()) { + case 0: + this.transactionId = in.readString(this.transactionId instanceof Utf8 ? (Utf8)this.transactionId : null); + break; + + case 1: + this.type = in.readString(this.type instanceof Utf8 ? (Utf8)this.type : null); + break; + + case 2: + this.amount = in.readDouble(); + break; + + case 3: + this.currency = in.readString(this.currency instanceof Utf8 ? (Utf8)this.currency : null); + break; + + case 4: + this.date = in.readString(this.date instanceof Utf8 ? (Utf8)this.date : null); + break; + + case 5: + this.status = in.readString(this.status instanceof Utf8 ? (Utf8)this.status : null); + break; + + default: + throw new java.io.IOException("Corrupt ResolvingDecoder."); + } + } + } + } +} + + + + + + + + + + diff --git a/src/main/java/io/skodjob/datagenerator/models/paymentfiat/PaymentDetails.java b/src/main/java/io/skodjob/datagenerator/models/paymentfiat/PaymentDetails.java new file mode 100644 index 0000000..c948a0f --- /dev/null +++ b/src/main/java/io/skodjob/datagenerator/models/paymentfiat/PaymentDetails.java @@ -0,0 +1,717 @@ +/** + * Autogenerated by Avro + * + * DO NOT EDIT DIRECTLY + */ +package io.skodjob.datagenerator.models.paymentfiat; + +import org.apache.avro.specific.SpecificData; +import org.apache.avro.util.Utf8; +import org.apache.avro.message.BinaryMessageEncoder; +import org.apache.avro.message.BinaryMessageDecoder; +import org.apache.avro.message.SchemaStore; + +@org.apache.avro.specific.AvroGenerated +public class PaymentDetails extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord { + private static final long serialVersionUID = -5774604774004341124L; + + + public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"PaymentDetails\",\"namespace\":\"io.skodjob.datagenerator.models\",\"fields\":[{\"name\":\"transactionId\",\"type\":\"string\"},{\"name\":\"type\",\"type\":\"string\"},{\"name\":\"amount\",\"type\":\"double\"},{\"name\":\"currency\",\"type\":\"string\"},{\"name\":\"date\",\"type\":\"string\"},{\"name\":\"status\",\"type\":\"string\"}]}"); + public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } + + private static final SpecificData MODEL$ = new SpecificData(); + + private static final BinaryMessageEncoder ENCODER = + new BinaryMessageEncoder<>(MODEL$, SCHEMA$); + + private static final BinaryMessageDecoder DECODER = + new BinaryMessageDecoder<>(MODEL$, SCHEMA$); + + /** + * Return the BinaryMessageEncoder instance used by this class. + * @return the message encoder used by this class + */ + public static BinaryMessageEncoder getEncoder() { + return ENCODER; + } + + /** + * Return the BinaryMessageDecoder instance used by this class. + * @return the message decoder used by this class + */ + public static BinaryMessageDecoder getDecoder() { + return DECODER; + } + + /** + * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}. + * @param resolver a {@link SchemaStore} used to find schemas by fingerprint + * @return a BinaryMessageDecoder instance for this class backed by the given SchemaStore + */ + public static BinaryMessageDecoder createDecoder(SchemaStore resolver) { + return new BinaryMessageDecoder<>(MODEL$, SCHEMA$, resolver); + } + + /** + * Serializes this PaymentDetails to a ByteBuffer. + * @return a buffer holding the serialized data for this instance + * @throws java.io.IOException if this instance could not be serialized + */ + public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException { + return ENCODER.encode(this); + } + + /** + * Deserializes a PaymentDetails from a ByteBuffer. + * @param b a byte buffer holding serialized data for an instance of this class + * @return a PaymentDetails instance decoded from the given buffer + * @throws java.io.IOException if the given bytes could not be deserialized into an instance of this class + */ + public static PaymentDetails fromByteBuffer( + java.nio.ByteBuffer b) throws java.io.IOException { + return DECODER.decode(b); + } + + private java.lang.CharSequence transactionId; + private java.lang.CharSequence type; + private double amount; + private java.lang.CharSequence currency; + private java.lang.CharSequence date; + private java.lang.CharSequence status; + + /** + * Default constructor. Note that this does not initialize fields + * to their default values from the schema. If that is desired then + * one should use newBuilder(). + */ + public PaymentDetails() {} + + /** + * All-args constructor. + * @param transactionId The new value for transactionId + * @param type The new value for type + * @param amount The new value for amount + * @param currency The new value for currency + * @param date The new value for date + * @param status The new value for status + */ + public PaymentDetails(java.lang.CharSequence transactionId, java.lang.CharSequence type, java.lang.Double amount, java.lang.CharSequence currency, java.lang.CharSequence date, java.lang.CharSequence status) { + this.transactionId = transactionId; + this.type = type; + this.amount = amount; + this.currency = currency; + this.date = date; + this.status = status; + } + + @Override + public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; } + + @Override + public org.apache.avro.Schema getSchema() { return SCHEMA$; } + + // Used by DatumWriter. Applications should not call. + @Override + public java.lang.Object get(int field$) { + switch (field$) { + case 0: return transactionId; + case 1: return type; + case 2: return amount; + case 3: return currency; + case 4: return date; + case 5: return status; + default: throw new IndexOutOfBoundsException("Invalid index: " + field$); + } + } + + // Used by DatumReader. Applications should not call. + @Override + @SuppressWarnings(value="unchecked") + public void put(int field$, java.lang.Object value$) { + switch (field$) { + case 0: transactionId = (java.lang.CharSequence)value$; break; + case 1: type = (java.lang.CharSequence)value$; break; + case 2: amount = (java.lang.Double)value$; break; + case 3: currency = (java.lang.CharSequence)value$; break; + case 4: date = (java.lang.CharSequence)value$; break; + case 5: status = (java.lang.CharSequence)value$; break; + default: throw new IndexOutOfBoundsException("Invalid index: " + field$); + } + } + + /** + * Gets the value of the 'transactionId' field. + * @return The value of the 'transactionId' field. + */ + public java.lang.CharSequence getTransactionId() { + return transactionId; + } + + + /** + * Sets the value of the 'transactionId' field. + * @param value the value to set. + */ + public void setTransactionId(java.lang.CharSequence value) { + this.transactionId = value; + } + + /** + * Gets the value of the 'type' field. + * @return The value of the 'type' field. + */ + public java.lang.CharSequence getType() { + return type; + } + + + /** + * Sets the value of the 'type' field. + * @param value the value to set. + */ + public void setType(java.lang.CharSequence value) { + this.type = value; + } + + /** + * Gets the value of the 'amount' field. + * @return The value of the 'amount' field. + */ + public double getAmount() { + return amount; + } + + + /** + * Sets the value of the 'amount' field. + * @param value the value to set. + */ + public void setAmount(double value) { + this.amount = value; + } + + /** + * Gets the value of the 'currency' field. + * @return The value of the 'currency' field. + */ + public java.lang.CharSequence getCurrency() { + return currency; + } + + + /** + * Sets the value of the 'currency' field. + * @param value the value to set. + */ + public void setCurrency(java.lang.CharSequence value) { + this.currency = value; + } + + /** + * Gets the value of the 'date' field. + * @return The value of the 'date' field. + */ + public java.lang.CharSequence getDate() { + return date; + } + + + /** + * Sets the value of the 'date' field. + * @param value the value to set. + */ + public void setDate(java.lang.CharSequence value) { + this.date = value; + } + + /** + * Gets the value of the 'status' field. + * @return The value of the 'status' field. + */ + public java.lang.CharSequence getStatus() { + return status; + } + + + /** + * Sets the value of the 'status' field. + * @param value the value to set. + */ + public void setStatus(java.lang.CharSequence value) { + this.status = value; + } + + /** + * Creates a new PaymentDetails RecordBuilder. + * @return A new PaymentDetails RecordBuilder + */ + public static PaymentDetails.Builder newBuilder() { + return new PaymentDetails.Builder(); + } + + /** + * Creates a new PaymentDetails RecordBuilder by copying an existing Builder. + * @param other The existing builder to copy. + * @return A new PaymentDetails RecordBuilder + */ + public static PaymentDetails.Builder newBuilder(PaymentDetails.Builder other) { + if (other == null) { + return new PaymentDetails.Builder(); + } else { + return new PaymentDetails.Builder(other); + } + } + + /** + * Creates a new PaymentDetails RecordBuilder by copying an existing PaymentDetails instance. + * @param other The existing instance to copy. + * @return A new PaymentDetails RecordBuilder + */ + public static PaymentDetails.Builder newBuilder(PaymentDetails other) { + if (other == null) { + return new PaymentDetails.Builder(); + } else { + return new PaymentDetails.Builder(other); + } + } + + /** + * RecordBuilder for PaymentDetails instances. + */ + @org.apache.avro.specific.AvroGenerated + public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase + implements org.apache.avro.data.RecordBuilder { + + private java.lang.CharSequence transactionId; + private java.lang.CharSequence type; + private double amount; + private java.lang.CharSequence currency; + private java.lang.CharSequence date; + private java.lang.CharSequence status; + + /** Creates a new Builder */ + private Builder() { + super(SCHEMA$, MODEL$); + } + + /** + * Creates a Builder by copying an existing Builder. + * @param other The existing Builder to copy. + */ + private Builder(PaymentDetails.Builder other) { + super(other); + if (isValidValue(fields()[0], other.transactionId)) { + this.transactionId = data().deepCopy(fields()[0].schema(), other.transactionId); + fieldSetFlags()[0] = other.fieldSetFlags()[0]; + } + if (isValidValue(fields()[1], other.type)) { + this.type = data().deepCopy(fields()[1].schema(), other.type); + fieldSetFlags()[1] = other.fieldSetFlags()[1]; + } + if (isValidValue(fields()[2], other.amount)) { + this.amount = data().deepCopy(fields()[2].schema(), other.amount); + fieldSetFlags()[2] = other.fieldSetFlags()[2]; + } + if (isValidValue(fields()[3], other.currency)) { + this.currency = data().deepCopy(fields()[3].schema(), other.currency); + fieldSetFlags()[3] = other.fieldSetFlags()[3]; + } + if (isValidValue(fields()[4], other.date)) { + this.date = data().deepCopy(fields()[4].schema(), other.date); + fieldSetFlags()[4] = other.fieldSetFlags()[4]; + } + if (isValidValue(fields()[5], other.status)) { + this.status = data().deepCopy(fields()[5].schema(), other.status); + fieldSetFlags()[5] = other.fieldSetFlags()[5]; + } + } + + /** + * Creates a Builder by copying an existing PaymentDetails instance + * @param other The existing instance to copy. + */ + private Builder(PaymentDetails other) { + super(SCHEMA$, MODEL$); + if (isValidValue(fields()[0], other.transactionId)) { + this.transactionId = data().deepCopy(fields()[0].schema(), other.transactionId); + fieldSetFlags()[0] = true; + } + if (isValidValue(fields()[1], other.type)) { + this.type = data().deepCopy(fields()[1].schema(), other.type); + fieldSetFlags()[1] = true; + } + if (isValidValue(fields()[2], other.amount)) { + this.amount = data().deepCopy(fields()[2].schema(), other.amount); + fieldSetFlags()[2] = true; + } + if (isValidValue(fields()[3], other.currency)) { + this.currency = data().deepCopy(fields()[3].schema(), other.currency); + fieldSetFlags()[3] = true; + } + if (isValidValue(fields()[4], other.date)) { + this.date = data().deepCopy(fields()[4].schema(), other.date); + fieldSetFlags()[4] = true; + } + if (isValidValue(fields()[5], other.status)) { + this.status = data().deepCopy(fields()[5].schema(), other.status); + fieldSetFlags()[5] = true; + } + } + + /** + * Gets the value of the 'transactionId' field. + * @return The value. + */ + public java.lang.CharSequence getTransactionId() { + return transactionId; + } + + + /** + * Sets the value of the 'transactionId' field. + * @param value The value of 'transactionId'. + * @return This builder. + */ + public PaymentDetails.Builder setTransactionId(java.lang.CharSequence value) { + validate(fields()[0], value); + this.transactionId = value; + fieldSetFlags()[0] = true; + return this; + } + + /** + * Checks whether the 'transactionId' field has been set. + * @return True if the 'transactionId' field has been set, false otherwise. + */ + public boolean hasTransactionId() { + return fieldSetFlags()[0]; + } + + + /** + * Clears the value of the 'transactionId' field. + * @return This builder. + */ + public PaymentDetails.Builder clearTransactionId() { + transactionId = null; + fieldSetFlags()[0] = false; + return this; + } + + /** + * Gets the value of the 'type' field. + * @return The value. + */ + public java.lang.CharSequence getType() { + return type; + } + + + /** + * Sets the value of the 'type' field. + * @param value The value of 'type'. + * @return This builder. + */ + public PaymentDetails.Builder setType(java.lang.CharSequence value) { + validate(fields()[1], value); + this.type = value; + fieldSetFlags()[1] = true; + return this; + } + + /** + * Checks whether the 'type' field has been set. + * @return True if the 'type' field has been set, false otherwise. + */ + public boolean hasType() { + return fieldSetFlags()[1]; + } + + + /** + * Clears the value of the 'type' field. + * @return This builder. + */ + public PaymentDetails.Builder clearType() { + type = null; + fieldSetFlags()[1] = false; + return this; + } + + /** + * Gets the value of the 'amount' field. + * @return The value. + */ + public double getAmount() { + return amount; + } + + + /** + * Sets the value of the 'amount' field. + * @param value The value of 'amount'. + * @return This builder. + */ + public PaymentDetails.Builder setAmount(double value) { + validate(fields()[2], value); + this.amount = value; + fieldSetFlags()[2] = true; + return this; + } + + /** + * Checks whether the 'amount' field has been set. + * @return True if the 'amount' field has been set, false otherwise. + */ + public boolean hasAmount() { + return fieldSetFlags()[2]; + } + + + /** + * Clears the value of the 'amount' field. + * @return This builder. + */ + public PaymentDetails.Builder clearAmount() { + fieldSetFlags()[2] = false; + return this; + } + + /** + * Gets the value of the 'currency' field. + * @return The value. + */ + public java.lang.CharSequence getCurrency() { + return currency; + } + + + /** + * Sets the value of the 'currency' field. + * @param value The value of 'currency'. + * @return This builder. + */ + public PaymentDetails.Builder setCurrency(java.lang.CharSequence value) { + validate(fields()[3], value); + this.currency = value; + fieldSetFlags()[3] = true; + return this; + } + + /** + * Checks whether the 'currency' field has been set. + * @return True if the 'currency' field has been set, false otherwise. + */ + public boolean hasCurrency() { + return fieldSetFlags()[3]; + } + + + /** + * Clears the value of the 'currency' field. + * @return This builder. + */ + public PaymentDetails.Builder clearCurrency() { + currency = null; + fieldSetFlags()[3] = false; + return this; + } + + /** + * Gets the value of the 'date' field. + * @return The value. + */ + public java.lang.CharSequence getDate() { + return date; + } + + + /** + * Sets the value of the 'date' field. + * @param value The value of 'date'. + * @return This builder. + */ + public PaymentDetails.Builder setDate(java.lang.CharSequence value) { + validate(fields()[4], value); + this.date = value; + fieldSetFlags()[4] = true; + return this; + } + + /** + * Checks whether the 'date' field has been set. + * @return True if the 'date' field has been set, false otherwise. + */ + public boolean hasDate() { + return fieldSetFlags()[4]; + } + + + /** + * Clears the value of the 'date' field. + * @return This builder. + */ + public PaymentDetails.Builder clearDate() { + date = null; + fieldSetFlags()[4] = false; + return this; + } + + /** + * Gets the value of the 'status' field. + * @return The value. + */ + public java.lang.CharSequence getStatus() { + return status; + } + + + /** + * Sets the value of the 'status' field. + * @param value The value of 'status'. + * @return This builder. + */ + public PaymentDetails.Builder setStatus(java.lang.CharSequence value) { + validate(fields()[5], value); + this.status = value; + fieldSetFlags()[5] = true; + return this; + } + + /** + * Checks whether the 'status' field has been set. + * @return True if the 'status' field has been set, false otherwise. + */ + public boolean hasStatus() { + return fieldSetFlags()[5]; + } + + + /** + * Clears the value of the 'status' field. + * @return This builder. + */ + public PaymentDetails.Builder clearStatus() { + status = null; + fieldSetFlags()[5] = false; + return this; + } + + @Override + @SuppressWarnings("unchecked") + public PaymentDetails build() { + try { + PaymentDetails record = new PaymentDetails(); + record.transactionId = fieldSetFlags()[0] ? this.transactionId : (java.lang.CharSequence) defaultValue(fields()[0]); + record.type = fieldSetFlags()[1] ? this.type : (java.lang.CharSequence) defaultValue(fields()[1]); + record.amount = fieldSetFlags()[2] ? this.amount : (java.lang.Double) defaultValue(fields()[2]); + record.currency = fieldSetFlags()[3] ? this.currency : (java.lang.CharSequence) defaultValue(fields()[3]); + record.date = fieldSetFlags()[4] ? this.date : (java.lang.CharSequence) defaultValue(fields()[4]); + record.status = fieldSetFlags()[5] ? this.status : (java.lang.CharSequence) defaultValue(fields()[5]); + return record; + } catch (org.apache.avro.AvroMissingFieldException e) { + throw e; + } catch (java.lang.Exception e) { + throw new org.apache.avro.AvroRuntimeException(e); + } + } + } + + @SuppressWarnings("unchecked") + private static final org.apache.avro.io.DatumWriter + WRITER$ = (org.apache.avro.io.DatumWriter)MODEL$.createDatumWriter(SCHEMA$); + + @Override public void writeExternal(java.io.ObjectOutput out) + throws java.io.IOException { + WRITER$.write(this, SpecificData.getEncoder(out)); + } + + @SuppressWarnings("unchecked") + private static final org.apache.avro.io.DatumReader + READER$ = (org.apache.avro.io.DatumReader)MODEL$.createDatumReader(SCHEMA$); + + @Override public void readExternal(java.io.ObjectInput in) + throws java.io.IOException { + READER$.read(this, SpecificData.getDecoder(in)); + } + + @Override protected boolean hasCustomCoders() { return true; } + + @Override public void customEncode(org.apache.avro.io.Encoder out) + throws java.io.IOException + { + out.writeString(this.transactionId); + + out.writeString(this.type); + + out.writeDouble(this.amount); + + out.writeString(this.currency); + + out.writeString(this.date); + + out.writeString(this.status); + + } + + @Override public void customDecode(org.apache.avro.io.ResolvingDecoder in) + throws java.io.IOException + { + org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff(); + if (fieldOrder == null) { + this.transactionId = in.readString(this.transactionId instanceof Utf8 ? (Utf8)this.transactionId : null); + + this.type = in.readString(this.type instanceof Utf8 ? (Utf8)this.type : null); + + this.amount = in.readDouble(); + + this.currency = in.readString(this.currency instanceof Utf8 ? (Utf8)this.currency : null); + + this.date = in.readString(this.date instanceof Utf8 ? (Utf8)this.date : null); + + this.status = in.readString(this.status instanceof Utf8 ? (Utf8)this.status : null); + + } else { + for (int i = 0; i < 6; i++) { + switch (fieldOrder[i].pos()) { + case 0: + this.transactionId = in.readString(this.transactionId instanceof Utf8 ? (Utf8)this.transactionId : null); + break; + + case 1: + this.type = in.readString(this.type instanceof Utf8 ? (Utf8)this.type : null); + break; + + case 2: + this.amount = in.readDouble(); + break; + + case 3: + this.currency = in.readString(this.currency instanceof Utf8 ? (Utf8)this.currency : null); + break; + + case 4: + this.date = in.readString(this.date instanceof Utf8 ? (Utf8)this.date : null); + break; + + case 5: + this.status = in.readString(this.status instanceof Utf8 ? (Utf8)this.status : null); + break; + + default: + throw new java.io.IOException("Corrupt ResolvingDecoder."); + } + } + } + } +} + + + + + + + + + + diff --git a/src/main/java/io/skodjob/datagenerator/models/paymentfiat/PaymentFiat.java b/src/main/java/io/skodjob/datagenerator/models/paymentfiat/PaymentFiat.java new file mode 100644 index 0000000..8dba5b9 --- /dev/null +++ b/src/main/java/io/skodjob/datagenerator/models/paymentfiat/PaymentFiat.java @@ -0,0 +1,647 @@ +/** + * Autogenerated by Avro + * + * DO NOT EDIT DIRECTLY + */ +package io.skodjob.datagenerator.models.paymentfiat; + +import org.apache.avro.generic.GenericArray; +import org.apache.avro.specific.SpecificData; +import org.apache.avro.util.Utf8; +import org.apache.avro.message.BinaryMessageEncoder; +import org.apache.avro.message.BinaryMessageDecoder; +import org.apache.avro.message.SchemaStore; + +@org.apache.avro.specific.AvroGenerated +public class PaymentFiat extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord { + private static final long serialVersionUID = 4555590429550840016L; + + + public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"PaymentFiat\",\"namespace\":\"io.skodjob.datagenerator.models.paymentfiat\",\"fields\":[{\"name\":\"paymentDetails\",\"type\":{\"type\":\"record\",\"name\":\"PaymentDetails\",\"fields\":[{\"name\":\"transactionId\",\"type\":\"string\"},{\"name\":\"type\",\"type\":\"string\"},{\"name\":\"amount\",\"type\":\"double\"},{\"name\":\"currency\",\"type\":\"string\"},{\"name\":\"date\",\"type\":\"string\"},{\"name\":\"status\",\"type\":\"string\"}]}},{\"name\":\"payer\",\"type\":{\"type\":\"record\",\"name\":\"Payer\",\"fields\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"payerType\",\"type\":\"string\"},{\"name\":\"accountNumber\",\"type\":\"string\"},{\"name\":\"bank\",\"type\":\"string\"},{\"name\":\"billingAddress\",\"type\":{\"type\":\"record\",\"name\":\"Address\",\"fields\":[{\"name\":\"street\",\"type\":\"string\"},{\"name\":\"city\",\"type\":\"string\"},{\"name\":\"state\",\"type\":\"string\"},{\"name\":\"country\",\"type\":\"string\"},{\"name\":\"postalCode\",\"type\":\"string\"}]}},{\"name\":\"cardNumber\",\"type\":[\"null\",\"string\"],\"default\":null},{\"name\":\"cardType\",\"type\":[\"null\",\"string\"],\"default\":null},{\"name\":\"expiryDate\",\"type\":[\"null\",\"string\"],\"default\":null}]}},{\"name\":\"payee\",\"type\":{\"type\":\"record\",\"name\":\"Payee\",\"fields\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"payeeType\",\"type\":\"string\"},{\"name\":\"accountNumber\",\"type\":\"string\"},{\"name\":\"bank\",\"type\":\"string\"},{\"name\":\"address\",\"type\":\"Address\"}]}}]}"); + public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } + + private static final SpecificData MODEL$ = new SpecificData(); + + private static final BinaryMessageEncoder ENCODER = + new BinaryMessageEncoder<>(MODEL$, SCHEMA$); + + private static final BinaryMessageDecoder DECODER = + new BinaryMessageDecoder<>(MODEL$, SCHEMA$); + + /** + * Return the BinaryMessageEncoder instance used by this class. + * @return the message encoder used by this class + */ + public static BinaryMessageEncoder getEncoder() { + return ENCODER; + } + + /** + * Return the BinaryMessageDecoder instance used by this class. + * @return the message decoder used by this class + */ + public static BinaryMessageDecoder getDecoder() { + return DECODER; + } + + /** + * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}. + * @param resolver a {@link SchemaStore} used to find schemas by fingerprint + * @return a BinaryMessageDecoder instance for this class backed by the given SchemaStore + */ + public static BinaryMessageDecoder createDecoder(SchemaStore resolver) { + return new BinaryMessageDecoder<>(MODEL$, SCHEMA$, resolver); + } + + /** + * Serializes this PaymentFiat to a ByteBuffer. + * @return a buffer holding the serialized data for this instance + * @throws java.io.IOException if this instance could not be serialized + */ + public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException { + return ENCODER.encode(this); + } + + /** + * Deserializes a PaymentFiat from a ByteBuffer. + * @param b a byte buffer holding serialized data for an instance of this class + * @return a PaymentFiat instance decoded from the given buffer + * @throws java.io.IOException if the given bytes could not be deserialized into an instance of this class + */ + public static PaymentFiat fromByteBuffer( + java.nio.ByteBuffer b) throws java.io.IOException { + return DECODER.decode(b); + } + + private io.skodjob.datagenerator.models.paymentfiat.PaymentDetails paymentDetails; + private io.skodjob.datagenerator.models.paymentfiat.Payer payer; + private io.skodjob.datagenerator.models.paymentfiat.Payee payee; + + /** + * Default constructor. Note that this does not initialize fields + * to their default values from the schema. If that is desired then + * one should use newBuilder(). + */ + public PaymentFiat() {} + + /** + * All-args constructor. + * @param paymentDetails The new value for paymentDetails + * @param payer The new value for payer + * @param payee The new value for payee + */ + public PaymentFiat(io.skodjob.datagenerator.models.paymentfiat.PaymentDetails paymentDetails, io.skodjob.datagenerator.models.paymentfiat.Payer payer, io.skodjob.datagenerator.models.paymentfiat.Payee payee) { + this.paymentDetails = paymentDetails; + this.payer = payer; + this.payee = payee; + } + + @Override + public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; } + + @Override + public org.apache.avro.Schema getSchema() { return SCHEMA$; } + + // Used by DatumWriter. Applications should not call. + @Override + public java.lang.Object get(int field$) { + switch (field$) { + case 0: return paymentDetails; + case 1: return payer; + case 2: return payee; + default: throw new IndexOutOfBoundsException("Invalid index: " + field$); + } + } + + // Used by DatumReader. Applications should not call. + @Override + @SuppressWarnings(value="unchecked") + public void put(int field$, java.lang.Object value$) { + switch (field$) { + case 0: paymentDetails = (io.skodjob.datagenerator.models.paymentfiat.PaymentDetails)value$; break; + case 1: payer = (io.skodjob.datagenerator.models.paymentfiat.Payer)value$; break; + case 2: payee = (io.skodjob.datagenerator.models.paymentfiat.Payee)value$; break; + default: throw new IndexOutOfBoundsException("Invalid index: " + field$); + } + } + + /** + * Gets the value of the 'paymentDetails' field. + * @return The value of the 'paymentDetails' field. + */ + public io.skodjob.datagenerator.models.paymentfiat.PaymentDetails getPaymentDetails() { + return paymentDetails; + } + + + /** + * Sets the value of the 'paymentDetails' field. + * @param value the value to set. + */ + public void setPaymentDetails(io.skodjob.datagenerator.models.paymentfiat.PaymentDetails value) { + this.paymentDetails = value; + } + + /** + * Gets the value of the 'payer' field. + * @return The value of the 'payer' field. + */ + public io.skodjob.datagenerator.models.paymentfiat.Payer getPayer() { + return payer; + } + + + /** + * Sets the value of the 'payer' field. + * @param value the value to set. + */ + public void setPayer(io.skodjob.datagenerator.models.paymentfiat.Payer value) { + this.payer = value; + } + + /** + * Gets the value of the 'payee' field. + * @return The value of the 'payee' field. + */ + public io.skodjob.datagenerator.models.paymentfiat.Payee getPayee() { + return payee; + } + + + /** + * Sets the value of the 'payee' field. + * @param value the value to set. + */ + public void setPayee(io.skodjob.datagenerator.models.paymentfiat.Payee value) { + this.payee = value; + } + + /** + * Creates a new PaymentFiat RecordBuilder. + * @return A new PaymentFiat RecordBuilder + */ + public static io.skodjob.datagenerator.models.paymentfiat.PaymentFiat.Builder newBuilder() { + return new io.skodjob.datagenerator.models.paymentfiat.PaymentFiat.Builder(); + } + + /** + * Creates a new PaymentFiat RecordBuilder by copying an existing Builder. + * @param other The existing builder to copy. + * @return A new PaymentFiat RecordBuilder + */ + public static io.skodjob.datagenerator.models.paymentfiat.PaymentFiat.Builder newBuilder(io.skodjob.datagenerator.models.paymentfiat.PaymentFiat.Builder other) { + if (other == null) { + return new io.skodjob.datagenerator.models.paymentfiat.PaymentFiat.Builder(); + } else { + return new io.skodjob.datagenerator.models.paymentfiat.PaymentFiat.Builder(other); + } + } + + /** + * Creates a new PaymentFiat RecordBuilder by copying an existing PaymentFiat instance. + * @param other The existing instance to copy. + * @return A new PaymentFiat RecordBuilder + */ + public static io.skodjob.datagenerator.models.paymentfiat.PaymentFiat.Builder newBuilder(io.skodjob.datagenerator.models.paymentfiat.PaymentFiat other) { + if (other == null) { + return new io.skodjob.datagenerator.models.paymentfiat.PaymentFiat.Builder(); + } else { + return new io.skodjob.datagenerator.models.paymentfiat.PaymentFiat.Builder(other); + } + } + + /** + * RecordBuilder for PaymentFiat instances. + */ + @org.apache.avro.specific.AvroGenerated + public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase + implements org.apache.avro.data.RecordBuilder { + + private io.skodjob.datagenerator.models.paymentfiat.PaymentDetails paymentDetails; + private io.skodjob.datagenerator.models.paymentfiat.PaymentDetails.Builder paymentDetailsBuilder; + private io.skodjob.datagenerator.models.paymentfiat.Payer payer; + private io.skodjob.datagenerator.models.paymentfiat.Payer.Builder payerBuilder; + private io.skodjob.datagenerator.models.paymentfiat.Payee payee; + private io.skodjob.datagenerator.models.paymentfiat.Payee.Builder payeeBuilder; + + /** Creates a new Builder */ + private Builder() { + super(SCHEMA$, MODEL$); + } + + /** + * Creates a Builder by copying an existing Builder. + * @param other The existing Builder to copy. + */ + private Builder(io.skodjob.datagenerator.models.paymentfiat.PaymentFiat.Builder other) { + super(other); + if (isValidValue(fields()[0], other.paymentDetails)) { + this.paymentDetails = data().deepCopy(fields()[0].schema(), other.paymentDetails); + fieldSetFlags()[0] = other.fieldSetFlags()[0]; + } + if (other.hasPaymentDetailsBuilder()) { + this.paymentDetailsBuilder = io.skodjob.datagenerator.models.paymentfiat.PaymentDetails.newBuilder(other.getPaymentDetailsBuilder()); + } + if (isValidValue(fields()[1], other.payer)) { + this.payer = data().deepCopy(fields()[1].schema(), other.payer); + fieldSetFlags()[1] = other.fieldSetFlags()[1]; + } + if (other.hasPayerBuilder()) { + this.payerBuilder = io.skodjob.datagenerator.models.paymentfiat.Payer.newBuilder(other.getPayerBuilder()); + } + if (isValidValue(fields()[2], other.payee)) { + this.payee = data().deepCopy(fields()[2].schema(), other.payee); + fieldSetFlags()[2] = other.fieldSetFlags()[2]; + } + if (other.hasPayeeBuilder()) { + this.payeeBuilder = io.skodjob.datagenerator.models.paymentfiat.Payee.newBuilder(other.getPayeeBuilder()); + } + } + + /** + * Creates a Builder by copying an existing PaymentFiat instance + * @param other The existing instance to copy. + */ + private Builder(io.skodjob.datagenerator.models.paymentfiat.PaymentFiat other) { + super(SCHEMA$, MODEL$); + if (isValidValue(fields()[0], other.paymentDetails)) { + this.paymentDetails = data().deepCopy(fields()[0].schema(), other.paymentDetails); + fieldSetFlags()[0] = true; + } + this.paymentDetailsBuilder = null; + if (isValidValue(fields()[1], other.payer)) { + this.payer = data().deepCopy(fields()[1].schema(), other.payer); + fieldSetFlags()[1] = true; + } + this.payerBuilder = null; + if (isValidValue(fields()[2], other.payee)) { + this.payee = data().deepCopy(fields()[2].schema(), other.payee); + fieldSetFlags()[2] = true; + } + this.payeeBuilder = null; + } + + /** + * Gets the value of the 'paymentDetails' field. + * @return The value. + */ + public io.skodjob.datagenerator.models.paymentfiat.PaymentDetails getPaymentDetails() { + return paymentDetails; + } + + + /** + * Sets the value of the 'paymentDetails' field. + * @param value The value of 'paymentDetails'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.paymentfiat.PaymentFiat.Builder setPaymentDetails(io.skodjob.datagenerator.models.paymentfiat.PaymentDetails value) { + validate(fields()[0], value); + this.paymentDetailsBuilder = null; + this.paymentDetails = value; + fieldSetFlags()[0] = true; + return this; + } + + /** + * Checks whether the 'paymentDetails' field has been set. + * @return True if the 'paymentDetails' field has been set, false otherwise. + */ + public boolean hasPaymentDetails() { + return fieldSetFlags()[0]; + } + + /** + * Gets the Builder instance for the 'paymentDetails' field and creates one if it doesn't exist yet. + * @return This builder. + */ + public io.skodjob.datagenerator.models.paymentfiat.PaymentDetails.Builder getPaymentDetailsBuilder() { + if (paymentDetailsBuilder == null) { + if (hasPaymentDetails()) { + setPaymentDetailsBuilder(io.skodjob.datagenerator.models.paymentfiat.PaymentDetails.newBuilder(paymentDetails)); + } else { + setPaymentDetailsBuilder(io.skodjob.datagenerator.models.paymentfiat.PaymentDetails.newBuilder()); + } + } + return paymentDetailsBuilder; + } + + /** + * Sets the Builder instance for the 'paymentDetails' field + * @param value The builder instance that must be set. + * @return This builder. + */ + + public io.skodjob.datagenerator.models.paymentfiat.PaymentFiat.Builder setPaymentDetailsBuilder(io.skodjob.datagenerator.models.paymentfiat.PaymentDetails.Builder value) { + clearPaymentDetails(); + paymentDetailsBuilder = value; + return this; + } + + /** + * Checks whether the 'paymentDetails' field has an active Builder instance + * @return True if the 'paymentDetails' field has an active Builder instance + */ + public boolean hasPaymentDetailsBuilder() { + return paymentDetailsBuilder != null; + } + + /** + * Clears the value of the 'paymentDetails' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.paymentfiat.PaymentFiat.Builder clearPaymentDetails() { + paymentDetails = null; + paymentDetailsBuilder = null; + fieldSetFlags()[0] = false; + return this; + } + + /** + * Gets the value of the 'payer' field. + * @return The value. + */ + public io.skodjob.datagenerator.models.paymentfiat.Payer getPayer() { + return payer; + } + + + /** + * Sets the value of the 'payer' field. + * @param value The value of 'payer'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.paymentfiat.PaymentFiat.Builder setPayer(io.skodjob.datagenerator.models.paymentfiat.Payer value) { + validate(fields()[1], value); + this.payerBuilder = null; + this.payer = value; + fieldSetFlags()[1] = true; + return this; + } + + /** + * Checks whether the 'payer' field has been set. + * @return True if the 'payer' field has been set, false otherwise. + */ + public boolean hasPayer() { + return fieldSetFlags()[1]; + } + + /** + * Gets the Builder instance for the 'payer' field and creates one if it doesn't exist yet. + * @return This builder. + */ + public io.skodjob.datagenerator.models.paymentfiat.Payer.Builder getPayerBuilder() { + if (payerBuilder == null) { + if (hasPayer()) { + setPayerBuilder(io.skodjob.datagenerator.models.paymentfiat.Payer.newBuilder(payer)); + } else { + setPayerBuilder(io.skodjob.datagenerator.models.paymentfiat.Payer.newBuilder()); + } + } + return payerBuilder; + } + + /** + * Sets the Builder instance for the 'payer' field + * @param value The builder instance that must be set. + * @return This builder. + */ + + public io.skodjob.datagenerator.models.paymentfiat.PaymentFiat.Builder setPayerBuilder(io.skodjob.datagenerator.models.paymentfiat.Payer.Builder value) { + clearPayer(); + payerBuilder = value; + return this; + } + + /** + * Checks whether the 'payer' field has an active Builder instance + * @return True if the 'payer' field has an active Builder instance + */ + public boolean hasPayerBuilder() { + return payerBuilder != null; + } + + /** + * Clears the value of the 'payer' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.paymentfiat.PaymentFiat.Builder clearPayer() { + payer = null; + payerBuilder = null; + fieldSetFlags()[1] = false; + return this; + } + + /** + * Gets the value of the 'payee' field. + * @return The value. + */ + public io.skodjob.datagenerator.models.paymentfiat.Payee getPayee() { + return payee; + } + + + /** + * Sets the value of the 'payee' field. + * @param value The value of 'payee'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.paymentfiat.PaymentFiat.Builder setPayee(io.skodjob.datagenerator.models.paymentfiat.Payee value) { + validate(fields()[2], value); + this.payeeBuilder = null; + this.payee = value; + fieldSetFlags()[2] = true; + return this; + } + + /** + * Checks whether the 'payee' field has been set. + * @return True if the 'payee' field has been set, false otherwise. + */ + public boolean hasPayee() { + return fieldSetFlags()[2]; + } + + /** + * Gets the Builder instance for the 'payee' field and creates one if it doesn't exist yet. + * @return This builder. + */ + public io.skodjob.datagenerator.models.paymentfiat.Payee.Builder getPayeeBuilder() { + if (payeeBuilder == null) { + if (hasPayee()) { + setPayeeBuilder(io.skodjob.datagenerator.models.paymentfiat.Payee.newBuilder(payee)); + } else { + setPayeeBuilder(io.skodjob.datagenerator.models.paymentfiat.Payee.newBuilder()); + } + } + return payeeBuilder; + } + + /** + * Sets the Builder instance for the 'payee' field + * @param value The builder instance that must be set. + * @return This builder. + */ + + public io.skodjob.datagenerator.models.paymentfiat.PaymentFiat.Builder setPayeeBuilder(io.skodjob.datagenerator.models.paymentfiat.Payee.Builder value) { + clearPayee(); + payeeBuilder = value; + return this; + } + + /** + * Checks whether the 'payee' field has an active Builder instance + * @return True if the 'payee' field has an active Builder instance + */ + public boolean hasPayeeBuilder() { + return payeeBuilder != null; + } + + /** + * Clears the value of the 'payee' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.paymentfiat.PaymentFiat.Builder clearPayee() { + payee = null; + payeeBuilder = null; + fieldSetFlags()[2] = false; + return this; + } + + @Override + @SuppressWarnings("unchecked") + public PaymentFiat build() { + try { + PaymentFiat record = new PaymentFiat(); + if (paymentDetailsBuilder != null) { + try { + record.paymentDetails = this.paymentDetailsBuilder.build(); + } catch (org.apache.avro.AvroMissingFieldException e) { + e.addParentField(record.getSchema().getField("paymentDetails")); + throw e; + } + } else { + record.paymentDetails = fieldSetFlags()[0] ? this.paymentDetails : (io.skodjob.datagenerator.models.paymentfiat.PaymentDetails) defaultValue(fields()[0]); + } + if (payerBuilder != null) { + try { + record.payer = this.payerBuilder.build(); + } catch (org.apache.avro.AvroMissingFieldException e) { + e.addParentField(record.getSchema().getField("payer")); + throw e; + } + } else { + record.payer = fieldSetFlags()[1] ? this.payer : (io.skodjob.datagenerator.models.paymentfiat.Payer) defaultValue(fields()[1]); + } + if (payeeBuilder != null) { + try { + record.payee = this.payeeBuilder.build(); + } catch (org.apache.avro.AvroMissingFieldException e) { + e.addParentField(record.getSchema().getField("payee")); + throw e; + } + } else { + record.payee = fieldSetFlags()[2] ? this.payee : (io.skodjob.datagenerator.models.paymentfiat.Payee) defaultValue(fields()[2]); + } + return record; + } catch (org.apache.avro.AvroMissingFieldException e) { + throw e; + } catch (java.lang.Exception e) { + throw new org.apache.avro.AvroRuntimeException(e); + } + } + } + + @SuppressWarnings("unchecked") + private static final org.apache.avro.io.DatumWriter + WRITER$ = (org.apache.avro.io.DatumWriter)MODEL$.createDatumWriter(SCHEMA$); + + @Override public void writeExternal(java.io.ObjectOutput out) + throws java.io.IOException { + WRITER$.write(this, SpecificData.getEncoder(out)); + } + + @SuppressWarnings("unchecked") + private static final org.apache.avro.io.DatumReader + READER$ = (org.apache.avro.io.DatumReader)MODEL$.createDatumReader(SCHEMA$); + + @Override public void readExternal(java.io.ObjectInput in) + throws java.io.IOException { + READER$.read(this, SpecificData.getDecoder(in)); + } + + @Override protected boolean hasCustomCoders() { return true; } + + @Override public void customEncode(org.apache.avro.io.Encoder out) + throws java.io.IOException + { + this.paymentDetails.customEncode(out); + + this.payer.customEncode(out); + + this.payee.customEncode(out); + + } + + @Override public void customDecode(org.apache.avro.io.ResolvingDecoder in) + throws java.io.IOException + { + org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff(); + if (fieldOrder == null) { + if (this.paymentDetails == null) { + this.paymentDetails = new io.skodjob.datagenerator.models.paymentfiat.PaymentDetails(); + } + this.paymentDetails.customDecode(in); + + if (this.payer == null) { + this.payer = new io.skodjob.datagenerator.models.paymentfiat.Payer(); + } + this.payer.customDecode(in); + + if (this.payee == null) { + this.payee = new io.skodjob.datagenerator.models.paymentfiat.Payee(); + } + this.payee.customDecode(in); + + } else { + for (int i = 0; i < 3; i++) { + switch (fieldOrder[i].pos()) { + case 0: + if (this.paymentDetails == null) { + this.paymentDetails = new io.skodjob.datagenerator.models.paymentfiat.PaymentDetails(); + } + this.paymentDetails.customDecode(in); + break; + + case 1: + if (this.payer == null) { + this.payer = new io.skodjob.datagenerator.models.paymentfiat.Payer(); + } + this.payer.customDecode(in); + break; + + case 2: + if (this.payee == null) { + this.payee = new io.skodjob.datagenerator.models.paymentfiat.Payee(); + } + this.payee.customDecode(in); + break; + + default: + throw new java.io.IOException("Corrupt ResolvingDecoder."); + } + } + } + } +} + + + + + + + + + + diff --git a/src/main/java/io/skodjob/datagenerator/models/payroll/Employee.java b/src/main/java/io/skodjob/datagenerator/models/payroll/Employee.java new file mode 100644 index 0000000..e713ecd --- /dev/null +++ b/src/main/java/io/skodjob/datagenerator/models/payroll/Employee.java @@ -0,0 +1,957 @@ +/** + * Autogenerated by Avro + * + * DO NOT EDIT DIRECTLY + */ +package io.skodjob.datagenerator.models.payroll; + +import org.apache.avro.generic.GenericArray; +import org.apache.avro.specific.SpecificData; +import org.apache.avro.util.Utf8; +import org.apache.avro.message.BinaryMessageEncoder; +import org.apache.avro.message.BinaryMessageDecoder; +import org.apache.avro.message.SchemaStore; + +@org.apache.avro.specific.AvroGenerated +public class Employee extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord { + private static final long serialVersionUID = 2495808458502106084L; + + + public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"Employee\",\"namespace\":\"io.skodjob.datagenerator.models.payroll\",\"fields\":[{\"name\":\"employeeId\",\"type\":\"string\"},{\"name\":\"firstName\",\"type\":\"string\"},{\"name\":\"lastName\",\"type\":\"string\"},{\"name\":\"age\",\"type\":\"int\"},{\"name\":\"ssn\",\"type\":\"string\"},{\"name\":\"hourlyRate\",\"type\":\"float\"},{\"name\":\"gender\",\"type\":\"string\"},{\"name\":\"email\",\"type\":\"string\"},{\"name\":\"company\",\"type\":\"string\"}]}"); + public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } + + private static final SpecificData MODEL$ = new SpecificData(); + + private static final BinaryMessageEncoder ENCODER = + new BinaryMessageEncoder<>(MODEL$, SCHEMA$); + + private static final BinaryMessageDecoder DECODER = + new BinaryMessageDecoder<>(MODEL$, SCHEMA$); + + /** + * Return the BinaryMessageEncoder instance used by this class. + * @return the message encoder used by this class + */ + public static BinaryMessageEncoder getEncoder() { + return ENCODER; + } + + /** + * Return the BinaryMessageDecoder instance used by this class. + * @return the message decoder used by this class + */ + public static BinaryMessageDecoder getDecoder() { + return DECODER; + } + + /** + * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}. + * @param resolver a {@link SchemaStore} used to find schemas by fingerprint + * @return a BinaryMessageDecoder instance for this class backed by the given SchemaStore + */ + public static BinaryMessageDecoder createDecoder(SchemaStore resolver) { + return new BinaryMessageDecoder<>(MODEL$, SCHEMA$, resolver); + } + + /** + * Serializes this Employee to a ByteBuffer. + * @return a buffer holding the serialized data for this instance + * @throws java.io.IOException if this instance could not be serialized + */ + public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException { + return ENCODER.encode(this); + } + + /** + * Deserializes a Employee from a ByteBuffer. + * @param b a byte buffer holding serialized data for an instance of this class + * @return a Employee instance decoded from the given buffer + * @throws java.io.IOException if the given bytes could not be deserialized into an instance of this class + */ + public static Employee fromByteBuffer( + java.nio.ByteBuffer b) throws java.io.IOException { + return DECODER.decode(b); + } + + private java.lang.CharSequence employeeId; + private java.lang.CharSequence firstName; + private java.lang.CharSequence lastName; + private int age; + private java.lang.CharSequence ssn; + private float hourlyRate; + private java.lang.CharSequence gender; + private java.lang.CharSequence email; + private java.lang.CharSequence company; + + /** + * Default constructor. Note that this does not initialize fields + * to their default values from the schema. If that is desired then + * one should use newBuilder(). + */ + public Employee() {} + + /** + * All-args constructor. + * @param employeeId The new value for employeeId + * @param firstName The new value for firstName + * @param lastName The new value for lastName + * @param age The new value for age + * @param ssn The new value for ssn + * @param hourlyRate The new value for hourlyRate + * @param gender The new value for gender + * @param email The new value for email + * @param company The new value for company + */ + public Employee(java.lang.CharSequence employeeId, java.lang.CharSequence firstName, java.lang.CharSequence lastName, java.lang.Integer age, java.lang.CharSequence ssn, java.lang.Float hourlyRate, java.lang.CharSequence gender, java.lang.CharSequence email, java.lang.CharSequence company) { + this.employeeId = employeeId; + this.firstName = firstName; + this.lastName = lastName; + this.age = age; + this.ssn = ssn; + this.hourlyRate = hourlyRate; + this.gender = gender; + this.email = email; + this.company = company; + } + + @Override + public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; } + + @Override + public org.apache.avro.Schema getSchema() { return SCHEMA$; } + + // Used by DatumWriter. Applications should not call. + @Override + public java.lang.Object get(int field$) { + switch (field$) { + case 0: return employeeId; + case 1: return firstName; + case 2: return lastName; + case 3: return age; + case 4: return ssn; + case 5: return hourlyRate; + case 6: return gender; + case 7: return email; + case 8: return company; + default: throw new IndexOutOfBoundsException("Invalid index: " + field$); + } + } + + // Used by DatumReader. Applications should not call. + @Override + @SuppressWarnings(value="unchecked") + public void put(int field$, java.lang.Object value$) { + switch (field$) { + case 0: employeeId = (java.lang.CharSequence)value$; break; + case 1: firstName = (java.lang.CharSequence)value$; break; + case 2: lastName = (java.lang.CharSequence)value$; break; + case 3: age = (java.lang.Integer)value$; break; + case 4: ssn = (java.lang.CharSequence)value$; break; + case 5: hourlyRate = (java.lang.Float)value$; break; + case 6: gender = (java.lang.CharSequence)value$; break; + case 7: email = (java.lang.CharSequence)value$; break; + case 8: company = (java.lang.CharSequence)value$; break; + default: throw new IndexOutOfBoundsException("Invalid index: " + field$); + } + } + + /** + * Gets the value of the 'employeeId' field. + * @return The value of the 'employeeId' field. + */ + public java.lang.CharSequence getEmployeeId() { + return employeeId; + } + + + /** + * Sets the value of the 'employeeId' field. + * @param value the value to set. + */ + public void setEmployeeId(java.lang.CharSequence value) { + this.employeeId = value; + } + + /** + * Gets the value of the 'firstName' field. + * @return The value of the 'firstName' field. + */ + public java.lang.CharSequence getFirstName() { + return firstName; + } + + + /** + * Sets the value of the 'firstName' field. + * @param value the value to set. + */ + public void setFirstName(java.lang.CharSequence value) { + this.firstName = value; + } + + /** + * Gets the value of the 'lastName' field. + * @return The value of the 'lastName' field. + */ + public java.lang.CharSequence getLastName() { + return lastName; + } + + + /** + * Sets the value of the 'lastName' field. + * @param value the value to set. + */ + public void setLastName(java.lang.CharSequence value) { + this.lastName = value; + } + + /** + * Gets the value of the 'age' field. + * @return The value of the 'age' field. + */ + public int getAge() { + return age; + } + + + /** + * Sets the value of the 'age' field. + * @param value the value to set. + */ + public void setAge(int value) { + this.age = value; + } + + /** + * Gets the value of the 'ssn' field. + * @return The value of the 'ssn' field. + */ + public java.lang.CharSequence getSsn() { + return ssn; + } + + + /** + * Sets the value of the 'ssn' field. + * @param value the value to set. + */ + public void setSsn(java.lang.CharSequence value) { + this.ssn = value; + } + + /** + * Gets the value of the 'hourlyRate' field. + * @return The value of the 'hourlyRate' field. + */ + public float getHourlyRate() { + return hourlyRate; + } + + + /** + * Sets the value of the 'hourlyRate' field. + * @param value the value to set. + */ + public void setHourlyRate(float value) { + this.hourlyRate = value; + } + + /** + * Gets the value of the 'gender' field. + * @return The value of the 'gender' field. + */ + public java.lang.CharSequence getGender() { + return gender; + } + + + /** + * Sets the value of the 'gender' field. + * @param value the value to set. + */ + public void setGender(java.lang.CharSequence value) { + this.gender = value; + } + + /** + * Gets the value of the 'email' field. + * @return The value of the 'email' field. + */ + public java.lang.CharSequence getEmail() { + return email; + } + + + /** + * Sets the value of the 'email' field. + * @param value the value to set. + */ + public void setEmail(java.lang.CharSequence value) { + this.email = value; + } + + /** + * Gets the value of the 'company' field. + * @return The value of the 'company' field. + */ + public java.lang.CharSequence getCompany() { + return company; + } + + + /** + * Sets the value of the 'company' field. + * @param value the value to set. + */ + public void setCompany(java.lang.CharSequence value) { + this.company = value; + } + + /** + * Creates a new Employee RecordBuilder. + * @return A new Employee RecordBuilder + */ + public static io.skodjob.datagenerator.models.payroll.Employee.Builder newBuilder() { + return new io.skodjob.datagenerator.models.payroll.Employee.Builder(); + } + + /** + * Creates a new Employee RecordBuilder by copying an existing Builder. + * @param other The existing builder to copy. + * @return A new Employee RecordBuilder + */ + public static io.skodjob.datagenerator.models.payroll.Employee.Builder newBuilder(io.skodjob.datagenerator.models.payroll.Employee.Builder other) { + if (other == null) { + return new io.skodjob.datagenerator.models.payroll.Employee.Builder(); + } else { + return new io.skodjob.datagenerator.models.payroll.Employee.Builder(other); + } + } + + /** + * Creates a new Employee RecordBuilder by copying an existing Employee instance. + * @param other The existing instance to copy. + * @return A new Employee RecordBuilder + */ + public static io.skodjob.datagenerator.models.payroll.Employee.Builder newBuilder(io.skodjob.datagenerator.models.payroll.Employee other) { + if (other == null) { + return new io.skodjob.datagenerator.models.payroll.Employee.Builder(); + } else { + return new io.skodjob.datagenerator.models.payroll.Employee.Builder(other); + } + } + + /** + * RecordBuilder for Employee instances. + */ + @org.apache.avro.specific.AvroGenerated + public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase + implements org.apache.avro.data.RecordBuilder { + + private java.lang.CharSequence employeeId; + private java.lang.CharSequence firstName; + private java.lang.CharSequence lastName; + private int age; + private java.lang.CharSequence ssn; + private float hourlyRate; + private java.lang.CharSequence gender; + private java.lang.CharSequence email; + private java.lang.CharSequence company; + + /** Creates a new Builder */ + private Builder() { + super(SCHEMA$, MODEL$); + } + + /** + * Creates a Builder by copying an existing Builder. + * @param other The existing Builder to copy. + */ + private Builder(io.skodjob.datagenerator.models.payroll.Employee.Builder other) { + super(other); + if (isValidValue(fields()[0], other.employeeId)) { + this.employeeId = data().deepCopy(fields()[0].schema(), other.employeeId); + fieldSetFlags()[0] = other.fieldSetFlags()[0]; + } + if (isValidValue(fields()[1], other.firstName)) { + this.firstName = data().deepCopy(fields()[1].schema(), other.firstName); + fieldSetFlags()[1] = other.fieldSetFlags()[1]; + } + if (isValidValue(fields()[2], other.lastName)) { + this.lastName = data().deepCopy(fields()[2].schema(), other.lastName); + fieldSetFlags()[2] = other.fieldSetFlags()[2]; + } + if (isValidValue(fields()[3], other.age)) { + this.age = data().deepCopy(fields()[3].schema(), other.age); + fieldSetFlags()[3] = other.fieldSetFlags()[3]; + } + if (isValidValue(fields()[4], other.ssn)) { + this.ssn = data().deepCopy(fields()[4].schema(), other.ssn); + fieldSetFlags()[4] = other.fieldSetFlags()[4]; + } + if (isValidValue(fields()[5], other.hourlyRate)) { + this.hourlyRate = data().deepCopy(fields()[5].schema(), other.hourlyRate); + fieldSetFlags()[5] = other.fieldSetFlags()[5]; + } + if (isValidValue(fields()[6], other.gender)) { + this.gender = data().deepCopy(fields()[6].schema(), other.gender); + fieldSetFlags()[6] = other.fieldSetFlags()[6]; + } + if (isValidValue(fields()[7], other.email)) { + this.email = data().deepCopy(fields()[7].schema(), other.email); + fieldSetFlags()[7] = other.fieldSetFlags()[7]; + } + if (isValidValue(fields()[8], other.company)) { + this.company = data().deepCopy(fields()[8].schema(), other.company); + fieldSetFlags()[8] = other.fieldSetFlags()[8]; + } + } + + /** + * Creates a Builder by copying an existing Employee instance + * @param other The existing instance to copy. + */ + private Builder(io.skodjob.datagenerator.models.payroll.Employee other) { + super(SCHEMA$, MODEL$); + if (isValidValue(fields()[0], other.employeeId)) { + this.employeeId = data().deepCopy(fields()[0].schema(), other.employeeId); + fieldSetFlags()[0] = true; + } + if (isValidValue(fields()[1], other.firstName)) { + this.firstName = data().deepCopy(fields()[1].schema(), other.firstName); + fieldSetFlags()[1] = true; + } + if (isValidValue(fields()[2], other.lastName)) { + this.lastName = data().deepCopy(fields()[2].schema(), other.lastName); + fieldSetFlags()[2] = true; + } + if (isValidValue(fields()[3], other.age)) { + this.age = data().deepCopy(fields()[3].schema(), other.age); + fieldSetFlags()[3] = true; + } + if (isValidValue(fields()[4], other.ssn)) { + this.ssn = data().deepCopy(fields()[4].schema(), other.ssn); + fieldSetFlags()[4] = true; + } + if (isValidValue(fields()[5], other.hourlyRate)) { + this.hourlyRate = data().deepCopy(fields()[5].schema(), other.hourlyRate); + fieldSetFlags()[5] = true; + } + if (isValidValue(fields()[6], other.gender)) { + this.gender = data().deepCopy(fields()[6].schema(), other.gender); + fieldSetFlags()[6] = true; + } + if (isValidValue(fields()[7], other.email)) { + this.email = data().deepCopy(fields()[7].schema(), other.email); + fieldSetFlags()[7] = true; + } + if (isValidValue(fields()[8], other.company)) { + this.company = data().deepCopy(fields()[8].schema(), other.company); + fieldSetFlags()[8] = true; + } + } + + /** + * Gets the value of the 'employeeId' field. + * @return The value. + */ + public java.lang.CharSequence getEmployeeId() { + return employeeId; + } + + + /** + * Sets the value of the 'employeeId' field. + * @param value The value of 'employeeId'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.payroll.Employee.Builder setEmployeeId(java.lang.CharSequence value) { + validate(fields()[0], value); + this.employeeId = value; + fieldSetFlags()[0] = true; + return this; + } + + /** + * Checks whether the 'employeeId' field has been set. + * @return True if the 'employeeId' field has been set, false otherwise. + */ + public boolean hasEmployeeId() { + return fieldSetFlags()[0]; + } + + + /** + * Clears the value of the 'employeeId' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.payroll.Employee.Builder clearEmployeeId() { + employeeId = null; + fieldSetFlags()[0] = false; + return this; + } + + /** + * Gets the value of the 'firstName' field. + * @return The value. + */ + public java.lang.CharSequence getFirstName() { + return firstName; + } + + + /** + * Sets the value of the 'firstName' field. + * @param value The value of 'firstName'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.payroll.Employee.Builder setFirstName(java.lang.CharSequence value) { + validate(fields()[1], value); + this.firstName = value; + fieldSetFlags()[1] = true; + return this; + } + + /** + * Checks whether the 'firstName' field has been set. + * @return True if the 'firstName' field has been set, false otherwise. + */ + public boolean hasFirstName() { + return fieldSetFlags()[1]; + } + + + /** + * Clears the value of the 'firstName' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.payroll.Employee.Builder clearFirstName() { + firstName = null; + fieldSetFlags()[1] = false; + return this; + } + + /** + * Gets the value of the 'lastName' field. + * @return The value. + */ + public java.lang.CharSequence getLastName() { + return lastName; + } + + + /** + * Sets the value of the 'lastName' field. + * @param value The value of 'lastName'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.payroll.Employee.Builder setLastName(java.lang.CharSequence value) { + validate(fields()[2], value); + this.lastName = value; + fieldSetFlags()[2] = true; + return this; + } + + /** + * Checks whether the 'lastName' field has been set. + * @return True if the 'lastName' field has been set, false otherwise. + */ + public boolean hasLastName() { + return fieldSetFlags()[2]; + } + + + /** + * Clears the value of the 'lastName' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.payroll.Employee.Builder clearLastName() { + lastName = null; + fieldSetFlags()[2] = false; + return this; + } + + /** + * Gets the value of the 'age' field. + * @return The value. + */ + public int getAge() { + return age; + } + + + /** + * Sets the value of the 'age' field. + * @param value The value of 'age'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.payroll.Employee.Builder setAge(int value) { + validate(fields()[3], value); + this.age = value; + fieldSetFlags()[3] = true; + return this; + } + + /** + * Checks whether the 'age' field has been set. + * @return True if the 'age' field has been set, false otherwise. + */ + public boolean hasAge() { + return fieldSetFlags()[3]; + } + + + /** + * Clears the value of the 'age' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.payroll.Employee.Builder clearAge() { + fieldSetFlags()[3] = false; + return this; + } + + /** + * Gets the value of the 'ssn' field. + * @return The value. + */ + public java.lang.CharSequence getSsn() { + return ssn; + } + + + /** + * Sets the value of the 'ssn' field. + * @param value The value of 'ssn'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.payroll.Employee.Builder setSsn(java.lang.CharSequence value) { + validate(fields()[4], value); + this.ssn = value; + fieldSetFlags()[4] = true; + return this; + } + + /** + * Checks whether the 'ssn' field has been set. + * @return True if the 'ssn' field has been set, false otherwise. + */ + public boolean hasSsn() { + return fieldSetFlags()[4]; + } + + + /** + * Clears the value of the 'ssn' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.payroll.Employee.Builder clearSsn() { + ssn = null; + fieldSetFlags()[4] = false; + return this; + } + + /** + * Gets the value of the 'hourlyRate' field. + * @return The value. + */ + public float getHourlyRate() { + return hourlyRate; + } + + + /** + * Sets the value of the 'hourlyRate' field. + * @param value The value of 'hourlyRate'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.payroll.Employee.Builder setHourlyRate(float value) { + validate(fields()[5], value); + this.hourlyRate = value; + fieldSetFlags()[5] = true; + return this; + } + + /** + * Checks whether the 'hourlyRate' field has been set. + * @return True if the 'hourlyRate' field has been set, false otherwise. + */ + public boolean hasHourlyRate() { + return fieldSetFlags()[5]; + } + + + /** + * Clears the value of the 'hourlyRate' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.payroll.Employee.Builder clearHourlyRate() { + fieldSetFlags()[5] = false; + return this; + } + + /** + * Gets the value of the 'gender' field. + * @return The value. + */ + public java.lang.CharSequence getGender() { + return gender; + } + + + /** + * Sets the value of the 'gender' field. + * @param value The value of 'gender'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.payroll.Employee.Builder setGender(java.lang.CharSequence value) { + validate(fields()[6], value); + this.gender = value; + fieldSetFlags()[6] = true; + return this; + } + + /** + * Checks whether the 'gender' field has been set. + * @return True if the 'gender' field has been set, false otherwise. + */ + public boolean hasGender() { + return fieldSetFlags()[6]; + } + + + /** + * Clears the value of the 'gender' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.payroll.Employee.Builder clearGender() { + gender = null; + fieldSetFlags()[6] = false; + return this; + } + + /** + * Gets the value of the 'email' field. + * @return The value. + */ + public java.lang.CharSequence getEmail() { + return email; + } + + + /** + * Sets the value of the 'email' field. + * @param value The value of 'email'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.payroll.Employee.Builder setEmail(java.lang.CharSequence value) { + validate(fields()[7], value); + this.email = value; + fieldSetFlags()[7] = true; + return this; + } + + /** + * Checks whether the 'email' field has been set. + * @return True if the 'email' field has been set, false otherwise. + */ + public boolean hasEmail() { + return fieldSetFlags()[7]; + } + + + /** + * Clears the value of the 'email' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.payroll.Employee.Builder clearEmail() { + email = null; + fieldSetFlags()[7] = false; + return this; + } + + /** + * Gets the value of the 'company' field. + * @return The value. + */ + public java.lang.CharSequence getCompany() { + return company; + } + + + /** + * Sets the value of the 'company' field. + * @param value The value of 'company'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.payroll.Employee.Builder setCompany(java.lang.CharSequence value) { + validate(fields()[8], value); + this.company = value; + fieldSetFlags()[8] = true; + return this; + } + + /** + * Checks whether the 'company' field has been set. + * @return True if the 'company' field has been set, false otherwise. + */ + public boolean hasCompany() { + return fieldSetFlags()[8]; + } + + + /** + * Clears the value of the 'company' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.payroll.Employee.Builder clearCompany() { + company = null; + fieldSetFlags()[8] = false; + return this; + } + + @Override + @SuppressWarnings("unchecked") + public Employee build() { + try { + Employee record = new Employee(); + record.employeeId = fieldSetFlags()[0] ? this.employeeId : (java.lang.CharSequence) defaultValue(fields()[0]); + record.firstName = fieldSetFlags()[1] ? this.firstName : (java.lang.CharSequence) defaultValue(fields()[1]); + record.lastName = fieldSetFlags()[2] ? this.lastName : (java.lang.CharSequence) defaultValue(fields()[2]); + record.age = fieldSetFlags()[3] ? this.age : (java.lang.Integer) defaultValue(fields()[3]); + record.ssn = fieldSetFlags()[4] ? this.ssn : (java.lang.CharSequence) defaultValue(fields()[4]); + record.hourlyRate = fieldSetFlags()[5] ? this.hourlyRate : (java.lang.Float) defaultValue(fields()[5]); + record.gender = fieldSetFlags()[6] ? this.gender : (java.lang.CharSequence) defaultValue(fields()[6]); + record.email = fieldSetFlags()[7] ? this.email : (java.lang.CharSequence) defaultValue(fields()[7]); + record.company = fieldSetFlags()[8] ? this.company : (java.lang.CharSequence) defaultValue(fields()[8]); + return record; + } catch (org.apache.avro.AvroMissingFieldException e) { + throw e; + } catch (java.lang.Exception e) { + throw new org.apache.avro.AvroRuntimeException(e); + } + } + } + + @SuppressWarnings("unchecked") + private static final org.apache.avro.io.DatumWriter + WRITER$ = (org.apache.avro.io.DatumWriter)MODEL$.createDatumWriter(SCHEMA$); + + @Override public void writeExternal(java.io.ObjectOutput out) + throws java.io.IOException { + WRITER$.write(this, SpecificData.getEncoder(out)); + } + + @SuppressWarnings("unchecked") + private static final org.apache.avro.io.DatumReader + READER$ = (org.apache.avro.io.DatumReader)MODEL$.createDatumReader(SCHEMA$); + + @Override public void readExternal(java.io.ObjectInput in) + throws java.io.IOException { + READER$.read(this, SpecificData.getDecoder(in)); + } + + @Override protected boolean hasCustomCoders() { return true; } + + @Override public void customEncode(org.apache.avro.io.Encoder out) + throws java.io.IOException + { + out.writeString(this.employeeId); + + out.writeString(this.firstName); + + out.writeString(this.lastName); + + out.writeInt(this.age); + + out.writeString(this.ssn); + + out.writeFloat(this.hourlyRate); + + out.writeString(this.gender); + + out.writeString(this.email); + + out.writeString(this.company); + + } + + @Override public void customDecode(org.apache.avro.io.ResolvingDecoder in) + throws java.io.IOException + { + org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff(); + if (fieldOrder == null) { + this.employeeId = in.readString(this.employeeId instanceof Utf8 ? (Utf8)this.employeeId : null); + + this.firstName = in.readString(this.firstName instanceof Utf8 ? (Utf8)this.firstName : null); + + this.lastName = in.readString(this.lastName instanceof Utf8 ? (Utf8)this.lastName : null); + + this.age = in.readInt(); + + this.ssn = in.readString(this.ssn instanceof Utf8 ? (Utf8)this.ssn : null); + + this.hourlyRate = in.readFloat(); + + this.gender = in.readString(this.gender instanceof Utf8 ? (Utf8)this.gender : null); + + this.email = in.readString(this.email instanceof Utf8 ? (Utf8)this.email : null); + + this.company = in.readString(this.company instanceof Utf8 ? (Utf8)this.company : null); + + } else { + for (int i = 0; i < 9; i++) { + switch (fieldOrder[i].pos()) { + case 0: + this.employeeId = in.readString(this.employeeId instanceof Utf8 ? (Utf8)this.employeeId : null); + break; + + case 1: + this.firstName = in.readString(this.firstName instanceof Utf8 ? (Utf8)this.firstName : null); + break; + + case 2: + this.lastName = in.readString(this.lastName instanceof Utf8 ? (Utf8)this.lastName : null); + break; + + case 3: + this.age = in.readInt(); + break; + + case 4: + this.ssn = in.readString(this.ssn instanceof Utf8 ? (Utf8)this.ssn : null); + break; + + case 5: + this.hourlyRate = in.readFloat(); + break; + + case 6: + this.gender = in.readString(this.gender instanceof Utf8 ? (Utf8)this.gender : null); + break; + + case 7: + this.email = in.readString(this.email instanceof Utf8 ? (Utf8)this.email : null); + break; + + case 8: + this.company = in.readString(this.company instanceof Utf8 ? (Utf8)this.company : null); + break; + + default: + throw new java.io.IOException("Corrupt ResolvingDecoder."); + } + } + } + } +} + + + + + + + + + + diff --git a/src/main/java/io/skodjob/datagenerator/models/stargate/StarGate.java b/src/main/java/io/skodjob/datagenerator/models/stargate/StarGate.java new file mode 100644 index 0000000..0bbb0a1 --- /dev/null +++ b/src/main/java/io/skodjob/datagenerator/models/stargate/StarGate.java @@ -0,0 +1,877 @@ +/** + * Autogenerated by Avro + * + * DO NOT EDIT DIRECTLY + */ +package io.skodjob.datagenerator.models.stargate; + +import org.apache.avro.generic.GenericArray; +import org.apache.avro.specific.SpecificData; +import org.apache.avro.util.Utf8; +import org.apache.avro.message.BinaryMessageEncoder; +import org.apache.avro.message.BinaryMessageDecoder; +import org.apache.avro.message.SchemaStore; + +@org.apache.avro.specific.AvroGenerated +public class StarGate extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord { + private static final long serialVersionUID = -443295484777882232L; + + + public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"StarGate\",\"namespace\":\"io.skodjob.datagenerator.models.stargate\",\"fields\":[{\"name\":\"character_name\",\"type\":\"string\"},{\"name\":\"source_planet\",\"type\":\"string\"},{\"name\":\"target_planet\",\"type\":\"string\"},{\"name\":\"quote\",\"type\":\"string\"},{\"name\":\"duration\",\"type\":\"int\"},{\"name\":\"duration_unit\",\"type\":\"string\"},{\"name\":\"distance\",\"type\":\"int\"},{\"name\":\"distance_unit\",\"type\":\"string\"}]}"); + public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } + + private static final SpecificData MODEL$ = new SpecificData(); + + private static final BinaryMessageEncoder ENCODER = + new BinaryMessageEncoder<>(MODEL$, SCHEMA$); + + private static final BinaryMessageDecoder DECODER = + new BinaryMessageDecoder<>(MODEL$, SCHEMA$); + + /** + * Return the BinaryMessageEncoder instance used by this class. + * @return the message encoder used by this class + */ + public static BinaryMessageEncoder getEncoder() { + return ENCODER; + } + + /** + * Return the BinaryMessageDecoder instance used by this class. + * @return the message decoder used by this class + */ + public static BinaryMessageDecoder getDecoder() { + return DECODER; + } + + /** + * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}. + * @param resolver a {@link SchemaStore} used to find schemas by fingerprint + * @return a BinaryMessageDecoder instance for this class backed by the given SchemaStore + */ + public static BinaryMessageDecoder createDecoder(SchemaStore resolver) { + return new BinaryMessageDecoder<>(MODEL$, SCHEMA$, resolver); + } + + /** + * Serializes this StarGate to a ByteBuffer. + * @return a buffer holding the serialized data for this instance + * @throws java.io.IOException if this instance could not be serialized + */ + public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException { + return ENCODER.encode(this); + } + + /** + * Deserializes a StarGate from a ByteBuffer. + * @param b a byte buffer holding serialized data for an instance of this class + * @return a StarGate instance decoded from the given buffer + * @throws java.io.IOException if the given bytes could not be deserialized into an instance of this class + */ + public static StarGate fromByteBuffer( + java.nio.ByteBuffer b) throws java.io.IOException { + return DECODER.decode(b); + } + + private java.lang.CharSequence character_name; + private java.lang.CharSequence source_planet; + private java.lang.CharSequence target_planet; + private java.lang.CharSequence quote; + private int duration; + private java.lang.CharSequence duration_unit; + private int distance; + private java.lang.CharSequence distance_unit; + + /** + * Default constructor. Note that this does not initialize fields + * to their default values from the schema. If that is desired then + * one should use newBuilder(). + */ + public StarGate() {} + + /** + * All-args constructor. + * @param character_name The new value for character_name + * @param source_planet The new value for source_planet + * @param target_planet The new value for target_planet + * @param quote The new value for quote + * @param duration The new value for duration + * @param duration_unit The new value for duration_unit + * @param distance The new value for distance + * @param distance_unit The new value for distance_unit + */ + public StarGate(java.lang.CharSequence character_name, java.lang.CharSequence source_planet, java.lang.CharSequence target_planet, java.lang.CharSequence quote, java.lang.Integer duration, java.lang.CharSequence duration_unit, java.lang.Integer distance, java.lang.CharSequence distance_unit) { + this.character_name = character_name; + this.source_planet = source_planet; + this.target_planet = target_planet; + this.quote = quote; + this.duration = duration; + this.duration_unit = duration_unit; + this.distance = distance; + this.distance_unit = distance_unit; + } + + @Override + public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; } + + @Override + public org.apache.avro.Schema getSchema() { return SCHEMA$; } + + // Used by DatumWriter. Applications should not call. + @Override + public java.lang.Object get(int field$) { + switch (field$) { + case 0: return character_name; + case 1: return source_planet; + case 2: return target_planet; + case 3: return quote; + case 4: return duration; + case 5: return duration_unit; + case 6: return distance; + case 7: return distance_unit; + default: throw new IndexOutOfBoundsException("Invalid index: " + field$); + } + } + + // Used by DatumReader. Applications should not call. + @Override + @SuppressWarnings(value="unchecked") + public void put(int field$, java.lang.Object value$) { + switch (field$) { + case 0: character_name = (java.lang.CharSequence)value$; break; + case 1: source_planet = (java.lang.CharSequence)value$; break; + case 2: target_planet = (java.lang.CharSequence)value$; break; + case 3: quote = (java.lang.CharSequence)value$; break; + case 4: duration = (java.lang.Integer)value$; break; + case 5: duration_unit = (java.lang.CharSequence)value$; break; + case 6: distance = (java.lang.Integer)value$; break; + case 7: distance_unit = (java.lang.CharSequence)value$; break; + default: throw new IndexOutOfBoundsException("Invalid index: " + field$); + } + } + + /** + * Gets the value of the 'character_name' field. + * @return The value of the 'character_name' field. + */ + public java.lang.CharSequence getCharacterName() { + return character_name; + } + + + /** + * Sets the value of the 'character_name' field. + * @param value the value to set. + */ + public void setCharacterName(java.lang.CharSequence value) { + this.character_name = value; + } + + /** + * Gets the value of the 'source_planet' field. + * @return The value of the 'source_planet' field. + */ + public java.lang.CharSequence getSourcePlanet() { + return source_planet; + } + + + /** + * Sets the value of the 'source_planet' field. + * @param value the value to set. + */ + public void setSourcePlanet(java.lang.CharSequence value) { + this.source_planet = value; + } + + /** + * Gets the value of the 'target_planet' field. + * @return The value of the 'target_planet' field. + */ + public java.lang.CharSequence getTargetPlanet() { + return target_planet; + } + + + /** + * Sets the value of the 'target_planet' field. + * @param value the value to set. + */ + public void setTargetPlanet(java.lang.CharSequence value) { + this.target_planet = value; + } + + /** + * Gets the value of the 'quote' field. + * @return The value of the 'quote' field. + */ + public java.lang.CharSequence getQuote() { + return quote; + } + + + /** + * Sets the value of the 'quote' field. + * @param value the value to set. + */ + public void setQuote(java.lang.CharSequence value) { + this.quote = value; + } + + /** + * Gets the value of the 'duration' field. + * @return The value of the 'duration' field. + */ + public int getDuration() { + return duration; + } + + + /** + * Sets the value of the 'duration' field. + * @param value the value to set. + */ + public void setDuration(int value) { + this.duration = value; + } + + /** + * Gets the value of the 'duration_unit' field. + * @return The value of the 'duration_unit' field. + */ + public java.lang.CharSequence getDurationUnit() { + return duration_unit; + } + + + /** + * Sets the value of the 'duration_unit' field. + * @param value the value to set. + */ + public void setDurationUnit(java.lang.CharSequence value) { + this.duration_unit = value; + } + + /** + * Gets the value of the 'distance' field. + * @return The value of the 'distance' field. + */ + public int getDistance() { + return distance; + } + + + /** + * Sets the value of the 'distance' field. + * @param value the value to set. + */ + public void setDistance(int value) { + this.distance = value; + } + + /** + * Gets the value of the 'distance_unit' field. + * @return The value of the 'distance_unit' field. + */ + public java.lang.CharSequence getDistanceUnit() { + return distance_unit; + } + + + /** + * Sets the value of the 'distance_unit' field. + * @param value the value to set. + */ + public void setDistanceUnit(java.lang.CharSequence value) { + this.distance_unit = value; + } + + /** + * Creates a new StarGate RecordBuilder. + * @return A new StarGate RecordBuilder + */ + public static io.skodjob.datagenerator.models.stargate.StarGate.Builder newBuilder() { + return new io.skodjob.datagenerator.models.stargate.StarGate.Builder(); + } + + /** + * Creates a new StarGate RecordBuilder by copying an existing Builder. + * @param other The existing builder to copy. + * @return A new StarGate RecordBuilder + */ + public static io.skodjob.datagenerator.models.stargate.StarGate.Builder newBuilder(io.skodjob.datagenerator.models.stargate.StarGate.Builder other) { + if (other == null) { + return new io.skodjob.datagenerator.models.stargate.StarGate.Builder(); + } else { + return new io.skodjob.datagenerator.models.stargate.StarGate.Builder(other); + } + } + + /** + * Creates a new StarGate RecordBuilder by copying an existing StarGate instance. + * @param other The existing instance to copy. + * @return A new StarGate RecordBuilder + */ + public static io.skodjob.datagenerator.models.stargate.StarGate.Builder newBuilder(io.skodjob.datagenerator.models.stargate.StarGate other) { + if (other == null) { + return new io.skodjob.datagenerator.models.stargate.StarGate.Builder(); + } else { + return new io.skodjob.datagenerator.models.stargate.StarGate.Builder(other); + } + } + + /** + * RecordBuilder for StarGate instances. + */ + @org.apache.avro.specific.AvroGenerated + public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase + implements org.apache.avro.data.RecordBuilder { + + private java.lang.CharSequence character_name; + private java.lang.CharSequence source_planet; + private java.lang.CharSequence target_planet; + private java.lang.CharSequence quote; + private int duration; + private java.lang.CharSequence duration_unit; + private int distance; + private java.lang.CharSequence distance_unit; + + /** Creates a new Builder */ + private Builder() { + super(SCHEMA$, MODEL$); + } + + /** + * Creates a Builder by copying an existing Builder. + * @param other The existing Builder to copy. + */ + private Builder(io.skodjob.datagenerator.models.stargate.StarGate.Builder other) { + super(other); + if (isValidValue(fields()[0], other.character_name)) { + this.character_name = data().deepCopy(fields()[0].schema(), other.character_name); + fieldSetFlags()[0] = other.fieldSetFlags()[0]; + } + if (isValidValue(fields()[1], other.source_planet)) { + this.source_planet = data().deepCopy(fields()[1].schema(), other.source_planet); + fieldSetFlags()[1] = other.fieldSetFlags()[1]; + } + if (isValidValue(fields()[2], other.target_planet)) { + this.target_planet = data().deepCopy(fields()[2].schema(), other.target_planet); + fieldSetFlags()[2] = other.fieldSetFlags()[2]; + } + if (isValidValue(fields()[3], other.quote)) { + this.quote = data().deepCopy(fields()[3].schema(), other.quote); + fieldSetFlags()[3] = other.fieldSetFlags()[3]; + } + if (isValidValue(fields()[4], other.duration)) { + this.duration = data().deepCopy(fields()[4].schema(), other.duration); + fieldSetFlags()[4] = other.fieldSetFlags()[4]; + } + if (isValidValue(fields()[5], other.duration_unit)) { + this.duration_unit = data().deepCopy(fields()[5].schema(), other.duration_unit); + fieldSetFlags()[5] = other.fieldSetFlags()[5]; + } + if (isValidValue(fields()[6], other.distance)) { + this.distance = data().deepCopy(fields()[6].schema(), other.distance); + fieldSetFlags()[6] = other.fieldSetFlags()[6]; + } + if (isValidValue(fields()[7], other.distance_unit)) { + this.distance_unit = data().deepCopy(fields()[7].schema(), other.distance_unit); + fieldSetFlags()[7] = other.fieldSetFlags()[7]; + } + } + + /** + * Creates a Builder by copying an existing StarGate instance + * @param other The existing instance to copy. + */ + private Builder(io.skodjob.datagenerator.models.stargate.StarGate other) { + super(SCHEMA$, MODEL$); + if (isValidValue(fields()[0], other.character_name)) { + this.character_name = data().deepCopy(fields()[0].schema(), other.character_name); + fieldSetFlags()[0] = true; + } + if (isValidValue(fields()[1], other.source_planet)) { + this.source_planet = data().deepCopy(fields()[1].schema(), other.source_planet); + fieldSetFlags()[1] = true; + } + if (isValidValue(fields()[2], other.target_planet)) { + this.target_planet = data().deepCopy(fields()[2].schema(), other.target_planet); + fieldSetFlags()[2] = true; + } + if (isValidValue(fields()[3], other.quote)) { + this.quote = data().deepCopy(fields()[3].schema(), other.quote); + fieldSetFlags()[3] = true; + } + if (isValidValue(fields()[4], other.duration)) { + this.duration = data().deepCopy(fields()[4].schema(), other.duration); + fieldSetFlags()[4] = true; + } + if (isValidValue(fields()[5], other.duration_unit)) { + this.duration_unit = data().deepCopy(fields()[5].schema(), other.duration_unit); + fieldSetFlags()[5] = true; + } + if (isValidValue(fields()[6], other.distance)) { + this.distance = data().deepCopy(fields()[6].schema(), other.distance); + fieldSetFlags()[6] = true; + } + if (isValidValue(fields()[7], other.distance_unit)) { + this.distance_unit = data().deepCopy(fields()[7].schema(), other.distance_unit); + fieldSetFlags()[7] = true; + } + } + + /** + * Gets the value of the 'character_name' field. + * @return The value. + */ + public java.lang.CharSequence getCharacterName() { + return character_name; + } + + + /** + * Sets the value of the 'character_name' field. + * @param value The value of 'character_name'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.stargate.StarGate.Builder setCharacterName(java.lang.CharSequence value) { + validate(fields()[0], value); + this.character_name = value; + fieldSetFlags()[0] = true; + return this; + } + + /** + * Checks whether the 'character_name' field has been set. + * @return True if the 'character_name' field has been set, false otherwise. + */ + public boolean hasCharacterName() { + return fieldSetFlags()[0]; + } + + + /** + * Clears the value of the 'character_name' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.stargate.StarGate.Builder clearCharacterName() { + character_name = null; + fieldSetFlags()[0] = false; + return this; + } + + /** + * Gets the value of the 'source_planet' field. + * @return The value. + */ + public java.lang.CharSequence getSourcePlanet() { + return source_planet; + } + + + /** + * Sets the value of the 'source_planet' field. + * @param value The value of 'source_planet'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.stargate.StarGate.Builder setSourcePlanet(java.lang.CharSequence value) { + validate(fields()[1], value); + this.source_planet = value; + fieldSetFlags()[1] = true; + return this; + } + + /** + * Checks whether the 'source_planet' field has been set. + * @return True if the 'source_planet' field has been set, false otherwise. + */ + public boolean hasSourcePlanet() { + return fieldSetFlags()[1]; + } + + + /** + * Clears the value of the 'source_planet' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.stargate.StarGate.Builder clearSourcePlanet() { + source_planet = null; + fieldSetFlags()[1] = false; + return this; + } + + /** + * Gets the value of the 'target_planet' field. + * @return The value. + */ + public java.lang.CharSequence getTargetPlanet() { + return target_planet; + } + + + /** + * Sets the value of the 'target_planet' field. + * @param value The value of 'target_planet'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.stargate.StarGate.Builder setTargetPlanet(java.lang.CharSequence value) { + validate(fields()[2], value); + this.target_planet = value; + fieldSetFlags()[2] = true; + return this; + } + + /** + * Checks whether the 'target_planet' field has been set. + * @return True if the 'target_planet' field has been set, false otherwise. + */ + public boolean hasTargetPlanet() { + return fieldSetFlags()[2]; + } + + + /** + * Clears the value of the 'target_planet' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.stargate.StarGate.Builder clearTargetPlanet() { + target_planet = null; + fieldSetFlags()[2] = false; + return this; + } + + /** + * Gets the value of the 'quote' field. + * @return The value. + */ + public java.lang.CharSequence getQuote() { + return quote; + } + + + /** + * Sets the value of the 'quote' field. + * @param value The value of 'quote'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.stargate.StarGate.Builder setQuote(java.lang.CharSequence value) { + validate(fields()[3], value); + this.quote = value; + fieldSetFlags()[3] = true; + return this; + } + + /** + * Checks whether the 'quote' field has been set. + * @return True if the 'quote' field has been set, false otherwise. + */ + public boolean hasQuote() { + return fieldSetFlags()[3]; + } + + + /** + * Clears the value of the 'quote' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.stargate.StarGate.Builder clearQuote() { + quote = null; + fieldSetFlags()[3] = false; + return this; + } + + /** + * Gets the value of the 'duration' field. + * @return The value. + */ + public int getDuration() { + return duration; + } + + + /** + * Sets the value of the 'duration' field. + * @param value The value of 'duration'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.stargate.StarGate.Builder setDuration(int value) { + validate(fields()[4], value); + this.duration = value; + fieldSetFlags()[4] = true; + return this; + } + + /** + * Checks whether the 'duration' field has been set. + * @return True if the 'duration' field has been set, false otherwise. + */ + public boolean hasDuration() { + return fieldSetFlags()[4]; + } + + + /** + * Clears the value of the 'duration' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.stargate.StarGate.Builder clearDuration() { + fieldSetFlags()[4] = false; + return this; + } + + /** + * Gets the value of the 'duration_unit' field. + * @return The value. + */ + public java.lang.CharSequence getDurationUnit() { + return duration_unit; + } + + + /** + * Sets the value of the 'duration_unit' field. + * @param value The value of 'duration_unit'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.stargate.StarGate.Builder setDurationUnit(java.lang.CharSequence value) { + validate(fields()[5], value); + this.duration_unit = value; + fieldSetFlags()[5] = true; + return this; + } + + /** + * Checks whether the 'duration_unit' field has been set. + * @return True if the 'duration_unit' field has been set, false otherwise. + */ + public boolean hasDurationUnit() { + return fieldSetFlags()[5]; + } + + + /** + * Clears the value of the 'duration_unit' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.stargate.StarGate.Builder clearDurationUnit() { + duration_unit = null; + fieldSetFlags()[5] = false; + return this; + } + + /** + * Gets the value of the 'distance' field. + * @return The value. + */ + public int getDistance() { + return distance; + } + + + /** + * Sets the value of the 'distance' field. + * @param value The value of 'distance'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.stargate.StarGate.Builder setDistance(int value) { + validate(fields()[6], value); + this.distance = value; + fieldSetFlags()[6] = true; + return this; + } + + /** + * Checks whether the 'distance' field has been set. + * @return True if the 'distance' field has been set, false otherwise. + */ + public boolean hasDistance() { + return fieldSetFlags()[6]; + } + + + /** + * Clears the value of the 'distance' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.stargate.StarGate.Builder clearDistance() { + fieldSetFlags()[6] = false; + return this; + } + + /** + * Gets the value of the 'distance_unit' field. + * @return The value. + */ + public java.lang.CharSequence getDistanceUnit() { + return distance_unit; + } + + + /** + * Sets the value of the 'distance_unit' field. + * @param value The value of 'distance_unit'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.stargate.StarGate.Builder setDistanceUnit(java.lang.CharSequence value) { + validate(fields()[7], value); + this.distance_unit = value; + fieldSetFlags()[7] = true; + return this; + } + + /** + * Checks whether the 'distance_unit' field has been set. + * @return True if the 'distance_unit' field has been set, false otherwise. + */ + public boolean hasDistanceUnit() { + return fieldSetFlags()[7]; + } + + + /** + * Clears the value of the 'distance_unit' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.stargate.StarGate.Builder clearDistanceUnit() { + distance_unit = null; + fieldSetFlags()[7] = false; + return this; + } + + @Override + @SuppressWarnings("unchecked") + public StarGate build() { + try { + StarGate record = new StarGate(); + record.character_name = fieldSetFlags()[0] ? this.character_name : (java.lang.CharSequence) defaultValue(fields()[0]); + record.source_planet = fieldSetFlags()[1] ? this.source_planet : (java.lang.CharSequence) defaultValue(fields()[1]); + record.target_planet = fieldSetFlags()[2] ? this.target_planet : (java.lang.CharSequence) defaultValue(fields()[2]); + record.quote = fieldSetFlags()[3] ? this.quote : (java.lang.CharSequence) defaultValue(fields()[3]); + record.duration = fieldSetFlags()[4] ? this.duration : (java.lang.Integer) defaultValue(fields()[4]); + record.duration_unit = fieldSetFlags()[5] ? this.duration_unit : (java.lang.CharSequence) defaultValue(fields()[5]); + record.distance = fieldSetFlags()[6] ? this.distance : (java.lang.Integer) defaultValue(fields()[6]); + record.distance_unit = fieldSetFlags()[7] ? this.distance_unit : (java.lang.CharSequence) defaultValue(fields()[7]); + return record; + } catch (org.apache.avro.AvroMissingFieldException e) { + throw e; + } catch (java.lang.Exception e) { + throw new org.apache.avro.AvroRuntimeException(e); + } + } + } + + @SuppressWarnings("unchecked") + private static final org.apache.avro.io.DatumWriter + WRITER$ = (org.apache.avro.io.DatumWriter)MODEL$.createDatumWriter(SCHEMA$); + + @Override public void writeExternal(java.io.ObjectOutput out) + throws java.io.IOException { + WRITER$.write(this, SpecificData.getEncoder(out)); + } + + @SuppressWarnings("unchecked") + private static final org.apache.avro.io.DatumReader + READER$ = (org.apache.avro.io.DatumReader)MODEL$.createDatumReader(SCHEMA$); + + @Override public void readExternal(java.io.ObjectInput in) + throws java.io.IOException { + READER$.read(this, SpecificData.getDecoder(in)); + } + + @Override protected boolean hasCustomCoders() { return true; } + + @Override public void customEncode(org.apache.avro.io.Encoder out) + throws java.io.IOException + { + out.writeString(this.character_name); + + out.writeString(this.source_planet); + + out.writeString(this.target_planet); + + out.writeString(this.quote); + + out.writeInt(this.duration); + + out.writeString(this.duration_unit); + + out.writeInt(this.distance); + + out.writeString(this.distance_unit); + + } + + @Override public void customDecode(org.apache.avro.io.ResolvingDecoder in) + throws java.io.IOException + { + org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff(); + if (fieldOrder == null) { + this.character_name = in.readString(this.character_name instanceof Utf8 ? (Utf8)this.character_name : null); + + this.source_planet = in.readString(this.source_planet instanceof Utf8 ? (Utf8)this.source_planet : null); + + this.target_planet = in.readString(this.target_planet instanceof Utf8 ? (Utf8)this.target_planet : null); + + this.quote = in.readString(this.quote instanceof Utf8 ? (Utf8)this.quote : null); + + this.duration = in.readInt(); + + this.duration_unit = in.readString(this.duration_unit instanceof Utf8 ? (Utf8)this.duration_unit : null); + + this.distance = in.readInt(); + + this.distance_unit = in.readString(this.distance_unit instanceof Utf8 ? (Utf8)this.distance_unit : null); + + } else { + for (int i = 0; i < 8; i++) { + switch (fieldOrder[i].pos()) { + case 0: + this.character_name = in.readString(this.character_name instanceof Utf8 ? (Utf8)this.character_name : null); + break; + + case 1: + this.source_planet = in.readString(this.source_planet instanceof Utf8 ? (Utf8)this.source_planet : null); + break; + + case 2: + this.target_planet = in.readString(this.target_planet instanceof Utf8 ? (Utf8)this.target_planet : null); + break; + + case 3: + this.quote = in.readString(this.quote instanceof Utf8 ? (Utf8)this.quote : null); + break; + + case 4: + this.duration = in.readInt(); + break; + + case 5: + this.duration_unit = in.readString(this.duration_unit instanceof Utf8 ? (Utf8)this.duration_unit : null); + break; + + case 6: + this.distance = in.readInt(); + break; + + case 7: + this.distance_unit = in.readString(this.distance_unit instanceof Utf8 ? (Utf8)this.distance_unit : null); + break; + + default: + throw new java.io.IOException("Corrupt ResolvingDecoder."); + } + } + } + } +} + + + + + + + + + + diff --git a/src/main/java/io/skodjob/datagenerator/models/starwars/StarWars.java b/src/main/java/io/skodjob/datagenerator/models/starwars/StarWars.java new file mode 100644 index 0000000..89a4564 --- /dev/null +++ b/src/main/java/io/skodjob/datagenerator/models/starwars/StarWars.java @@ -0,0 +1,959 @@ +/** + * Autogenerated by Avro + * + * DO NOT EDIT DIRECTLY + */ +package io.skodjob.datagenerator.models.starwars; + +import org.apache.avro.generic.GenericArray; +import org.apache.avro.specific.SpecificData; +import org.apache.avro.util.Utf8; +import org.apache.avro.message.BinaryMessageEncoder; +import org.apache.avro.message.BinaryMessageDecoder; +import org.apache.avro.message.SchemaStore; + +@org.apache.avro.specific.AvroGenerated +public class StarWars extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord { + private static final long serialVersionUID = -1351044176025905925L; + + + public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"StarWars\",\"namespace\":\"io.skodjob.datagenerator.models.starwars\",\"fields\":[{\"name\":\"character_name\",\"type\":\"string\"},{\"name\":\"source_planet\",\"type\":\"string\"},{\"name\":\"target_planet\",\"type\":\"string\"},{\"name\":\"quote\",\"type\":\"string\"},{\"name\":\"callSign\",\"type\":\"string\"},{\"name\":\"species\",\"type\":\"string\"},{\"name\":\"vehicle\",\"type\":\"string\"},{\"name\":\"wookieWords\",\"type\":\"string\"},{\"name\":\"alternateCharacterSpelling\",\"type\":\"string\"}]}"); + public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } + + private static final SpecificData MODEL$ = new SpecificData(); + + private static final BinaryMessageEncoder ENCODER = + new BinaryMessageEncoder<>(MODEL$, SCHEMA$); + + private static final BinaryMessageDecoder DECODER = + new BinaryMessageDecoder<>(MODEL$, SCHEMA$); + + /** + * Return the BinaryMessageEncoder instance used by this class. + * @return the message encoder used by this class + */ + public static BinaryMessageEncoder getEncoder() { + return ENCODER; + } + + /** + * Return the BinaryMessageDecoder instance used by this class. + * @return the message decoder used by this class + */ + public static BinaryMessageDecoder getDecoder() { + return DECODER; + } + + /** + * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}. + * @param resolver a {@link SchemaStore} used to find schemas by fingerprint + * @return a BinaryMessageDecoder instance for this class backed by the given SchemaStore + */ + public static BinaryMessageDecoder createDecoder(SchemaStore resolver) { + return new BinaryMessageDecoder<>(MODEL$, SCHEMA$, resolver); + } + + /** + * Serializes this StarWars to a ByteBuffer. + * @return a buffer holding the serialized data for this instance + * @throws java.io.IOException if this instance could not be serialized + */ + public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException { + return ENCODER.encode(this); + } + + /** + * Deserializes a StarWars from a ByteBuffer. + * @param b a byte buffer holding serialized data for an instance of this class + * @return a StarWars instance decoded from the given buffer + * @throws java.io.IOException if the given bytes could not be deserialized into an instance of this class + */ + public static StarWars fromByteBuffer( + java.nio.ByteBuffer b) throws java.io.IOException { + return DECODER.decode(b); + } + + private java.lang.CharSequence character_name; + private java.lang.CharSequence source_planet; + private java.lang.CharSequence target_planet; + private java.lang.CharSequence quote; + private java.lang.CharSequence callSign; + private java.lang.CharSequence species; + private java.lang.CharSequence vehicle; + private java.lang.CharSequence wookieWords; + private java.lang.CharSequence alternateCharacterSpelling; + + /** + * Default constructor. Note that this does not initialize fields + * to their default values from the schema. If that is desired then + * one should use newBuilder(). + */ + public StarWars() {} + + /** + * All-args constructor. + * @param character_name The new value for character_name + * @param source_planet The new value for source_planet + * @param target_planet The new value for target_planet + * @param quote The new value for quote + * @param callSign The new value for callSign + * @param species The new value for species + * @param vehicle The new value for vehicle + * @param wookieWords The new value for wookieWords + * @param alternateCharacterSpelling The new value for alternateCharacterSpelling + */ + public StarWars(java.lang.CharSequence character_name, java.lang.CharSequence source_planet, java.lang.CharSequence target_planet, java.lang.CharSequence quote, java.lang.CharSequence callSign, java.lang.CharSequence species, java.lang.CharSequence vehicle, java.lang.CharSequence wookieWords, java.lang.CharSequence alternateCharacterSpelling) { + this.character_name = character_name; + this.source_planet = source_planet; + this.target_planet = target_planet; + this.quote = quote; + this.callSign = callSign; + this.species = species; + this.vehicle = vehicle; + this.wookieWords = wookieWords; + this.alternateCharacterSpelling = alternateCharacterSpelling; + } + + @Override + public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; } + + @Override + public org.apache.avro.Schema getSchema() { return SCHEMA$; } + + // Used by DatumWriter. Applications should not call. + @Override + public java.lang.Object get(int field$) { + switch (field$) { + case 0: return character_name; + case 1: return source_planet; + case 2: return target_planet; + case 3: return quote; + case 4: return callSign; + case 5: return species; + case 6: return vehicle; + case 7: return wookieWords; + case 8: return alternateCharacterSpelling; + default: throw new IndexOutOfBoundsException("Invalid index: " + field$); + } + } + + // Used by DatumReader. Applications should not call. + @Override + @SuppressWarnings(value="unchecked") + public void put(int field$, java.lang.Object value$) { + switch (field$) { + case 0: character_name = (java.lang.CharSequence)value$; break; + case 1: source_planet = (java.lang.CharSequence)value$; break; + case 2: target_planet = (java.lang.CharSequence)value$; break; + case 3: quote = (java.lang.CharSequence)value$; break; + case 4: callSign = (java.lang.CharSequence)value$; break; + case 5: species = (java.lang.CharSequence)value$; break; + case 6: vehicle = (java.lang.CharSequence)value$; break; + case 7: wookieWords = (java.lang.CharSequence)value$; break; + case 8: alternateCharacterSpelling = (java.lang.CharSequence)value$; break; + default: throw new IndexOutOfBoundsException("Invalid index: " + field$); + } + } + + /** + * Gets the value of the 'character_name' field. + * @return The value of the 'character_name' field. + */ + public java.lang.CharSequence getCharacterName() { + return character_name; + } + + + /** + * Sets the value of the 'character_name' field. + * @param value the value to set. + */ + public void setCharacterName(java.lang.CharSequence value) { + this.character_name = value; + } + + /** + * Gets the value of the 'source_planet' field. + * @return The value of the 'source_planet' field. + */ + public java.lang.CharSequence getSourcePlanet() { + return source_planet; + } + + + /** + * Sets the value of the 'source_planet' field. + * @param value the value to set. + */ + public void setSourcePlanet(java.lang.CharSequence value) { + this.source_planet = value; + } + + /** + * Gets the value of the 'target_planet' field. + * @return The value of the 'target_planet' field. + */ + public java.lang.CharSequence getTargetPlanet() { + return target_planet; + } + + + /** + * Sets the value of the 'target_planet' field. + * @param value the value to set. + */ + public void setTargetPlanet(java.lang.CharSequence value) { + this.target_planet = value; + } + + /** + * Gets the value of the 'quote' field. + * @return The value of the 'quote' field. + */ + public java.lang.CharSequence getQuote() { + return quote; + } + + + /** + * Sets the value of the 'quote' field. + * @param value the value to set. + */ + public void setQuote(java.lang.CharSequence value) { + this.quote = value; + } + + /** + * Gets the value of the 'callSign' field. + * @return The value of the 'callSign' field. + */ + public java.lang.CharSequence getCallSign() { + return callSign; + } + + + /** + * Sets the value of the 'callSign' field. + * @param value the value to set. + */ + public void setCallSign(java.lang.CharSequence value) { + this.callSign = value; + } + + /** + * Gets the value of the 'species' field. + * @return The value of the 'species' field. + */ + public java.lang.CharSequence getSpecies() { + return species; + } + + + /** + * Sets the value of the 'species' field. + * @param value the value to set. + */ + public void setSpecies(java.lang.CharSequence value) { + this.species = value; + } + + /** + * Gets the value of the 'vehicle' field. + * @return The value of the 'vehicle' field. + */ + public java.lang.CharSequence getVehicle() { + return vehicle; + } + + + /** + * Sets the value of the 'vehicle' field. + * @param value the value to set. + */ + public void setVehicle(java.lang.CharSequence value) { + this.vehicle = value; + } + + /** + * Gets the value of the 'wookieWords' field. + * @return The value of the 'wookieWords' field. + */ + public java.lang.CharSequence getWookieWords() { + return wookieWords; + } + + + /** + * Sets the value of the 'wookieWords' field. + * @param value the value to set. + */ + public void setWookieWords(java.lang.CharSequence value) { + this.wookieWords = value; + } + + /** + * Gets the value of the 'alternateCharacterSpelling' field. + * @return The value of the 'alternateCharacterSpelling' field. + */ + public java.lang.CharSequence getAlternateCharacterSpelling() { + return alternateCharacterSpelling; + } + + + /** + * Sets the value of the 'alternateCharacterSpelling' field. + * @param value the value to set. + */ + public void setAlternateCharacterSpelling(java.lang.CharSequence value) { + this.alternateCharacterSpelling = value; + } + + /** + * Creates a new StarWars RecordBuilder. + * @return A new StarWars RecordBuilder + */ + public static io.skodjob.datagenerator.models.starwars.StarWars.Builder newBuilder() { + return new io.skodjob.datagenerator.models.starwars.StarWars.Builder(); + } + + /** + * Creates a new StarWars RecordBuilder by copying an existing Builder. + * @param other The existing builder to copy. + * @return A new StarWars RecordBuilder + */ + public static io.skodjob.datagenerator.models.starwars.StarWars.Builder newBuilder(io.skodjob.datagenerator.models.starwars.StarWars.Builder other) { + if (other == null) { + return new io.skodjob.datagenerator.models.starwars.StarWars.Builder(); + } else { + return new io.skodjob.datagenerator.models.starwars.StarWars.Builder(other); + } + } + + /** + * Creates a new StarWars RecordBuilder by copying an existing StarWars instance. + * @param other The existing instance to copy. + * @return A new StarWars RecordBuilder + */ + public static io.skodjob.datagenerator.models.starwars.StarWars.Builder newBuilder(io.skodjob.datagenerator.models.starwars.StarWars other) { + if (other == null) { + return new io.skodjob.datagenerator.models.starwars.StarWars.Builder(); + } else { + return new io.skodjob.datagenerator.models.starwars.StarWars.Builder(other); + } + } + + /** + * RecordBuilder for StarWars instances. + */ + @org.apache.avro.specific.AvroGenerated + public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase + implements org.apache.avro.data.RecordBuilder { + + private java.lang.CharSequence character_name; + private java.lang.CharSequence source_planet; + private java.lang.CharSequence target_planet; + private java.lang.CharSequence quote; + private java.lang.CharSequence callSign; + private java.lang.CharSequence species; + private java.lang.CharSequence vehicle; + private java.lang.CharSequence wookieWords; + private java.lang.CharSequence alternateCharacterSpelling; + + /** Creates a new Builder */ + private Builder() { + super(SCHEMA$, MODEL$); + } + + /** + * Creates a Builder by copying an existing Builder. + * @param other The existing Builder to copy. + */ + private Builder(io.skodjob.datagenerator.models.starwars.StarWars.Builder other) { + super(other); + if (isValidValue(fields()[0], other.character_name)) { + this.character_name = data().deepCopy(fields()[0].schema(), other.character_name); + fieldSetFlags()[0] = other.fieldSetFlags()[0]; + } + if (isValidValue(fields()[1], other.source_planet)) { + this.source_planet = data().deepCopy(fields()[1].schema(), other.source_planet); + fieldSetFlags()[1] = other.fieldSetFlags()[1]; + } + if (isValidValue(fields()[2], other.target_planet)) { + this.target_planet = data().deepCopy(fields()[2].schema(), other.target_planet); + fieldSetFlags()[2] = other.fieldSetFlags()[2]; + } + if (isValidValue(fields()[3], other.quote)) { + this.quote = data().deepCopy(fields()[3].schema(), other.quote); + fieldSetFlags()[3] = other.fieldSetFlags()[3]; + } + if (isValidValue(fields()[4], other.callSign)) { + this.callSign = data().deepCopy(fields()[4].schema(), other.callSign); + fieldSetFlags()[4] = other.fieldSetFlags()[4]; + } + if (isValidValue(fields()[5], other.species)) { + this.species = data().deepCopy(fields()[5].schema(), other.species); + fieldSetFlags()[5] = other.fieldSetFlags()[5]; + } + if (isValidValue(fields()[6], other.vehicle)) { + this.vehicle = data().deepCopy(fields()[6].schema(), other.vehicle); + fieldSetFlags()[6] = other.fieldSetFlags()[6]; + } + if (isValidValue(fields()[7], other.wookieWords)) { + this.wookieWords = data().deepCopy(fields()[7].schema(), other.wookieWords); + fieldSetFlags()[7] = other.fieldSetFlags()[7]; + } + if (isValidValue(fields()[8], other.alternateCharacterSpelling)) { + this.alternateCharacterSpelling = data().deepCopy(fields()[8].schema(), other.alternateCharacterSpelling); + fieldSetFlags()[8] = other.fieldSetFlags()[8]; + } + } + + /** + * Creates a Builder by copying an existing StarWars instance + * @param other The existing instance to copy. + */ + private Builder(io.skodjob.datagenerator.models.starwars.StarWars other) { + super(SCHEMA$, MODEL$); + if (isValidValue(fields()[0], other.character_name)) { + this.character_name = data().deepCopy(fields()[0].schema(), other.character_name); + fieldSetFlags()[0] = true; + } + if (isValidValue(fields()[1], other.source_planet)) { + this.source_planet = data().deepCopy(fields()[1].schema(), other.source_planet); + fieldSetFlags()[1] = true; + } + if (isValidValue(fields()[2], other.target_planet)) { + this.target_planet = data().deepCopy(fields()[2].schema(), other.target_planet); + fieldSetFlags()[2] = true; + } + if (isValidValue(fields()[3], other.quote)) { + this.quote = data().deepCopy(fields()[3].schema(), other.quote); + fieldSetFlags()[3] = true; + } + if (isValidValue(fields()[4], other.callSign)) { + this.callSign = data().deepCopy(fields()[4].schema(), other.callSign); + fieldSetFlags()[4] = true; + } + if (isValidValue(fields()[5], other.species)) { + this.species = data().deepCopy(fields()[5].schema(), other.species); + fieldSetFlags()[5] = true; + } + if (isValidValue(fields()[6], other.vehicle)) { + this.vehicle = data().deepCopy(fields()[6].schema(), other.vehicle); + fieldSetFlags()[6] = true; + } + if (isValidValue(fields()[7], other.wookieWords)) { + this.wookieWords = data().deepCopy(fields()[7].schema(), other.wookieWords); + fieldSetFlags()[7] = true; + } + if (isValidValue(fields()[8], other.alternateCharacterSpelling)) { + this.alternateCharacterSpelling = data().deepCopy(fields()[8].schema(), other.alternateCharacterSpelling); + fieldSetFlags()[8] = true; + } + } + + /** + * Gets the value of the 'character_name' field. + * @return The value. + */ + public java.lang.CharSequence getCharacterName() { + return character_name; + } + + + /** + * Sets the value of the 'character_name' field. + * @param value The value of 'character_name'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.starwars.StarWars.Builder setCharacterName(java.lang.CharSequence value) { + validate(fields()[0], value); + this.character_name = value; + fieldSetFlags()[0] = true; + return this; + } + + /** + * Checks whether the 'character_name' field has been set. + * @return True if the 'character_name' field has been set, false otherwise. + */ + public boolean hasCharacterName() { + return fieldSetFlags()[0]; + } + + + /** + * Clears the value of the 'character_name' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.starwars.StarWars.Builder clearCharacterName() { + character_name = null; + fieldSetFlags()[0] = false; + return this; + } + + /** + * Gets the value of the 'source_planet' field. + * @return The value. + */ + public java.lang.CharSequence getSourcePlanet() { + return source_planet; + } + + + /** + * Sets the value of the 'source_planet' field. + * @param value The value of 'source_planet'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.starwars.StarWars.Builder setSourcePlanet(java.lang.CharSequence value) { + validate(fields()[1], value); + this.source_planet = value; + fieldSetFlags()[1] = true; + return this; + } + + /** + * Checks whether the 'source_planet' field has been set. + * @return True if the 'source_planet' field has been set, false otherwise. + */ + public boolean hasSourcePlanet() { + return fieldSetFlags()[1]; + } + + + /** + * Clears the value of the 'source_planet' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.starwars.StarWars.Builder clearSourcePlanet() { + source_planet = null; + fieldSetFlags()[1] = false; + return this; + } + + /** + * Gets the value of the 'target_planet' field. + * @return The value. + */ + public java.lang.CharSequence getTargetPlanet() { + return target_planet; + } + + + /** + * Sets the value of the 'target_planet' field. + * @param value The value of 'target_planet'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.starwars.StarWars.Builder setTargetPlanet(java.lang.CharSequence value) { + validate(fields()[2], value); + this.target_planet = value; + fieldSetFlags()[2] = true; + return this; + } + + /** + * Checks whether the 'target_planet' field has been set. + * @return True if the 'target_planet' field has been set, false otherwise. + */ + public boolean hasTargetPlanet() { + return fieldSetFlags()[2]; + } + + + /** + * Clears the value of the 'target_planet' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.starwars.StarWars.Builder clearTargetPlanet() { + target_planet = null; + fieldSetFlags()[2] = false; + return this; + } + + /** + * Gets the value of the 'quote' field. + * @return The value. + */ + public java.lang.CharSequence getQuote() { + return quote; + } + + + /** + * Sets the value of the 'quote' field. + * @param value The value of 'quote'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.starwars.StarWars.Builder setQuote(java.lang.CharSequence value) { + validate(fields()[3], value); + this.quote = value; + fieldSetFlags()[3] = true; + return this; + } + + /** + * Checks whether the 'quote' field has been set. + * @return True if the 'quote' field has been set, false otherwise. + */ + public boolean hasQuote() { + return fieldSetFlags()[3]; + } + + + /** + * Clears the value of the 'quote' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.starwars.StarWars.Builder clearQuote() { + quote = null; + fieldSetFlags()[3] = false; + return this; + } + + /** + * Gets the value of the 'callSign' field. + * @return The value. + */ + public java.lang.CharSequence getCallSign() { + return callSign; + } + + + /** + * Sets the value of the 'callSign' field. + * @param value The value of 'callSign'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.starwars.StarWars.Builder setCallSign(java.lang.CharSequence value) { + validate(fields()[4], value); + this.callSign = value; + fieldSetFlags()[4] = true; + return this; + } + + /** + * Checks whether the 'callSign' field has been set. + * @return True if the 'callSign' field has been set, false otherwise. + */ + public boolean hasCallSign() { + return fieldSetFlags()[4]; + } + + + /** + * Clears the value of the 'callSign' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.starwars.StarWars.Builder clearCallSign() { + callSign = null; + fieldSetFlags()[4] = false; + return this; + } + + /** + * Gets the value of the 'species' field. + * @return The value. + */ + public java.lang.CharSequence getSpecies() { + return species; + } + + + /** + * Sets the value of the 'species' field. + * @param value The value of 'species'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.starwars.StarWars.Builder setSpecies(java.lang.CharSequence value) { + validate(fields()[5], value); + this.species = value; + fieldSetFlags()[5] = true; + return this; + } + + /** + * Checks whether the 'species' field has been set. + * @return True if the 'species' field has been set, false otherwise. + */ + public boolean hasSpecies() { + return fieldSetFlags()[5]; + } + + + /** + * Clears the value of the 'species' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.starwars.StarWars.Builder clearSpecies() { + species = null; + fieldSetFlags()[5] = false; + return this; + } + + /** + * Gets the value of the 'vehicle' field. + * @return The value. + */ + public java.lang.CharSequence getVehicle() { + return vehicle; + } + + + /** + * Sets the value of the 'vehicle' field. + * @param value The value of 'vehicle'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.starwars.StarWars.Builder setVehicle(java.lang.CharSequence value) { + validate(fields()[6], value); + this.vehicle = value; + fieldSetFlags()[6] = true; + return this; + } + + /** + * Checks whether the 'vehicle' field has been set. + * @return True if the 'vehicle' field has been set, false otherwise. + */ + public boolean hasVehicle() { + return fieldSetFlags()[6]; + } + + + /** + * Clears the value of the 'vehicle' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.starwars.StarWars.Builder clearVehicle() { + vehicle = null; + fieldSetFlags()[6] = false; + return this; + } + + /** + * Gets the value of the 'wookieWords' field. + * @return The value. + */ + public java.lang.CharSequence getWookieWords() { + return wookieWords; + } + + + /** + * Sets the value of the 'wookieWords' field. + * @param value The value of 'wookieWords'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.starwars.StarWars.Builder setWookieWords(java.lang.CharSequence value) { + validate(fields()[7], value); + this.wookieWords = value; + fieldSetFlags()[7] = true; + return this; + } + + /** + * Checks whether the 'wookieWords' field has been set. + * @return True if the 'wookieWords' field has been set, false otherwise. + */ + public boolean hasWookieWords() { + return fieldSetFlags()[7]; + } + + + /** + * Clears the value of the 'wookieWords' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.starwars.StarWars.Builder clearWookieWords() { + wookieWords = null; + fieldSetFlags()[7] = false; + return this; + } + + /** + * Gets the value of the 'alternateCharacterSpelling' field. + * @return The value. + */ + public java.lang.CharSequence getAlternateCharacterSpelling() { + return alternateCharacterSpelling; + } + + + /** + * Sets the value of the 'alternateCharacterSpelling' field. + * @param value The value of 'alternateCharacterSpelling'. + * @return This builder. + */ + public io.skodjob.datagenerator.models.starwars.StarWars.Builder setAlternateCharacterSpelling(java.lang.CharSequence value) { + validate(fields()[8], value); + this.alternateCharacterSpelling = value; + fieldSetFlags()[8] = true; + return this; + } + + /** + * Checks whether the 'alternateCharacterSpelling' field has been set. + * @return True if the 'alternateCharacterSpelling' field has been set, false otherwise. + */ + public boolean hasAlternateCharacterSpelling() { + return fieldSetFlags()[8]; + } + + + /** + * Clears the value of the 'alternateCharacterSpelling' field. + * @return This builder. + */ + public io.skodjob.datagenerator.models.starwars.StarWars.Builder clearAlternateCharacterSpelling() { + alternateCharacterSpelling = null; + fieldSetFlags()[8] = false; + return this; + } + + @Override + @SuppressWarnings("unchecked") + public StarWars build() { + try { + StarWars record = new StarWars(); + record.character_name = fieldSetFlags()[0] ? this.character_name : (java.lang.CharSequence) defaultValue(fields()[0]); + record.source_planet = fieldSetFlags()[1] ? this.source_planet : (java.lang.CharSequence) defaultValue(fields()[1]); + record.target_planet = fieldSetFlags()[2] ? this.target_planet : (java.lang.CharSequence) defaultValue(fields()[2]); + record.quote = fieldSetFlags()[3] ? this.quote : (java.lang.CharSequence) defaultValue(fields()[3]); + record.callSign = fieldSetFlags()[4] ? this.callSign : (java.lang.CharSequence) defaultValue(fields()[4]); + record.species = fieldSetFlags()[5] ? this.species : (java.lang.CharSequence) defaultValue(fields()[5]); + record.vehicle = fieldSetFlags()[6] ? this.vehicle : (java.lang.CharSequence) defaultValue(fields()[6]); + record.wookieWords = fieldSetFlags()[7] ? this.wookieWords : (java.lang.CharSequence) defaultValue(fields()[7]); + record.alternateCharacterSpelling = fieldSetFlags()[8] ? this.alternateCharacterSpelling : (java.lang.CharSequence) defaultValue(fields()[8]); + return record; + } catch (org.apache.avro.AvroMissingFieldException e) { + throw e; + } catch (java.lang.Exception e) { + throw new org.apache.avro.AvroRuntimeException(e); + } + } + } + + @SuppressWarnings("unchecked") + private static final org.apache.avro.io.DatumWriter + WRITER$ = (org.apache.avro.io.DatumWriter)MODEL$.createDatumWriter(SCHEMA$); + + @Override public void writeExternal(java.io.ObjectOutput out) + throws java.io.IOException { + WRITER$.write(this, SpecificData.getEncoder(out)); + } + + @SuppressWarnings("unchecked") + private static final org.apache.avro.io.DatumReader + READER$ = (org.apache.avro.io.DatumReader)MODEL$.createDatumReader(SCHEMA$); + + @Override public void readExternal(java.io.ObjectInput in) + throws java.io.IOException { + READER$.read(this, SpecificData.getDecoder(in)); + } + + @Override protected boolean hasCustomCoders() { return true; } + + @Override public void customEncode(org.apache.avro.io.Encoder out) + throws java.io.IOException + { + out.writeString(this.character_name); + + out.writeString(this.source_planet); + + out.writeString(this.target_planet); + + out.writeString(this.quote); + + out.writeString(this.callSign); + + out.writeString(this.species); + + out.writeString(this.vehicle); + + out.writeString(this.wookieWords); + + out.writeString(this.alternateCharacterSpelling); + + } + + @Override public void customDecode(org.apache.avro.io.ResolvingDecoder in) + throws java.io.IOException + { + org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff(); + if (fieldOrder == null) { + this.character_name = in.readString(this.character_name instanceof Utf8 ? (Utf8)this.character_name : null); + + this.source_planet = in.readString(this.source_planet instanceof Utf8 ? (Utf8)this.source_planet : null); + + this.target_planet = in.readString(this.target_planet instanceof Utf8 ? (Utf8)this.target_planet : null); + + this.quote = in.readString(this.quote instanceof Utf8 ? (Utf8)this.quote : null); + + this.callSign = in.readString(this.callSign instanceof Utf8 ? (Utf8)this.callSign : null); + + this.species = in.readString(this.species instanceof Utf8 ? (Utf8)this.species : null); + + this.vehicle = in.readString(this.vehicle instanceof Utf8 ? (Utf8)this.vehicle : null); + + this.wookieWords = in.readString(this.wookieWords instanceof Utf8 ? (Utf8)this.wookieWords : null); + + this.alternateCharacterSpelling = in.readString(this.alternateCharacterSpelling instanceof Utf8 ? (Utf8)this.alternateCharacterSpelling : null); + + } else { + for (int i = 0; i < 9; i++) { + switch (fieldOrder[i].pos()) { + case 0: + this.character_name = in.readString(this.character_name instanceof Utf8 ? (Utf8)this.character_name : null); + break; + + case 1: + this.source_planet = in.readString(this.source_planet instanceof Utf8 ? (Utf8)this.source_planet : null); + break; + + case 2: + this.target_planet = in.readString(this.target_planet instanceof Utf8 ? (Utf8)this.target_planet : null); + break; + + case 3: + this.quote = in.readString(this.quote instanceof Utf8 ? (Utf8)this.quote : null); + break; + + case 4: + this.callSign = in.readString(this.callSign instanceof Utf8 ? (Utf8)this.callSign : null); + break; + + case 5: + this.species = in.readString(this.species instanceof Utf8 ? (Utf8)this.species : null); + break; + + case 6: + this.vehicle = in.readString(this.vehicle instanceof Utf8 ? (Utf8)this.vehicle : null); + break; + + case 7: + this.wookieWords = in.readString(this.wookieWords instanceof Utf8 ? (Utf8)this.wookieWords : null); + break; + + case 8: + this.alternateCharacterSpelling = in.readString(this.alternateCharacterSpelling instanceof Utf8 ? (Utf8)this.alternateCharacterSpelling : null); + break; + + default: + throw new java.io.IOException("Corrupt ResolvingDecoder."); + } + } + } + } +} + + + + + + + + + + diff --git a/src/test/java/io/skodjob/datagenerator/DataGeneratorTest.java b/src/test/java/io/skodjob/datagenerator/DataGeneratorTest.java index 2569455..c5f0238 100644 --- a/src/test/java/io/skodjob/datagenerator/DataGeneratorTest.java +++ b/src/test/java/io/skodjob/datagenerator/DataGeneratorTest.java @@ -13,6 +13,7 @@ import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; +import java.io.IOException; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.IntStream; @@ -41,10 +42,10 @@ void setUp() { @ParameterizedTest(name = "{0}") @MethodSource("testRepeatedParameters") - void testValidateGeneratedData(String testName, String regex, DataGenerator generator) { + void testValidateGeneratedData(String testName, String regex, DataGenerator generator) throws IOException { Pattern dataPattern = Pattern.compile(regex); - String data = generator.generateStringData(); + String data = generator.generateJsonData().toString(); assertNotNull(data, "Generated string data should not be null for PAYROLL_EMPLOYEE"); Matcher matcher = dataPattern.matcher(data); @@ -69,12 +70,12 @@ void checkJsonData(DataGenerator generator) { public Stream testRepeatedParameters() { String peopleRegex = "\\{" - + "\"employee_id\":\"\\d+\"," - + "\"first_name\":\"[A-Za-z']+\"," - + "\"last_name\":\"[A-Za-z']+\"," + + "\"employeeId\":\"\\d+\"," + + "\"firstName\":\"[A-Za-z']+\"," + + "\"lastName\":\"[A-Za-z']+\"," + "\"age\":\\d+," + "\"ssn\":\"\\d+-\\d+-\\d+\"," - + "\"hourly_rate\":\\d+\\.\\d+," + + "\"hourlyRate\":\\d+\\.\\d+," + "\"gender\":\"(Male|Female)\"," + "\"email\":\"[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}\"," + "\"company\":\"[A-Za-z-&\\.\\,\\-' ]+\"" @@ -96,7 +97,7 @@ public Stream testRepeatedParameters() { "\"quote\":\"[^\"]*\"," + "\"duration\":[0-9]+," + "\"duration_unit\":\"seconds\"," + - "\"distance\":\"[0-9]+\"," + + "\"distance\":[0-9]+," + "\"distance_unit\":\"light_year\"\\}"; String starWarsRegex = "\\{\"character_name\":\"[\\w\\s'-]+\"," + @@ -109,33 +110,33 @@ public Stream testRepeatedParameters() { "\"wookieWords\":\"[^\"]*\"," + "\"alternateCharacterSpelling\":\"[^\"]*\"\\}"; - String paymentFiatRegex = "\\{\"payment\":\\{\"transaction_id\":\"txn_[0-9]{10}\"," + - "\"type\":\"(credit_card|bank_transfer|paypal)\"," + - "\"amount\":[0-9]+\\.[0-9]{2}," + + String paymentFiatRegex = "\\{\"paymentDetails\":\\{\"transactionId\":\"txn_[0-9]{10}\"," + + "\"type\":\"(creditCard|bankTransfer|paypal)\"," + + "\"amount\":[0-9]+\\.[0-9]{1,}," + "\"currency\":\"[A-Z]{1,}\"," + "\"date\":\"[0-9T:\\-\\+\\.Z]+\"," + "\"status\":\"(completed|pending|failed)\"\\}," + "\"payer\":\\{\"name\":\"[^\"]{3,}\"," + "\"payerType\":\"(company|person)\"," + - "\"account_number\":\"[0-9]{9}\"," + + "\"accountNumber\":\"[0-9]{9}\"," + "\"bank\":\"[^\"]{3,}\"," + - "\"billing_address\":\\{\"street\":\"[^\"]{3,}\"," + + "\"billingAddress\":\\{\"street\":\"[^\"]{3,}\"," + "\"city\":\"[^\"]{3,}\"," + "\"state\":\"[^\"]{3,}\"," + "\"country\":\"[^\"]{3,}\"," + - "\"postal_code\":\"[^\"]{3,}\"\\}" + - "(,\"card_number\":\"[0-9\\-]+\"," + - "\"card_type\":\"(Visa|MasterCard|American Express|Revolut|Wise|CityGroup|Barclays)\"," + - "\"expiry_date\":\"[0-9\\-]+\")?\\}," + + "\"postalCode\":\"[^\"]{3,}\"\\}" + + "(,\"cardNumber\":(null|\"[0-9\\-]+\")," + + "\"cardType\":(null|\"[^\"]{3,}\")," + + "\"expiryDate\":(null|\"[0-9\\-]+\"))?\\}," + "\"payee\":\\{\"name\":\"[^\"]{3,}\"," + "\"payeeType\":\"(company|person)\"," + - "\"account_number\":\"[0-9]{9}\"," + + "\"accountNumber\":\"[0-9]{9}\"," + "\"bank\":\"[^\"]{3,}\"," + "\"address\":\\{\"street\":\"[^\"]{3,}\"," + "\"city\":\"[^\"]{3,}\"," + "\"state\":\"[^\"]{3,}\"," + "\"country\":\"[^\"]{3,}\"," + - "\"postal_code\":\"[^\"]{3,}\"\\}\\}\\}"; + "\"postalCode\":\"[^\"]{3,}\"\\}\\}\\}"; String flightRegex = "\\{" + "\"passenger\":\\{" + From 986d77884c732c8e678f7d733ccfd34cc8c12fd7 Mon Sep 17 00:00:00 2001 From: Jakub Stejskal Date: Mon, 22 Jul 2024 09:21:53 +0200 Subject: [PATCH 2/2] Remove unwanted sources as they will get generated every build Signed-off-by: Jakub Stejskal --- .gitignore | 3 + .../datagenerator/models/flights/Flight.java | 1039 ----------------- .../models/flights/FlightRecord.java | 511 -------- .../models/flights/Passenger.java | 559 --------- .../models/iotdevice/Battery.java | 398 ------- .../models/iotdevice/ButtonData.java | 455 -------- .../models/iotdevice/CustomData.java | 399 ------- .../models/iotdevice/EnergyCurrent.java | 398 ------- .../models/iotdevice/EnergyToday.java | 398 ------- .../models/iotdevice/GateData.java | 399 ------- .../models/iotdevice/IotDevice.java | 721 ------------ .../models/iotdevice/LightData.java | 478 -------- .../models/iotdevice/PlugData.java | 591 ---------- .../models/iotdevice/ThermometerData.java | 533 --------- .../models/paymentfiat/Address.java | 639 ---------- .../models/paymentfiat/Payee.java | 694 ----------- .../models/paymentfiat/Payer.java | 983 ---------------- .../models/paymentfiat/Payment.java | 717 ------------ .../models/paymentfiat/PaymentDetails.java | 717 ------------ .../models/paymentfiat/PaymentFiat.java | 647 ---------- .../models/payroll/Employee.java | 957 --------------- .../models/stargate/StarGate.java | 877 -------------- .../models/starwars/StarWars.java | 959 --------------- 23 files changed, 3 insertions(+), 14069 deletions(-) delete mode 100644 src/main/java/io/skodjob/datagenerator/models/flights/Flight.java delete mode 100644 src/main/java/io/skodjob/datagenerator/models/flights/FlightRecord.java delete mode 100644 src/main/java/io/skodjob/datagenerator/models/flights/Passenger.java delete mode 100644 src/main/java/io/skodjob/datagenerator/models/iotdevice/Battery.java delete mode 100644 src/main/java/io/skodjob/datagenerator/models/iotdevice/ButtonData.java delete mode 100644 src/main/java/io/skodjob/datagenerator/models/iotdevice/CustomData.java delete mode 100644 src/main/java/io/skodjob/datagenerator/models/iotdevice/EnergyCurrent.java delete mode 100644 src/main/java/io/skodjob/datagenerator/models/iotdevice/EnergyToday.java delete mode 100644 src/main/java/io/skodjob/datagenerator/models/iotdevice/GateData.java delete mode 100644 src/main/java/io/skodjob/datagenerator/models/iotdevice/IotDevice.java delete mode 100644 src/main/java/io/skodjob/datagenerator/models/iotdevice/LightData.java delete mode 100644 src/main/java/io/skodjob/datagenerator/models/iotdevice/PlugData.java delete mode 100644 src/main/java/io/skodjob/datagenerator/models/iotdevice/ThermometerData.java delete mode 100644 src/main/java/io/skodjob/datagenerator/models/paymentfiat/Address.java delete mode 100644 src/main/java/io/skodjob/datagenerator/models/paymentfiat/Payee.java delete mode 100644 src/main/java/io/skodjob/datagenerator/models/paymentfiat/Payer.java delete mode 100644 src/main/java/io/skodjob/datagenerator/models/paymentfiat/Payment.java delete mode 100644 src/main/java/io/skodjob/datagenerator/models/paymentfiat/PaymentDetails.java delete mode 100644 src/main/java/io/skodjob/datagenerator/models/paymentfiat/PaymentFiat.java delete mode 100644 src/main/java/io/skodjob/datagenerator/models/payroll/Employee.java delete mode 100644 src/main/java/io/skodjob/datagenerator/models/stargate/StarGate.java delete mode 100644 src/main/java/io/skodjob/datagenerator/models/starwars/StarWars.java diff --git a/.gitignore b/.gitignore index 0c45e8a..d3c932d 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,6 @@ target/ ### Mac OS ### **.DS_Store + +# Generated Avro models that should be excluded +src/main/java/io/skodjob/datagenerator/models/* diff --git a/src/main/java/io/skodjob/datagenerator/models/flights/Flight.java b/src/main/java/io/skodjob/datagenerator/models/flights/Flight.java deleted file mode 100644 index db9a0e7..0000000 --- a/src/main/java/io/skodjob/datagenerator/models/flights/Flight.java +++ /dev/null @@ -1,1039 +0,0 @@ -/** - * Autogenerated by Avro - * - * DO NOT EDIT DIRECTLY - */ -package io.skodjob.datagenerator.models.flights; - -import org.apache.avro.generic.GenericArray; -import org.apache.avro.specific.SpecificData; -import org.apache.avro.util.Utf8; -import org.apache.avro.message.BinaryMessageEncoder; -import org.apache.avro.message.BinaryMessageDecoder; -import org.apache.avro.message.SchemaStore; - -@org.apache.avro.specific.AvroGenerated -public class Flight extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord { - private static final long serialVersionUID = 4755920530450445103L; - - - public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"Flight\",\"namespace\":\"io.skodjob.datagenerator.models.flights\",\"fields\":[{\"name\":\"number\",\"type\":\"string\"},{\"name\":\"departure_airport\",\"type\":\"string\"},{\"name\":\"arrival_airport\",\"type\":\"string\"},{\"name\":\"departure_time\",\"type\":\"string\"},{\"name\":\"arrival_time\",\"type\":\"string\"},{\"name\":\"seat_number\",\"type\":\"string\"},{\"name\":\"gate\",\"type\":\"string\"},{\"name\":\"boarding_group\",\"type\":\"string\"},{\"name\":\"plane_model\",\"type\":\"string\"},{\"name\":\"airline\",\"type\":\"string\"}]}"); - public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } - - private static final SpecificData MODEL$ = new SpecificData(); - - private static final BinaryMessageEncoder ENCODER = - new BinaryMessageEncoder<>(MODEL$, SCHEMA$); - - private static final BinaryMessageDecoder DECODER = - new BinaryMessageDecoder<>(MODEL$, SCHEMA$); - - /** - * Return the BinaryMessageEncoder instance used by this class. - * @return the message encoder used by this class - */ - public static BinaryMessageEncoder getEncoder() { - return ENCODER; - } - - /** - * Return the BinaryMessageDecoder instance used by this class. - * @return the message decoder used by this class - */ - public static BinaryMessageDecoder getDecoder() { - return DECODER; - } - - /** - * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}. - * @param resolver a {@link SchemaStore} used to find schemas by fingerprint - * @return a BinaryMessageDecoder instance for this class backed by the given SchemaStore - */ - public static BinaryMessageDecoder createDecoder(SchemaStore resolver) { - return new BinaryMessageDecoder<>(MODEL$, SCHEMA$, resolver); - } - - /** - * Serializes this Flight to a ByteBuffer. - * @return a buffer holding the serialized data for this instance - * @throws java.io.IOException if this instance could not be serialized - */ - public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException { - return ENCODER.encode(this); - } - - /** - * Deserializes a Flight from a ByteBuffer. - * @param b a byte buffer holding serialized data for an instance of this class - * @return a Flight instance decoded from the given buffer - * @throws java.io.IOException if the given bytes could not be deserialized into an instance of this class - */ - public static Flight fromByteBuffer( - java.nio.ByteBuffer b) throws java.io.IOException { - return DECODER.decode(b); - } - - private java.lang.CharSequence number; - private java.lang.CharSequence departure_airport; - private java.lang.CharSequence arrival_airport; - private java.lang.CharSequence departure_time; - private java.lang.CharSequence arrival_time; - private java.lang.CharSequence seat_number; - private java.lang.CharSequence gate; - private java.lang.CharSequence boarding_group; - private java.lang.CharSequence plane_model; - private java.lang.CharSequence airline; - - /** - * Default constructor. Note that this does not initialize fields - * to their default values from the schema. If that is desired then - * one should use newBuilder(). - */ - public Flight() {} - - /** - * All-args constructor. - * @param number The new value for number - * @param departure_airport The new value for departure_airport - * @param arrival_airport The new value for arrival_airport - * @param departure_time The new value for departure_time - * @param arrival_time The new value for arrival_time - * @param seat_number The new value for seat_number - * @param gate The new value for gate - * @param boarding_group The new value for boarding_group - * @param plane_model The new value for plane_model - * @param airline The new value for airline - */ - public Flight(java.lang.CharSequence number, java.lang.CharSequence departure_airport, java.lang.CharSequence arrival_airport, java.lang.CharSequence departure_time, java.lang.CharSequence arrival_time, java.lang.CharSequence seat_number, java.lang.CharSequence gate, java.lang.CharSequence boarding_group, java.lang.CharSequence plane_model, java.lang.CharSequence airline) { - this.number = number; - this.departure_airport = departure_airport; - this.arrival_airport = arrival_airport; - this.departure_time = departure_time; - this.arrival_time = arrival_time; - this.seat_number = seat_number; - this.gate = gate; - this.boarding_group = boarding_group; - this.plane_model = plane_model; - this.airline = airline; - } - - @Override - public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; } - - @Override - public org.apache.avro.Schema getSchema() { return SCHEMA$; } - - // Used by DatumWriter. Applications should not call. - @Override - public java.lang.Object get(int field$) { - switch (field$) { - case 0: return number; - case 1: return departure_airport; - case 2: return arrival_airport; - case 3: return departure_time; - case 4: return arrival_time; - case 5: return seat_number; - case 6: return gate; - case 7: return boarding_group; - case 8: return plane_model; - case 9: return airline; - default: throw new IndexOutOfBoundsException("Invalid index: " + field$); - } - } - - // Used by DatumReader. Applications should not call. - @Override - @SuppressWarnings(value="unchecked") - public void put(int field$, java.lang.Object value$) { - switch (field$) { - case 0: number = (java.lang.CharSequence)value$; break; - case 1: departure_airport = (java.lang.CharSequence)value$; break; - case 2: arrival_airport = (java.lang.CharSequence)value$; break; - case 3: departure_time = (java.lang.CharSequence)value$; break; - case 4: arrival_time = (java.lang.CharSequence)value$; break; - case 5: seat_number = (java.lang.CharSequence)value$; break; - case 6: gate = (java.lang.CharSequence)value$; break; - case 7: boarding_group = (java.lang.CharSequence)value$; break; - case 8: plane_model = (java.lang.CharSequence)value$; break; - case 9: airline = (java.lang.CharSequence)value$; break; - default: throw new IndexOutOfBoundsException("Invalid index: " + field$); - } - } - - /** - * Gets the value of the 'number' field. - * @return The value of the 'number' field. - */ - public java.lang.CharSequence getNumber() { - return number; - } - - - /** - * Sets the value of the 'number' field. - * @param value the value to set. - */ - public void setNumber(java.lang.CharSequence value) { - this.number = value; - } - - /** - * Gets the value of the 'departure_airport' field. - * @return The value of the 'departure_airport' field. - */ - public java.lang.CharSequence getDepartureAirport() { - return departure_airport; - } - - - /** - * Sets the value of the 'departure_airport' field. - * @param value the value to set. - */ - public void setDepartureAirport(java.lang.CharSequence value) { - this.departure_airport = value; - } - - /** - * Gets the value of the 'arrival_airport' field. - * @return The value of the 'arrival_airport' field. - */ - public java.lang.CharSequence getArrivalAirport() { - return arrival_airport; - } - - - /** - * Sets the value of the 'arrival_airport' field. - * @param value the value to set. - */ - public void setArrivalAirport(java.lang.CharSequence value) { - this.arrival_airport = value; - } - - /** - * Gets the value of the 'departure_time' field. - * @return The value of the 'departure_time' field. - */ - public java.lang.CharSequence getDepartureTime() { - return departure_time; - } - - - /** - * Sets the value of the 'departure_time' field. - * @param value the value to set. - */ - public void setDepartureTime(java.lang.CharSequence value) { - this.departure_time = value; - } - - /** - * Gets the value of the 'arrival_time' field. - * @return The value of the 'arrival_time' field. - */ - public java.lang.CharSequence getArrivalTime() { - return arrival_time; - } - - - /** - * Sets the value of the 'arrival_time' field. - * @param value the value to set. - */ - public void setArrivalTime(java.lang.CharSequence value) { - this.arrival_time = value; - } - - /** - * Gets the value of the 'seat_number' field. - * @return The value of the 'seat_number' field. - */ - public java.lang.CharSequence getSeatNumber() { - return seat_number; - } - - - /** - * Sets the value of the 'seat_number' field. - * @param value the value to set. - */ - public void setSeatNumber(java.lang.CharSequence value) { - this.seat_number = value; - } - - /** - * Gets the value of the 'gate' field. - * @return The value of the 'gate' field. - */ - public java.lang.CharSequence getGate() { - return gate; - } - - - /** - * Sets the value of the 'gate' field. - * @param value the value to set. - */ - public void setGate(java.lang.CharSequence value) { - this.gate = value; - } - - /** - * Gets the value of the 'boarding_group' field. - * @return The value of the 'boarding_group' field. - */ - public java.lang.CharSequence getBoardingGroup() { - return boarding_group; - } - - - /** - * Sets the value of the 'boarding_group' field. - * @param value the value to set. - */ - public void setBoardingGroup(java.lang.CharSequence value) { - this.boarding_group = value; - } - - /** - * Gets the value of the 'plane_model' field. - * @return The value of the 'plane_model' field. - */ - public java.lang.CharSequence getPlaneModel() { - return plane_model; - } - - - /** - * Sets the value of the 'plane_model' field. - * @param value the value to set. - */ - public void setPlaneModel(java.lang.CharSequence value) { - this.plane_model = value; - } - - /** - * Gets the value of the 'airline' field. - * @return The value of the 'airline' field. - */ - public java.lang.CharSequence getAirline() { - return airline; - } - - - /** - * Sets the value of the 'airline' field. - * @param value the value to set. - */ - public void setAirline(java.lang.CharSequence value) { - this.airline = value; - } - - /** - * Creates a new Flight RecordBuilder. - * @return A new Flight RecordBuilder - */ - public static io.skodjob.datagenerator.models.flights.Flight.Builder newBuilder() { - return new io.skodjob.datagenerator.models.flights.Flight.Builder(); - } - - /** - * Creates a new Flight RecordBuilder by copying an existing Builder. - * @param other The existing builder to copy. - * @return A new Flight RecordBuilder - */ - public static io.skodjob.datagenerator.models.flights.Flight.Builder newBuilder(io.skodjob.datagenerator.models.flights.Flight.Builder other) { - if (other == null) { - return new io.skodjob.datagenerator.models.flights.Flight.Builder(); - } else { - return new io.skodjob.datagenerator.models.flights.Flight.Builder(other); - } - } - - /** - * Creates a new Flight RecordBuilder by copying an existing Flight instance. - * @param other The existing instance to copy. - * @return A new Flight RecordBuilder - */ - public static io.skodjob.datagenerator.models.flights.Flight.Builder newBuilder(io.skodjob.datagenerator.models.flights.Flight other) { - if (other == null) { - return new io.skodjob.datagenerator.models.flights.Flight.Builder(); - } else { - return new io.skodjob.datagenerator.models.flights.Flight.Builder(other); - } - } - - /** - * RecordBuilder for Flight instances. - */ - @org.apache.avro.specific.AvroGenerated - public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase - implements org.apache.avro.data.RecordBuilder { - - private java.lang.CharSequence number; - private java.lang.CharSequence departure_airport; - private java.lang.CharSequence arrival_airport; - private java.lang.CharSequence departure_time; - private java.lang.CharSequence arrival_time; - private java.lang.CharSequence seat_number; - private java.lang.CharSequence gate; - private java.lang.CharSequence boarding_group; - private java.lang.CharSequence plane_model; - private java.lang.CharSequence airline; - - /** Creates a new Builder */ - private Builder() { - super(SCHEMA$, MODEL$); - } - - /** - * Creates a Builder by copying an existing Builder. - * @param other The existing Builder to copy. - */ - private Builder(io.skodjob.datagenerator.models.flights.Flight.Builder other) { - super(other); - if (isValidValue(fields()[0], other.number)) { - this.number = data().deepCopy(fields()[0].schema(), other.number); - fieldSetFlags()[0] = other.fieldSetFlags()[0]; - } - if (isValidValue(fields()[1], other.departure_airport)) { - this.departure_airport = data().deepCopy(fields()[1].schema(), other.departure_airport); - fieldSetFlags()[1] = other.fieldSetFlags()[1]; - } - if (isValidValue(fields()[2], other.arrival_airport)) { - this.arrival_airport = data().deepCopy(fields()[2].schema(), other.arrival_airport); - fieldSetFlags()[2] = other.fieldSetFlags()[2]; - } - if (isValidValue(fields()[3], other.departure_time)) { - this.departure_time = data().deepCopy(fields()[3].schema(), other.departure_time); - fieldSetFlags()[3] = other.fieldSetFlags()[3]; - } - if (isValidValue(fields()[4], other.arrival_time)) { - this.arrival_time = data().deepCopy(fields()[4].schema(), other.arrival_time); - fieldSetFlags()[4] = other.fieldSetFlags()[4]; - } - if (isValidValue(fields()[5], other.seat_number)) { - this.seat_number = data().deepCopy(fields()[5].schema(), other.seat_number); - fieldSetFlags()[5] = other.fieldSetFlags()[5]; - } - if (isValidValue(fields()[6], other.gate)) { - this.gate = data().deepCopy(fields()[6].schema(), other.gate); - fieldSetFlags()[6] = other.fieldSetFlags()[6]; - } - if (isValidValue(fields()[7], other.boarding_group)) { - this.boarding_group = data().deepCopy(fields()[7].schema(), other.boarding_group); - fieldSetFlags()[7] = other.fieldSetFlags()[7]; - } - if (isValidValue(fields()[8], other.plane_model)) { - this.plane_model = data().deepCopy(fields()[8].schema(), other.plane_model); - fieldSetFlags()[8] = other.fieldSetFlags()[8]; - } - if (isValidValue(fields()[9], other.airline)) { - this.airline = data().deepCopy(fields()[9].schema(), other.airline); - fieldSetFlags()[9] = other.fieldSetFlags()[9]; - } - } - - /** - * Creates a Builder by copying an existing Flight instance - * @param other The existing instance to copy. - */ - private Builder(io.skodjob.datagenerator.models.flights.Flight other) { - super(SCHEMA$, MODEL$); - if (isValidValue(fields()[0], other.number)) { - this.number = data().deepCopy(fields()[0].schema(), other.number); - fieldSetFlags()[0] = true; - } - if (isValidValue(fields()[1], other.departure_airport)) { - this.departure_airport = data().deepCopy(fields()[1].schema(), other.departure_airport); - fieldSetFlags()[1] = true; - } - if (isValidValue(fields()[2], other.arrival_airport)) { - this.arrival_airport = data().deepCopy(fields()[2].schema(), other.arrival_airport); - fieldSetFlags()[2] = true; - } - if (isValidValue(fields()[3], other.departure_time)) { - this.departure_time = data().deepCopy(fields()[3].schema(), other.departure_time); - fieldSetFlags()[3] = true; - } - if (isValidValue(fields()[4], other.arrival_time)) { - this.arrival_time = data().deepCopy(fields()[4].schema(), other.arrival_time); - fieldSetFlags()[4] = true; - } - if (isValidValue(fields()[5], other.seat_number)) { - this.seat_number = data().deepCopy(fields()[5].schema(), other.seat_number); - fieldSetFlags()[5] = true; - } - if (isValidValue(fields()[6], other.gate)) { - this.gate = data().deepCopy(fields()[6].schema(), other.gate); - fieldSetFlags()[6] = true; - } - if (isValidValue(fields()[7], other.boarding_group)) { - this.boarding_group = data().deepCopy(fields()[7].schema(), other.boarding_group); - fieldSetFlags()[7] = true; - } - if (isValidValue(fields()[8], other.plane_model)) { - this.plane_model = data().deepCopy(fields()[8].schema(), other.plane_model); - fieldSetFlags()[8] = true; - } - if (isValidValue(fields()[9], other.airline)) { - this.airline = data().deepCopy(fields()[9].schema(), other.airline); - fieldSetFlags()[9] = true; - } - } - - /** - * Gets the value of the 'number' field. - * @return The value. - */ - public java.lang.CharSequence getNumber() { - return number; - } - - - /** - * Sets the value of the 'number' field. - * @param value The value of 'number'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.flights.Flight.Builder setNumber(java.lang.CharSequence value) { - validate(fields()[0], value); - this.number = value; - fieldSetFlags()[0] = true; - return this; - } - - /** - * Checks whether the 'number' field has been set. - * @return True if the 'number' field has been set, false otherwise. - */ - public boolean hasNumber() { - return fieldSetFlags()[0]; - } - - - /** - * Clears the value of the 'number' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.flights.Flight.Builder clearNumber() { - number = null; - fieldSetFlags()[0] = false; - return this; - } - - /** - * Gets the value of the 'departure_airport' field. - * @return The value. - */ - public java.lang.CharSequence getDepartureAirport() { - return departure_airport; - } - - - /** - * Sets the value of the 'departure_airport' field. - * @param value The value of 'departure_airport'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.flights.Flight.Builder setDepartureAirport(java.lang.CharSequence value) { - validate(fields()[1], value); - this.departure_airport = value; - fieldSetFlags()[1] = true; - return this; - } - - /** - * Checks whether the 'departure_airport' field has been set. - * @return True if the 'departure_airport' field has been set, false otherwise. - */ - public boolean hasDepartureAirport() { - return fieldSetFlags()[1]; - } - - - /** - * Clears the value of the 'departure_airport' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.flights.Flight.Builder clearDepartureAirport() { - departure_airport = null; - fieldSetFlags()[1] = false; - return this; - } - - /** - * Gets the value of the 'arrival_airport' field. - * @return The value. - */ - public java.lang.CharSequence getArrivalAirport() { - return arrival_airport; - } - - - /** - * Sets the value of the 'arrival_airport' field. - * @param value The value of 'arrival_airport'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.flights.Flight.Builder setArrivalAirport(java.lang.CharSequence value) { - validate(fields()[2], value); - this.arrival_airport = value; - fieldSetFlags()[2] = true; - return this; - } - - /** - * Checks whether the 'arrival_airport' field has been set. - * @return True if the 'arrival_airport' field has been set, false otherwise. - */ - public boolean hasArrivalAirport() { - return fieldSetFlags()[2]; - } - - - /** - * Clears the value of the 'arrival_airport' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.flights.Flight.Builder clearArrivalAirport() { - arrival_airport = null; - fieldSetFlags()[2] = false; - return this; - } - - /** - * Gets the value of the 'departure_time' field. - * @return The value. - */ - public java.lang.CharSequence getDepartureTime() { - return departure_time; - } - - - /** - * Sets the value of the 'departure_time' field. - * @param value The value of 'departure_time'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.flights.Flight.Builder setDepartureTime(java.lang.CharSequence value) { - validate(fields()[3], value); - this.departure_time = value; - fieldSetFlags()[3] = true; - return this; - } - - /** - * Checks whether the 'departure_time' field has been set. - * @return True if the 'departure_time' field has been set, false otherwise. - */ - public boolean hasDepartureTime() { - return fieldSetFlags()[3]; - } - - - /** - * Clears the value of the 'departure_time' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.flights.Flight.Builder clearDepartureTime() { - departure_time = null; - fieldSetFlags()[3] = false; - return this; - } - - /** - * Gets the value of the 'arrival_time' field. - * @return The value. - */ - public java.lang.CharSequence getArrivalTime() { - return arrival_time; - } - - - /** - * Sets the value of the 'arrival_time' field. - * @param value The value of 'arrival_time'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.flights.Flight.Builder setArrivalTime(java.lang.CharSequence value) { - validate(fields()[4], value); - this.arrival_time = value; - fieldSetFlags()[4] = true; - return this; - } - - /** - * Checks whether the 'arrival_time' field has been set. - * @return True if the 'arrival_time' field has been set, false otherwise. - */ - public boolean hasArrivalTime() { - return fieldSetFlags()[4]; - } - - - /** - * Clears the value of the 'arrival_time' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.flights.Flight.Builder clearArrivalTime() { - arrival_time = null; - fieldSetFlags()[4] = false; - return this; - } - - /** - * Gets the value of the 'seat_number' field. - * @return The value. - */ - public java.lang.CharSequence getSeatNumber() { - return seat_number; - } - - - /** - * Sets the value of the 'seat_number' field. - * @param value The value of 'seat_number'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.flights.Flight.Builder setSeatNumber(java.lang.CharSequence value) { - validate(fields()[5], value); - this.seat_number = value; - fieldSetFlags()[5] = true; - return this; - } - - /** - * Checks whether the 'seat_number' field has been set. - * @return True if the 'seat_number' field has been set, false otherwise. - */ - public boolean hasSeatNumber() { - return fieldSetFlags()[5]; - } - - - /** - * Clears the value of the 'seat_number' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.flights.Flight.Builder clearSeatNumber() { - seat_number = null; - fieldSetFlags()[5] = false; - return this; - } - - /** - * Gets the value of the 'gate' field. - * @return The value. - */ - public java.lang.CharSequence getGate() { - return gate; - } - - - /** - * Sets the value of the 'gate' field. - * @param value The value of 'gate'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.flights.Flight.Builder setGate(java.lang.CharSequence value) { - validate(fields()[6], value); - this.gate = value; - fieldSetFlags()[6] = true; - return this; - } - - /** - * Checks whether the 'gate' field has been set. - * @return True if the 'gate' field has been set, false otherwise. - */ - public boolean hasGate() { - return fieldSetFlags()[6]; - } - - - /** - * Clears the value of the 'gate' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.flights.Flight.Builder clearGate() { - gate = null; - fieldSetFlags()[6] = false; - return this; - } - - /** - * Gets the value of the 'boarding_group' field. - * @return The value. - */ - public java.lang.CharSequence getBoardingGroup() { - return boarding_group; - } - - - /** - * Sets the value of the 'boarding_group' field. - * @param value The value of 'boarding_group'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.flights.Flight.Builder setBoardingGroup(java.lang.CharSequence value) { - validate(fields()[7], value); - this.boarding_group = value; - fieldSetFlags()[7] = true; - return this; - } - - /** - * Checks whether the 'boarding_group' field has been set. - * @return True if the 'boarding_group' field has been set, false otherwise. - */ - public boolean hasBoardingGroup() { - return fieldSetFlags()[7]; - } - - - /** - * Clears the value of the 'boarding_group' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.flights.Flight.Builder clearBoardingGroup() { - boarding_group = null; - fieldSetFlags()[7] = false; - return this; - } - - /** - * Gets the value of the 'plane_model' field. - * @return The value. - */ - public java.lang.CharSequence getPlaneModel() { - return plane_model; - } - - - /** - * Sets the value of the 'plane_model' field. - * @param value The value of 'plane_model'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.flights.Flight.Builder setPlaneModel(java.lang.CharSequence value) { - validate(fields()[8], value); - this.plane_model = value; - fieldSetFlags()[8] = true; - return this; - } - - /** - * Checks whether the 'plane_model' field has been set. - * @return True if the 'plane_model' field has been set, false otherwise. - */ - public boolean hasPlaneModel() { - return fieldSetFlags()[8]; - } - - - /** - * Clears the value of the 'plane_model' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.flights.Flight.Builder clearPlaneModel() { - plane_model = null; - fieldSetFlags()[8] = false; - return this; - } - - /** - * Gets the value of the 'airline' field. - * @return The value. - */ - public java.lang.CharSequence getAirline() { - return airline; - } - - - /** - * Sets the value of the 'airline' field. - * @param value The value of 'airline'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.flights.Flight.Builder setAirline(java.lang.CharSequence value) { - validate(fields()[9], value); - this.airline = value; - fieldSetFlags()[9] = true; - return this; - } - - /** - * Checks whether the 'airline' field has been set. - * @return True if the 'airline' field has been set, false otherwise. - */ - public boolean hasAirline() { - return fieldSetFlags()[9]; - } - - - /** - * Clears the value of the 'airline' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.flights.Flight.Builder clearAirline() { - airline = null; - fieldSetFlags()[9] = false; - return this; - } - - @Override - @SuppressWarnings("unchecked") - public Flight build() { - try { - Flight record = new Flight(); - record.number = fieldSetFlags()[0] ? this.number : (java.lang.CharSequence) defaultValue(fields()[0]); - record.departure_airport = fieldSetFlags()[1] ? this.departure_airport : (java.lang.CharSequence) defaultValue(fields()[1]); - record.arrival_airport = fieldSetFlags()[2] ? this.arrival_airport : (java.lang.CharSequence) defaultValue(fields()[2]); - record.departure_time = fieldSetFlags()[3] ? this.departure_time : (java.lang.CharSequence) defaultValue(fields()[3]); - record.arrival_time = fieldSetFlags()[4] ? this.arrival_time : (java.lang.CharSequence) defaultValue(fields()[4]); - record.seat_number = fieldSetFlags()[5] ? this.seat_number : (java.lang.CharSequence) defaultValue(fields()[5]); - record.gate = fieldSetFlags()[6] ? this.gate : (java.lang.CharSequence) defaultValue(fields()[6]); - record.boarding_group = fieldSetFlags()[7] ? this.boarding_group : (java.lang.CharSequence) defaultValue(fields()[7]); - record.plane_model = fieldSetFlags()[8] ? this.plane_model : (java.lang.CharSequence) defaultValue(fields()[8]); - record.airline = fieldSetFlags()[9] ? this.airline : (java.lang.CharSequence) defaultValue(fields()[9]); - return record; - } catch (org.apache.avro.AvroMissingFieldException e) { - throw e; - } catch (java.lang.Exception e) { - throw new org.apache.avro.AvroRuntimeException(e); - } - } - } - - @SuppressWarnings("unchecked") - private static final org.apache.avro.io.DatumWriter - WRITER$ = (org.apache.avro.io.DatumWriter)MODEL$.createDatumWriter(SCHEMA$); - - @Override public void writeExternal(java.io.ObjectOutput out) - throws java.io.IOException { - WRITER$.write(this, SpecificData.getEncoder(out)); - } - - @SuppressWarnings("unchecked") - private static final org.apache.avro.io.DatumReader - READER$ = (org.apache.avro.io.DatumReader)MODEL$.createDatumReader(SCHEMA$); - - @Override public void readExternal(java.io.ObjectInput in) - throws java.io.IOException { - READER$.read(this, SpecificData.getDecoder(in)); - } - - @Override protected boolean hasCustomCoders() { return true; } - - @Override public void customEncode(org.apache.avro.io.Encoder out) - throws java.io.IOException - { - out.writeString(this.number); - - out.writeString(this.departure_airport); - - out.writeString(this.arrival_airport); - - out.writeString(this.departure_time); - - out.writeString(this.arrival_time); - - out.writeString(this.seat_number); - - out.writeString(this.gate); - - out.writeString(this.boarding_group); - - out.writeString(this.plane_model); - - out.writeString(this.airline); - - } - - @Override public void customDecode(org.apache.avro.io.ResolvingDecoder in) - throws java.io.IOException - { - org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff(); - if (fieldOrder == null) { - this.number = in.readString(this.number instanceof Utf8 ? (Utf8)this.number : null); - - this.departure_airport = in.readString(this.departure_airport instanceof Utf8 ? (Utf8)this.departure_airport : null); - - this.arrival_airport = in.readString(this.arrival_airport instanceof Utf8 ? (Utf8)this.arrival_airport : null); - - this.departure_time = in.readString(this.departure_time instanceof Utf8 ? (Utf8)this.departure_time : null); - - this.arrival_time = in.readString(this.arrival_time instanceof Utf8 ? (Utf8)this.arrival_time : null); - - this.seat_number = in.readString(this.seat_number instanceof Utf8 ? (Utf8)this.seat_number : null); - - this.gate = in.readString(this.gate instanceof Utf8 ? (Utf8)this.gate : null); - - this.boarding_group = in.readString(this.boarding_group instanceof Utf8 ? (Utf8)this.boarding_group : null); - - this.plane_model = in.readString(this.plane_model instanceof Utf8 ? (Utf8)this.plane_model : null); - - this.airline = in.readString(this.airline instanceof Utf8 ? (Utf8)this.airline : null); - - } else { - for (int i = 0; i < 10; i++) { - switch (fieldOrder[i].pos()) { - case 0: - this.number = in.readString(this.number instanceof Utf8 ? (Utf8)this.number : null); - break; - - case 1: - this.departure_airport = in.readString(this.departure_airport instanceof Utf8 ? (Utf8)this.departure_airport : null); - break; - - case 2: - this.arrival_airport = in.readString(this.arrival_airport instanceof Utf8 ? (Utf8)this.arrival_airport : null); - break; - - case 3: - this.departure_time = in.readString(this.departure_time instanceof Utf8 ? (Utf8)this.departure_time : null); - break; - - case 4: - this.arrival_time = in.readString(this.arrival_time instanceof Utf8 ? (Utf8)this.arrival_time : null); - break; - - case 5: - this.seat_number = in.readString(this.seat_number instanceof Utf8 ? (Utf8)this.seat_number : null); - break; - - case 6: - this.gate = in.readString(this.gate instanceof Utf8 ? (Utf8)this.gate : null); - break; - - case 7: - this.boarding_group = in.readString(this.boarding_group instanceof Utf8 ? (Utf8)this.boarding_group : null); - break; - - case 8: - this.plane_model = in.readString(this.plane_model instanceof Utf8 ? (Utf8)this.plane_model : null); - break; - - case 9: - this.airline = in.readString(this.airline instanceof Utf8 ? (Utf8)this.airline : null); - break; - - default: - throw new java.io.IOException("Corrupt ResolvingDecoder."); - } - } - } - } -} - - - - - - - - - - diff --git a/src/main/java/io/skodjob/datagenerator/models/flights/FlightRecord.java b/src/main/java/io/skodjob/datagenerator/models/flights/FlightRecord.java deleted file mode 100644 index ca8a137..0000000 --- a/src/main/java/io/skodjob/datagenerator/models/flights/FlightRecord.java +++ /dev/null @@ -1,511 +0,0 @@ -/** - * Autogenerated by Avro - * - * DO NOT EDIT DIRECTLY - */ -package io.skodjob.datagenerator.models.flights; - -import org.apache.avro.generic.GenericArray; -import org.apache.avro.specific.SpecificData; -import org.apache.avro.util.Utf8; -import org.apache.avro.message.BinaryMessageEncoder; -import org.apache.avro.message.BinaryMessageDecoder; -import org.apache.avro.message.SchemaStore; - -@org.apache.avro.specific.AvroGenerated -public class FlightRecord extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord { - private static final long serialVersionUID = 1649870568249374036L; - - - public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"FlightRecord\",\"namespace\":\"io.skodjob.datagenerator.models.flights\",\"fields\":[{\"name\":\"passenger\",\"type\":{\"type\":\"record\",\"name\":\"Passenger\",\"fields\":[{\"name\":\"id\",\"type\":\"string\"},{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"passport_number\",\"type\":\"string\"},{\"name\":\"nationality\",\"type\":\"string\"}]}},{\"name\":\"flight\",\"type\":{\"type\":\"record\",\"name\":\"Flight\",\"fields\":[{\"name\":\"number\",\"type\":\"string\"},{\"name\":\"departure_airport\",\"type\":\"string\"},{\"name\":\"arrival_airport\",\"type\":\"string\"},{\"name\":\"departure_time\",\"type\":\"string\"},{\"name\":\"arrival_time\",\"type\":\"string\"},{\"name\":\"seat_number\",\"type\":\"string\"},{\"name\":\"gate\",\"type\":\"string\"},{\"name\":\"boarding_group\",\"type\":\"string\"},{\"name\":\"plane_model\",\"type\":\"string\"},{\"name\":\"airline\",\"type\":\"string\"}]}}]}"); - public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } - - private static final SpecificData MODEL$ = new SpecificData(); - - private static final BinaryMessageEncoder ENCODER = - new BinaryMessageEncoder<>(MODEL$, SCHEMA$); - - private static final BinaryMessageDecoder DECODER = - new BinaryMessageDecoder<>(MODEL$, SCHEMA$); - - /** - * Return the BinaryMessageEncoder instance used by this class. - * @return the message encoder used by this class - */ - public static BinaryMessageEncoder getEncoder() { - return ENCODER; - } - - /** - * Return the BinaryMessageDecoder instance used by this class. - * @return the message decoder used by this class - */ - public static BinaryMessageDecoder getDecoder() { - return DECODER; - } - - /** - * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}. - * @param resolver a {@link SchemaStore} used to find schemas by fingerprint - * @return a BinaryMessageDecoder instance for this class backed by the given SchemaStore - */ - public static BinaryMessageDecoder createDecoder(SchemaStore resolver) { - return new BinaryMessageDecoder<>(MODEL$, SCHEMA$, resolver); - } - - /** - * Serializes this FlightRecord to a ByteBuffer. - * @return a buffer holding the serialized data for this instance - * @throws java.io.IOException if this instance could not be serialized - */ - public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException { - return ENCODER.encode(this); - } - - /** - * Deserializes a FlightRecord from a ByteBuffer. - * @param b a byte buffer holding serialized data for an instance of this class - * @return a FlightRecord instance decoded from the given buffer - * @throws java.io.IOException if the given bytes could not be deserialized into an instance of this class - */ - public static FlightRecord fromByteBuffer( - java.nio.ByteBuffer b) throws java.io.IOException { - return DECODER.decode(b); - } - - private io.skodjob.datagenerator.models.flights.Passenger passenger; - private io.skodjob.datagenerator.models.flights.Flight flight; - - /** - * Default constructor. Note that this does not initialize fields - * to their default values from the schema. If that is desired then - * one should use newBuilder(). - */ - public FlightRecord() {} - - /** - * All-args constructor. - * @param passenger The new value for passenger - * @param flight The new value for flight - */ - public FlightRecord(io.skodjob.datagenerator.models.flights.Passenger passenger, io.skodjob.datagenerator.models.flights.Flight flight) { - this.passenger = passenger; - this.flight = flight; - } - - @Override - public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; } - - @Override - public org.apache.avro.Schema getSchema() { return SCHEMA$; } - - // Used by DatumWriter. Applications should not call. - @Override - public java.lang.Object get(int field$) { - switch (field$) { - case 0: return passenger; - case 1: return flight; - default: throw new IndexOutOfBoundsException("Invalid index: " + field$); - } - } - - // Used by DatumReader. Applications should not call. - @Override - @SuppressWarnings(value="unchecked") - public void put(int field$, java.lang.Object value$) { - switch (field$) { - case 0: passenger = (io.skodjob.datagenerator.models.flights.Passenger)value$; break; - case 1: flight = (io.skodjob.datagenerator.models.flights.Flight)value$; break; - default: throw new IndexOutOfBoundsException("Invalid index: " + field$); - } - } - - /** - * Gets the value of the 'passenger' field. - * @return The value of the 'passenger' field. - */ - public io.skodjob.datagenerator.models.flights.Passenger getPassenger() { - return passenger; - } - - - /** - * Sets the value of the 'passenger' field. - * @param value the value to set. - */ - public void setPassenger(io.skodjob.datagenerator.models.flights.Passenger value) { - this.passenger = value; - } - - /** - * Gets the value of the 'flight' field. - * @return The value of the 'flight' field. - */ - public io.skodjob.datagenerator.models.flights.Flight getFlight() { - return flight; - } - - - /** - * Sets the value of the 'flight' field. - * @param value the value to set. - */ - public void setFlight(io.skodjob.datagenerator.models.flights.Flight value) { - this.flight = value; - } - - /** - * Creates a new FlightRecord RecordBuilder. - * @return A new FlightRecord RecordBuilder - */ - public static io.skodjob.datagenerator.models.flights.FlightRecord.Builder newBuilder() { - return new io.skodjob.datagenerator.models.flights.FlightRecord.Builder(); - } - - /** - * Creates a new FlightRecord RecordBuilder by copying an existing Builder. - * @param other The existing builder to copy. - * @return A new FlightRecord RecordBuilder - */ - public static io.skodjob.datagenerator.models.flights.FlightRecord.Builder newBuilder(io.skodjob.datagenerator.models.flights.FlightRecord.Builder other) { - if (other == null) { - return new io.skodjob.datagenerator.models.flights.FlightRecord.Builder(); - } else { - return new io.skodjob.datagenerator.models.flights.FlightRecord.Builder(other); - } - } - - /** - * Creates a new FlightRecord RecordBuilder by copying an existing FlightRecord instance. - * @param other The existing instance to copy. - * @return A new FlightRecord RecordBuilder - */ - public static io.skodjob.datagenerator.models.flights.FlightRecord.Builder newBuilder(io.skodjob.datagenerator.models.flights.FlightRecord other) { - if (other == null) { - return new io.skodjob.datagenerator.models.flights.FlightRecord.Builder(); - } else { - return new io.skodjob.datagenerator.models.flights.FlightRecord.Builder(other); - } - } - - /** - * RecordBuilder for FlightRecord instances. - */ - @org.apache.avro.specific.AvroGenerated - public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase - implements org.apache.avro.data.RecordBuilder { - - private io.skodjob.datagenerator.models.flights.Passenger passenger; - private io.skodjob.datagenerator.models.flights.Passenger.Builder passengerBuilder; - private io.skodjob.datagenerator.models.flights.Flight flight; - private io.skodjob.datagenerator.models.flights.Flight.Builder flightBuilder; - - /** Creates a new Builder */ - private Builder() { - super(SCHEMA$, MODEL$); - } - - /** - * Creates a Builder by copying an existing Builder. - * @param other The existing Builder to copy. - */ - private Builder(io.skodjob.datagenerator.models.flights.FlightRecord.Builder other) { - super(other); - if (isValidValue(fields()[0], other.passenger)) { - this.passenger = data().deepCopy(fields()[0].schema(), other.passenger); - fieldSetFlags()[0] = other.fieldSetFlags()[0]; - } - if (other.hasPassengerBuilder()) { - this.passengerBuilder = io.skodjob.datagenerator.models.flights.Passenger.newBuilder(other.getPassengerBuilder()); - } - if (isValidValue(fields()[1], other.flight)) { - this.flight = data().deepCopy(fields()[1].schema(), other.flight); - fieldSetFlags()[1] = other.fieldSetFlags()[1]; - } - if (other.hasFlightBuilder()) { - this.flightBuilder = io.skodjob.datagenerator.models.flights.Flight.newBuilder(other.getFlightBuilder()); - } - } - - /** - * Creates a Builder by copying an existing FlightRecord instance - * @param other The existing instance to copy. - */ - private Builder(io.skodjob.datagenerator.models.flights.FlightRecord other) { - super(SCHEMA$, MODEL$); - if (isValidValue(fields()[0], other.passenger)) { - this.passenger = data().deepCopy(fields()[0].schema(), other.passenger); - fieldSetFlags()[0] = true; - } - this.passengerBuilder = null; - if (isValidValue(fields()[1], other.flight)) { - this.flight = data().deepCopy(fields()[1].schema(), other.flight); - fieldSetFlags()[1] = true; - } - this.flightBuilder = null; - } - - /** - * Gets the value of the 'passenger' field. - * @return The value. - */ - public io.skodjob.datagenerator.models.flights.Passenger getPassenger() { - return passenger; - } - - - /** - * Sets the value of the 'passenger' field. - * @param value The value of 'passenger'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.flights.FlightRecord.Builder setPassenger(io.skodjob.datagenerator.models.flights.Passenger value) { - validate(fields()[0], value); - this.passengerBuilder = null; - this.passenger = value; - fieldSetFlags()[0] = true; - return this; - } - - /** - * Checks whether the 'passenger' field has been set. - * @return True if the 'passenger' field has been set, false otherwise. - */ - public boolean hasPassenger() { - return fieldSetFlags()[0]; - } - - /** - * Gets the Builder instance for the 'passenger' field and creates one if it doesn't exist yet. - * @return This builder. - */ - public io.skodjob.datagenerator.models.flights.Passenger.Builder getPassengerBuilder() { - if (passengerBuilder == null) { - if (hasPassenger()) { - setPassengerBuilder(io.skodjob.datagenerator.models.flights.Passenger.newBuilder(passenger)); - } else { - setPassengerBuilder(io.skodjob.datagenerator.models.flights.Passenger.newBuilder()); - } - } - return passengerBuilder; - } - - /** - * Sets the Builder instance for the 'passenger' field - * @param value The builder instance that must be set. - * @return This builder. - */ - - public io.skodjob.datagenerator.models.flights.FlightRecord.Builder setPassengerBuilder(io.skodjob.datagenerator.models.flights.Passenger.Builder value) { - clearPassenger(); - passengerBuilder = value; - return this; - } - - /** - * Checks whether the 'passenger' field has an active Builder instance - * @return True if the 'passenger' field has an active Builder instance - */ - public boolean hasPassengerBuilder() { - return passengerBuilder != null; - } - - /** - * Clears the value of the 'passenger' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.flights.FlightRecord.Builder clearPassenger() { - passenger = null; - passengerBuilder = null; - fieldSetFlags()[0] = false; - return this; - } - - /** - * Gets the value of the 'flight' field. - * @return The value. - */ - public io.skodjob.datagenerator.models.flights.Flight getFlight() { - return flight; - } - - - /** - * Sets the value of the 'flight' field. - * @param value The value of 'flight'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.flights.FlightRecord.Builder setFlight(io.skodjob.datagenerator.models.flights.Flight value) { - validate(fields()[1], value); - this.flightBuilder = null; - this.flight = value; - fieldSetFlags()[1] = true; - return this; - } - - /** - * Checks whether the 'flight' field has been set. - * @return True if the 'flight' field has been set, false otherwise. - */ - public boolean hasFlight() { - return fieldSetFlags()[1]; - } - - /** - * Gets the Builder instance for the 'flight' field and creates one if it doesn't exist yet. - * @return This builder. - */ - public io.skodjob.datagenerator.models.flights.Flight.Builder getFlightBuilder() { - if (flightBuilder == null) { - if (hasFlight()) { - setFlightBuilder(io.skodjob.datagenerator.models.flights.Flight.newBuilder(flight)); - } else { - setFlightBuilder(io.skodjob.datagenerator.models.flights.Flight.newBuilder()); - } - } - return flightBuilder; - } - - /** - * Sets the Builder instance for the 'flight' field - * @param value The builder instance that must be set. - * @return This builder. - */ - - public io.skodjob.datagenerator.models.flights.FlightRecord.Builder setFlightBuilder(io.skodjob.datagenerator.models.flights.Flight.Builder value) { - clearFlight(); - flightBuilder = value; - return this; - } - - /** - * Checks whether the 'flight' field has an active Builder instance - * @return True if the 'flight' field has an active Builder instance - */ - public boolean hasFlightBuilder() { - return flightBuilder != null; - } - - /** - * Clears the value of the 'flight' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.flights.FlightRecord.Builder clearFlight() { - flight = null; - flightBuilder = null; - fieldSetFlags()[1] = false; - return this; - } - - @Override - @SuppressWarnings("unchecked") - public FlightRecord build() { - try { - FlightRecord record = new FlightRecord(); - if (passengerBuilder != null) { - try { - record.passenger = this.passengerBuilder.build(); - } catch (org.apache.avro.AvroMissingFieldException e) { - e.addParentField(record.getSchema().getField("passenger")); - throw e; - } - } else { - record.passenger = fieldSetFlags()[0] ? this.passenger : (io.skodjob.datagenerator.models.flights.Passenger) defaultValue(fields()[0]); - } - if (flightBuilder != null) { - try { - record.flight = this.flightBuilder.build(); - } catch (org.apache.avro.AvroMissingFieldException e) { - e.addParentField(record.getSchema().getField("flight")); - throw e; - } - } else { - record.flight = fieldSetFlags()[1] ? this.flight : (io.skodjob.datagenerator.models.flights.Flight) defaultValue(fields()[1]); - } - return record; - } catch (org.apache.avro.AvroMissingFieldException e) { - throw e; - } catch (java.lang.Exception e) { - throw new org.apache.avro.AvroRuntimeException(e); - } - } - } - - @SuppressWarnings("unchecked") - private static final org.apache.avro.io.DatumWriter - WRITER$ = (org.apache.avro.io.DatumWriter)MODEL$.createDatumWriter(SCHEMA$); - - @Override public void writeExternal(java.io.ObjectOutput out) - throws java.io.IOException { - WRITER$.write(this, SpecificData.getEncoder(out)); - } - - @SuppressWarnings("unchecked") - private static final org.apache.avro.io.DatumReader - READER$ = (org.apache.avro.io.DatumReader)MODEL$.createDatumReader(SCHEMA$); - - @Override public void readExternal(java.io.ObjectInput in) - throws java.io.IOException { - READER$.read(this, SpecificData.getDecoder(in)); - } - - @Override protected boolean hasCustomCoders() { return true; } - - @Override public void customEncode(org.apache.avro.io.Encoder out) - throws java.io.IOException - { - this.passenger.customEncode(out); - - this.flight.customEncode(out); - - } - - @Override public void customDecode(org.apache.avro.io.ResolvingDecoder in) - throws java.io.IOException - { - org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff(); - if (fieldOrder == null) { - if (this.passenger == null) { - this.passenger = new io.skodjob.datagenerator.models.flights.Passenger(); - } - this.passenger.customDecode(in); - - if (this.flight == null) { - this.flight = new io.skodjob.datagenerator.models.flights.Flight(); - } - this.flight.customDecode(in); - - } else { - for (int i = 0; i < 2; i++) { - switch (fieldOrder[i].pos()) { - case 0: - if (this.passenger == null) { - this.passenger = new io.skodjob.datagenerator.models.flights.Passenger(); - } - this.passenger.customDecode(in); - break; - - case 1: - if (this.flight == null) { - this.flight = new io.skodjob.datagenerator.models.flights.Flight(); - } - this.flight.customDecode(in); - break; - - default: - throw new java.io.IOException("Corrupt ResolvingDecoder."); - } - } - } - } -} - - - - - - - - - - diff --git a/src/main/java/io/skodjob/datagenerator/models/flights/Passenger.java b/src/main/java/io/skodjob/datagenerator/models/flights/Passenger.java deleted file mode 100644 index 9cc1146..0000000 --- a/src/main/java/io/skodjob/datagenerator/models/flights/Passenger.java +++ /dev/null @@ -1,559 +0,0 @@ -/** - * Autogenerated by Avro - * - * DO NOT EDIT DIRECTLY - */ -package io.skodjob.datagenerator.models.flights; - -import org.apache.avro.generic.GenericArray; -import org.apache.avro.specific.SpecificData; -import org.apache.avro.util.Utf8; -import org.apache.avro.message.BinaryMessageEncoder; -import org.apache.avro.message.BinaryMessageDecoder; -import org.apache.avro.message.SchemaStore; - -@org.apache.avro.specific.AvroGenerated -public class Passenger extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord { - private static final long serialVersionUID = 7514441306189719528L; - - - public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"Passenger\",\"namespace\":\"io.skodjob.datagenerator.models.flights\",\"fields\":[{\"name\":\"id\",\"type\":\"string\"},{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"passport_number\",\"type\":\"string\"},{\"name\":\"nationality\",\"type\":\"string\"}]}"); - public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } - - private static final SpecificData MODEL$ = new SpecificData(); - - private static final BinaryMessageEncoder ENCODER = - new BinaryMessageEncoder<>(MODEL$, SCHEMA$); - - private static final BinaryMessageDecoder DECODER = - new BinaryMessageDecoder<>(MODEL$, SCHEMA$); - - /** - * Return the BinaryMessageEncoder instance used by this class. - * @return the message encoder used by this class - */ - public static BinaryMessageEncoder getEncoder() { - return ENCODER; - } - - /** - * Return the BinaryMessageDecoder instance used by this class. - * @return the message decoder used by this class - */ - public static BinaryMessageDecoder getDecoder() { - return DECODER; - } - - /** - * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}. - * @param resolver a {@link SchemaStore} used to find schemas by fingerprint - * @return a BinaryMessageDecoder instance for this class backed by the given SchemaStore - */ - public static BinaryMessageDecoder createDecoder(SchemaStore resolver) { - return new BinaryMessageDecoder<>(MODEL$, SCHEMA$, resolver); - } - - /** - * Serializes this Passenger to a ByteBuffer. - * @return a buffer holding the serialized data for this instance - * @throws java.io.IOException if this instance could not be serialized - */ - public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException { - return ENCODER.encode(this); - } - - /** - * Deserializes a Passenger from a ByteBuffer. - * @param b a byte buffer holding serialized data for an instance of this class - * @return a Passenger instance decoded from the given buffer - * @throws java.io.IOException if the given bytes could not be deserialized into an instance of this class - */ - public static Passenger fromByteBuffer( - java.nio.ByteBuffer b) throws java.io.IOException { - return DECODER.decode(b); - } - - private java.lang.CharSequence id; - private java.lang.CharSequence name; - private java.lang.CharSequence passport_number; - private java.lang.CharSequence nationality; - - /** - * Default constructor. Note that this does not initialize fields - * to their default values from the schema. If that is desired then - * one should use newBuilder(). - */ - public Passenger() {} - - /** - * All-args constructor. - * @param id The new value for id - * @param name The new value for name - * @param passport_number The new value for passport_number - * @param nationality The new value for nationality - */ - public Passenger(java.lang.CharSequence id, java.lang.CharSequence name, java.lang.CharSequence passport_number, java.lang.CharSequence nationality) { - this.id = id; - this.name = name; - this.passport_number = passport_number; - this.nationality = nationality; - } - - @Override - public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; } - - @Override - public org.apache.avro.Schema getSchema() { return SCHEMA$; } - - // Used by DatumWriter. Applications should not call. - @Override - public java.lang.Object get(int field$) { - switch (field$) { - case 0: return id; - case 1: return name; - case 2: return passport_number; - case 3: return nationality; - default: throw new IndexOutOfBoundsException("Invalid index: " + field$); - } - } - - // Used by DatumReader. Applications should not call. - @Override - @SuppressWarnings(value="unchecked") - public void put(int field$, java.lang.Object value$) { - switch (field$) { - case 0: id = (java.lang.CharSequence)value$; break; - case 1: name = (java.lang.CharSequence)value$; break; - case 2: passport_number = (java.lang.CharSequence)value$; break; - case 3: nationality = (java.lang.CharSequence)value$; break; - default: throw new IndexOutOfBoundsException("Invalid index: " + field$); - } - } - - /** - * Gets the value of the 'id' field. - * @return The value of the 'id' field. - */ - public java.lang.CharSequence getId() { - return id; - } - - - /** - * Sets the value of the 'id' field. - * @param value the value to set. - */ - public void setId(java.lang.CharSequence value) { - this.id = value; - } - - /** - * Gets the value of the 'name' field. - * @return The value of the 'name' field. - */ - public java.lang.CharSequence getName() { - return name; - } - - - /** - * Sets the value of the 'name' field. - * @param value the value to set. - */ - public void setName(java.lang.CharSequence value) { - this.name = value; - } - - /** - * Gets the value of the 'passport_number' field. - * @return The value of the 'passport_number' field. - */ - public java.lang.CharSequence getPassportNumber() { - return passport_number; - } - - - /** - * Sets the value of the 'passport_number' field. - * @param value the value to set. - */ - public void setPassportNumber(java.lang.CharSequence value) { - this.passport_number = value; - } - - /** - * Gets the value of the 'nationality' field. - * @return The value of the 'nationality' field. - */ - public java.lang.CharSequence getNationality() { - return nationality; - } - - - /** - * Sets the value of the 'nationality' field. - * @param value the value to set. - */ - public void setNationality(java.lang.CharSequence value) { - this.nationality = value; - } - - /** - * Creates a new Passenger RecordBuilder. - * @return A new Passenger RecordBuilder - */ - public static io.skodjob.datagenerator.models.flights.Passenger.Builder newBuilder() { - return new io.skodjob.datagenerator.models.flights.Passenger.Builder(); - } - - /** - * Creates a new Passenger RecordBuilder by copying an existing Builder. - * @param other The existing builder to copy. - * @return A new Passenger RecordBuilder - */ - public static io.skodjob.datagenerator.models.flights.Passenger.Builder newBuilder(io.skodjob.datagenerator.models.flights.Passenger.Builder other) { - if (other == null) { - return new io.skodjob.datagenerator.models.flights.Passenger.Builder(); - } else { - return new io.skodjob.datagenerator.models.flights.Passenger.Builder(other); - } - } - - /** - * Creates a new Passenger RecordBuilder by copying an existing Passenger instance. - * @param other The existing instance to copy. - * @return A new Passenger RecordBuilder - */ - public static io.skodjob.datagenerator.models.flights.Passenger.Builder newBuilder(io.skodjob.datagenerator.models.flights.Passenger other) { - if (other == null) { - return new io.skodjob.datagenerator.models.flights.Passenger.Builder(); - } else { - return new io.skodjob.datagenerator.models.flights.Passenger.Builder(other); - } - } - - /** - * RecordBuilder for Passenger instances. - */ - @org.apache.avro.specific.AvroGenerated - public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase - implements org.apache.avro.data.RecordBuilder { - - private java.lang.CharSequence id; - private java.lang.CharSequence name; - private java.lang.CharSequence passport_number; - private java.lang.CharSequence nationality; - - /** Creates a new Builder */ - private Builder() { - super(SCHEMA$, MODEL$); - } - - /** - * Creates a Builder by copying an existing Builder. - * @param other The existing Builder to copy. - */ - private Builder(io.skodjob.datagenerator.models.flights.Passenger.Builder other) { - super(other); - if (isValidValue(fields()[0], other.id)) { - this.id = data().deepCopy(fields()[0].schema(), other.id); - fieldSetFlags()[0] = other.fieldSetFlags()[0]; - } - if (isValidValue(fields()[1], other.name)) { - this.name = data().deepCopy(fields()[1].schema(), other.name); - fieldSetFlags()[1] = other.fieldSetFlags()[1]; - } - if (isValidValue(fields()[2], other.passport_number)) { - this.passport_number = data().deepCopy(fields()[2].schema(), other.passport_number); - fieldSetFlags()[2] = other.fieldSetFlags()[2]; - } - if (isValidValue(fields()[3], other.nationality)) { - this.nationality = data().deepCopy(fields()[3].schema(), other.nationality); - fieldSetFlags()[3] = other.fieldSetFlags()[3]; - } - } - - /** - * Creates a Builder by copying an existing Passenger instance - * @param other The existing instance to copy. - */ - private Builder(io.skodjob.datagenerator.models.flights.Passenger other) { - super(SCHEMA$, MODEL$); - if (isValidValue(fields()[0], other.id)) { - this.id = data().deepCopy(fields()[0].schema(), other.id); - fieldSetFlags()[0] = true; - } - if (isValidValue(fields()[1], other.name)) { - this.name = data().deepCopy(fields()[1].schema(), other.name); - fieldSetFlags()[1] = true; - } - if (isValidValue(fields()[2], other.passport_number)) { - this.passport_number = data().deepCopy(fields()[2].schema(), other.passport_number); - fieldSetFlags()[2] = true; - } - if (isValidValue(fields()[3], other.nationality)) { - this.nationality = data().deepCopy(fields()[3].schema(), other.nationality); - fieldSetFlags()[3] = true; - } - } - - /** - * Gets the value of the 'id' field. - * @return The value. - */ - public java.lang.CharSequence getId() { - return id; - } - - - /** - * Sets the value of the 'id' field. - * @param value The value of 'id'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.flights.Passenger.Builder setId(java.lang.CharSequence value) { - validate(fields()[0], value); - this.id = value; - fieldSetFlags()[0] = true; - return this; - } - - /** - * Checks whether the 'id' field has been set. - * @return True if the 'id' field has been set, false otherwise. - */ - public boolean hasId() { - return fieldSetFlags()[0]; - } - - - /** - * Clears the value of the 'id' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.flights.Passenger.Builder clearId() { - id = null; - fieldSetFlags()[0] = false; - return this; - } - - /** - * Gets the value of the 'name' field. - * @return The value. - */ - public java.lang.CharSequence getName() { - return name; - } - - - /** - * Sets the value of the 'name' field. - * @param value The value of 'name'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.flights.Passenger.Builder setName(java.lang.CharSequence value) { - validate(fields()[1], value); - this.name = value; - fieldSetFlags()[1] = true; - return this; - } - - /** - * Checks whether the 'name' field has been set. - * @return True if the 'name' field has been set, false otherwise. - */ - public boolean hasName() { - return fieldSetFlags()[1]; - } - - - /** - * Clears the value of the 'name' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.flights.Passenger.Builder clearName() { - name = null; - fieldSetFlags()[1] = false; - return this; - } - - /** - * Gets the value of the 'passport_number' field. - * @return The value. - */ - public java.lang.CharSequence getPassportNumber() { - return passport_number; - } - - - /** - * Sets the value of the 'passport_number' field. - * @param value The value of 'passport_number'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.flights.Passenger.Builder setPassportNumber(java.lang.CharSequence value) { - validate(fields()[2], value); - this.passport_number = value; - fieldSetFlags()[2] = true; - return this; - } - - /** - * Checks whether the 'passport_number' field has been set. - * @return True if the 'passport_number' field has been set, false otherwise. - */ - public boolean hasPassportNumber() { - return fieldSetFlags()[2]; - } - - - /** - * Clears the value of the 'passport_number' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.flights.Passenger.Builder clearPassportNumber() { - passport_number = null; - fieldSetFlags()[2] = false; - return this; - } - - /** - * Gets the value of the 'nationality' field. - * @return The value. - */ - public java.lang.CharSequence getNationality() { - return nationality; - } - - - /** - * Sets the value of the 'nationality' field. - * @param value The value of 'nationality'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.flights.Passenger.Builder setNationality(java.lang.CharSequence value) { - validate(fields()[3], value); - this.nationality = value; - fieldSetFlags()[3] = true; - return this; - } - - /** - * Checks whether the 'nationality' field has been set. - * @return True if the 'nationality' field has been set, false otherwise. - */ - public boolean hasNationality() { - return fieldSetFlags()[3]; - } - - - /** - * Clears the value of the 'nationality' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.flights.Passenger.Builder clearNationality() { - nationality = null; - fieldSetFlags()[3] = false; - return this; - } - - @Override - @SuppressWarnings("unchecked") - public Passenger build() { - try { - Passenger record = new Passenger(); - record.id = fieldSetFlags()[0] ? this.id : (java.lang.CharSequence) defaultValue(fields()[0]); - record.name = fieldSetFlags()[1] ? this.name : (java.lang.CharSequence) defaultValue(fields()[1]); - record.passport_number = fieldSetFlags()[2] ? this.passport_number : (java.lang.CharSequence) defaultValue(fields()[2]); - record.nationality = fieldSetFlags()[3] ? this.nationality : (java.lang.CharSequence) defaultValue(fields()[3]); - return record; - } catch (org.apache.avro.AvroMissingFieldException e) { - throw e; - } catch (java.lang.Exception e) { - throw new org.apache.avro.AvroRuntimeException(e); - } - } - } - - @SuppressWarnings("unchecked") - private static final org.apache.avro.io.DatumWriter - WRITER$ = (org.apache.avro.io.DatumWriter)MODEL$.createDatumWriter(SCHEMA$); - - @Override public void writeExternal(java.io.ObjectOutput out) - throws java.io.IOException { - WRITER$.write(this, SpecificData.getEncoder(out)); - } - - @SuppressWarnings("unchecked") - private static final org.apache.avro.io.DatumReader - READER$ = (org.apache.avro.io.DatumReader)MODEL$.createDatumReader(SCHEMA$); - - @Override public void readExternal(java.io.ObjectInput in) - throws java.io.IOException { - READER$.read(this, SpecificData.getDecoder(in)); - } - - @Override protected boolean hasCustomCoders() { return true; } - - @Override public void customEncode(org.apache.avro.io.Encoder out) - throws java.io.IOException - { - out.writeString(this.id); - - out.writeString(this.name); - - out.writeString(this.passport_number); - - out.writeString(this.nationality); - - } - - @Override public void customDecode(org.apache.avro.io.ResolvingDecoder in) - throws java.io.IOException - { - org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff(); - if (fieldOrder == null) { - this.id = in.readString(this.id instanceof Utf8 ? (Utf8)this.id : null); - - this.name = in.readString(this.name instanceof Utf8 ? (Utf8)this.name : null); - - this.passport_number = in.readString(this.passport_number instanceof Utf8 ? (Utf8)this.passport_number : null); - - this.nationality = in.readString(this.nationality instanceof Utf8 ? (Utf8)this.nationality : null); - - } else { - for (int i = 0; i < 4; i++) { - switch (fieldOrder[i].pos()) { - case 0: - this.id = in.readString(this.id instanceof Utf8 ? (Utf8)this.id : null); - break; - - case 1: - this.name = in.readString(this.name instanceof Utf8 ? (Utf8)this.name : null); - break; - - case 2: - this.passport_number = in.readString(this.passport_number instanceof Utf8 ? (Utf8)this.passport_number : null); - break; - - case 3: - this.nationality = in.readString(this.nationality instanceof Utf8 ? (Utf8)this.nationality : null); - break; - - default: - throw new java.io.IOException("Corrupt ResolvingDecoder."); - } - } - } - } -} - - - - - - - - - - diff --git a/src/main/java/io/skodjob/datagenerator/models/iotdevice/Battery.java b/src/main/java/io/skodjob/datagenerator/models/iotdevice/Battery.java deleted file mode 100644 index 404eaa5..0000000 --- a/src/main/java/io/skodjob/datagenerator/models/iotdevice/Battery.java +++ /dev/null @@ -1,398 +0,0 @@ -/** - * Autogenerated by Avro - * - * DO NOT EDIT DIRECTLY - */ -package io.skodjob.datagenerator.models.iotdevice; - -import org.apache.avro.generic.GenericArray; -import org.apache.avro.specific.SpecificData; -import org.apache.avro.util.Utf8; -import org.apache.avro.message.BinaryMessageEncoder; -import org.apache.avro.message.BinaryMessageDecoder; -import org.apache.avro.message.SchemaStore; - -@org.apache.avro.specific.AvroGenerated -public class Battery extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord { - private static final long serialVersionUID = 4816886687575535407L; - - - public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"Battery\",\"namespace\":\"io.skodjob.datagenerator.models.iotdevice\",\"fields\":[{\"name\":\"value\",\"type\":\"int\"},{\"name\":\"unit\",\"type\":\"string\"}]}"); - public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } - - private static final SpecificData MODEL$ = new SpecificData(); - - private static final BinaryMessageEncoder ENCODER = - new BinaryMessageEncoder<>(MODEL$, SCHEMA$); - - private static final BinaryMessageDecoder DECODER = - new BinaryMessageDecoder<>(MODEL$, SCHEMA$); - - /** - * Return the BinaryMessageEncoder instance used by this class. - * @return the message encoder used by this class - */ - public static BinaryMessageEncoder getEncoder() { - return ENCODER; - } - - /** - * Return the BinaryMessageDecoder instance used by this class. - * @return the message decoder used by this class - */ - public static BinaryMessageDecoder getDecoder() { - return DECODER; - } - - /** - * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}. - * @param resolver a {@link SchemaStore} used to find schemas by fingerprint - * @return a BinaryMessageDecoder instance for this class backed by the given SchemaStore - */ - public static BinaryMessageDecoder createDecoder(SchemaStore resolver) { - return new BinaryMessageDecoder<>(MODEL$, SCHEMA$, resolver); - } - - /** - * Serializes this Battery to a ByteBuffer. - * @return a buffer holding the serialized data for this instance - * @throws java.io.IOException if this instance could not be serialized - */ - public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException { - return ENCODER.encode(this); - } - - /** - * Deserializes a Battery from a ByteBuffer. - * @param b a byte buffer holding serialized data for an instance of this class - * @return a Battery instance decoded from the given buffer - * @throws java.io.IOException if the given bytes could not be deserialized into an instance of this class - */ - public static Battery fromByteBuffer( - java.nio.ByteBuffer b) throws java.io.IOException { - return DECODER.decode(b); - } - - private int value; - private java.lang.CharSequence unit; - - /** - * Default constructor. Note that this does not initialize fields - * to their default values from the schema. If that is desired then - * one should use newBuilder(). - */ - public Battery() {} - - /** - * All-args constructor. - * @param value The new value for value - * @param unit The new value for unit - */ - public Battery(java.lang.Integer value, java.lang.CharSequence unit) { - this.value = value; - this.unit = unit; - } - - @Override - public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; } - - @Override - public org.apache.avro.Schema getSchema() { return SCHEMA$; } - - // Used by DatumWriter. Applications should not call. - @Override - public java.lang.Object get(int field$) { - switch (field$) { - case 0: return value; - case 1: return unit; - default: throw new IndexOutOfBoundsException("Invalid index: " + field$); - } - } - - // Used by DatumReader. Applications should not call. - @Override - @SuppressWarnings(value="unchecked") - public void put(int field$, java.lang.Object value$) { - switch (field$) { - case 0: value = (java.lang.Integer)value$; break; - case 1: unit = (java.lang.CharSequence)value$; break; - default: throw new IndexOutOfBoundsException("Invalid index: " + field$); - } - } - - /** - * Gets the value of the 'value' field. - * @return The value of the 'value' field. - */ - public int getValue() { - return value; - } - - - /** - * Sets the value of the 'value' field. - * @param value the value to set. - */ - public void setValue(int value) { - this.value = value; - } - - /** - * Gets the value of the 'unit' field. - * @return The value of the 'unit' field. - */ - public java.lang.CharSequence getUnit() { - return unit; - } - - - /** - * Sets the value of the 'unit' field. - * @param value the value to set. - */ - public void setUnit(java.lang.CharSequence value) { - this.unit = value; - } - - /** - * Creates a new Battery RecordBuilder. - * @return A new Battery RecordBuilder - */ - public static io.skodjob.datagenerator.models.iotdevice.Battery.Builder newBuilder() { - return new io.skodjob.datagenerator.models.iotdevice.Battery.Builder(); - } - - /** - * Creates a new Battery RecordBuilder by copying an existing Builder. - * @param other The existing builder to copy. - * @return A new Battery RecordBuilder - */ - public static io.skodjob.datagenerator.models.iotdevice.Battery.Builder newBuilder(io.skodjob.datagenerator.models.iotdevice.Battery.Builder other) { - if (other == null) { - return new io.skodjob.datagenerator.models.iotdevice.Battery.Builder(); - } else { - return new io.skodjob.datagenerator.models.iotdevice.Battery.Builder(other); - } - } - - /** - * Creates a new Battery RecordBuilder by copying an existing Battery instance. - * @param other The existing instance to copy. - * @return A new Battery RecordBuilder - */ - public static io.skodjob.datagenerator.models.iotdevice.Battery.Builder newBuilder(io.skodjob.datagenerator.models.iotdevice.Battery other) { - if (other == null) { - return new io.skodjob.datagenerator.models.iotdevice.Battery.Builder(); - } else { - return new io.skodjob.datagenerator.models.iotdevice.Battery.Builder(other); - } - } - - /** - * RecordBuilder for Battery instances. - */ - @org.apache.avro.specific.AvroGenerated - public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase - implements org.apache.avro.data.RecordBuilder { - - private int value; - private java.lang.CharSequence unit; - - /** Creates a new Builder */ - private Builder() { - super(SCHEMA$, MODEL$); - } - - /** - * Creates a Builder by copying an existing Builder. - * @param other The existing Builder to copy. - */ - private Builder(io.skodjob.datagenerator.models.iotdevice.Battery.Builder other) { - super(other); - if (isValidValue(fields()[0], other.value)) { - this.value = data().deepCopy(fields()[0].schema(), other.value); - fieldSetFlags()[0] = other.fieldSetFlags()[0]; - } - if (isValidValue(fields()[1], other.unit)) { - this.unit = data().deepCopy(fields()[1].schema(), other.unit); - fieldSetFlags()[1] = other.fieldSetFlags()[1]; - } - } - - /** - * Creates a Builder by copying an existing Battery instance - * @param other The existing instance to copy. - */ - private Builder(io.skodjob.datagenerator.models.iotdevice.Battery other) { - super(SCHEMA$, MODEL$); - if (isValidValue(fields()[0], other.value)) { - this.value = data().deepCopy(fields()[0].schema(), other.value); - fieldSetFlags()[0] = true; - } - if (isValidValue(fields()[1], other.unit)) { - this.unit = data().deepCopy(fields()[1].schema(), other.unit); - fieldSetFlags()[1] = true; - } - } - - /** - * Gets the value of the 'value' field. - * @return The value. - */ - public int getValue() { - return value; - } - - - /** - * Sets the value of the 'value' field. - * @param value The value of 'value'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.iotdevice.Battery.Builder setValue(int value) { - validate(fields()[0], value); - this.value = value; - fieldSetFlags()[0] = true; - return this; - } - - /** - * Checks whether the 'value' field has been set. - * @return True if the 'value' field has been set, false otherwise. - */ - public boolean hasValue() { - return fieldSetFlags()[0]; - } - - - /** - * Clears the value of the 'value' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.iotdevice.Battery.Builder clearValue() { - fieldSetFlags()[0] = false; - return this; - } - - /** - * Gets the value of the 'unit' field. - * @return The value. - */ - public java.lang.CharSequence getUnit() { - return unit; - } - - - /** - * Sets the value of the 'unit' field. - * @param value The value of 'unit'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.iotdevice.Battery.Builder setUnit(java.lang.CharSequence value) { - validate(fields()[1], value); - this.unit = value; - fieldSetFlags()[1] = true; - return this; - } - - /** - * Checks whether the 'unit' field has been set. - * @return True if the 'unit' field has been set, false otherwise. - */ - public boolean hasUnit() { - return fieldSetFlags()[1]; - } - - - /** - * Clears the value of the 'unit' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.iotdevice.Battery.Builder clearUnit() { - unit = null; - fieldSetFlags()[1] = false; - return this; - } - - @Override - @SuppressWarnings("unchecked") - public Battery build() { - try { - Battery record = new Battery(); - record.value = fieldSetFlags()[0] ? this.value : (java.lang.Integer) defaultValue(fields()[0]); - record.unit = fieldSetFlags()[1] ? this.unit : (java.lang.CharSequence) defaultValue(fields()[1]); - return record; - } catch (org.apache.avro.AvroMissingFieldException e) { - throw e; - } catch (java.lang.Exception e) { - throw new org.apache.avro.AvroRuntimeException(e); - } - } - } - - @SuppressWarnings("unchecked") - private static final org.apache.avro.io.DatumWriter - WRITER$ = (org.apache.avro.io.DatumWriter)MODEL$.createDatumWriter(SCHEMA$); - - @Override public void writeExternal(java.io.ObjectOutput out) - throws java.io.IOException { - WRITER$.write(this, SpecificData.getEncoder(out)); - } - - @SuppressWarnings("unchecked") - private static final org.apache.avro.io.DatumReader - READER$ = (org.apache.avro.io.DatumReader)MODEL$.createDatumReader(SCHEMA$); - - @Override public void readExternal(java.io.ObjectInput in) - throws java.io.IOException { - READER$.read(this, SpecificData.getDecoder(in)); - } - - @Override protected boolean hasCustomCoders() { return true; } - - @Override public void customEncode(org.apache.avro.io.Encoder out) - throws java.io.IOException - { - out.writeInt(this.value); - - out.writeString(this.unit); - - } - - @Override public void customDecode(org.apache.avro.io.ResolvingDecoder in) - throws java.io.IOException - { - org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff(); - if (fieldOrder == null) { - this.value = in.readInt(); - - this.unit = in.readString(this.unit instanceof Utf8 ? (Utf8)this.unit : null); - - } else { - for (int i = 0; i < 2; i++) { - switch (fieldOrder[i].pos()) { - case 0: - this.value = in.readInt(); - break; - - case 1: - this.unit = in.readString(this.unit instanceof Utf8 ? (Utf8)this.unit : null); - break; - - default: - throw new java.io.IOException("Corrupt ResolvingDecoder."); - } - } - } - } -} - - - - - - - - - - diff --git a/src/main/java/io/skodjob/datagenerator/models/iotdevice/ButtonData.java b/src/main/java/io/skodjob/datagenerator/models/iotdevice/ButtonData.java deleted file mode 100644 index 3a4ad44..0000000 --- a/src/main/java/io/skodjob/datagenerator/models/iotdevice/ButtonData.java +++ /dev/null @@ -1,455 +0,0 @@ -/** - * Autogenerated by Avro - * - * DO NOT EDIT DIRECTLY - */ -package io.skodjob.datagenerator.models.iotdevice; - -import org.apache.avro.generic.GenericArray; -import org.apache.avro.specific.SpecificData; -import org.apache.avro.util.Utf8; -import org.apache.avro.message.BinaryMessageEncoder; -import org.apache.avro.message.BinaryMessageDecoder; -import org.apache.avro.message.SchemaStore; - -@org.apache.avro.specific.AvroGenerated -public class ButtonData extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord { - private static final long serialVersionUID = -6315539208887626138L; - - - public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"ButtonData\",\"namespace\":\"io.skodjob.datagenerator.models.iotdevice\",\"fields\":[{\"name\":\"power\",\"type\":\"string\"},{\"name\":\"battery\",\"type\":{\"type\":\"record\",\"name\":\"Battery\",\"fields\":[{\"name\":\"value\",\"type\":\"int\"},{\"name\":\"unit\",\"type\":\"string\"}]}}]}"); - public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } - - private static final SpecificData MODEL$ = new SpecificData(); - - private static final BinaryMessageEncoder ENCODER = - new BinaryMessageEncoder<>(MODEL$, SCHEMA$); - - private static final BinaryMessageDecoder DECODER = - new BinaryMessageDecoder<>(MODEL$, SCHEMA$); - - /** - * Return the BinaryMessageEncoder instance used by this class. - * @return the message encoder used by this class - */ - public static BinaryMessageEncoder getEncoder() { - return ENCODER; - } - - /** - * Return the BinaryMessageDecoder instance used by this class. - * @return the message decoder used by this class - */ - public static BinaryMessageDecoder getDecoder() { - return DECODER; - } - - /** - * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}. - * @param resolver a {@link SchemaStore} used to find schemas by fingerprint - * @return a BinaryMessageDecoder instance for this class backed by the given SchemaStore - */ - public static BinaryMessageDecoder createDecoder(SchemaStore resolver) { - return new BinaryMessageDecoder<>(MODEL$, SCHEMA$, resolver); - } - - /** - * Serializes this ButtonData to a ByteBuffer. - * @return a buffer holding the serialized data for this instance - * @throws java.io.IOException if this instance could not be serialized - */ - public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException { - return ENCODER.encode(this); - } - - /** - * Deserializes a ButtonData from a ByteBuffer. - * @param b a byte buffer holding serialized data for an instance of this class - * @return a ButtonData instance decoded from the given buffer - * @throws java.io.IOException if the given bytes could not be deserialized into an instance of this class - */ - public static ButtonData fromByteBuffer( - java.nio.ByteBuffer b) throws java.io.IOException { - return DECODER.decode(b); - } - - private java.lang.CharSequence power; - private io.skodjob.datagenerator.models.iotdevice.Battery battery; - - /** - * Default constructor. Note that this does not initialize fields - * to their default values from the schema. If that is desired then - * one should use newBuilder(). - */ - public ButtonData() {} - - /** - * All-args constructor. - * @param power The new value for power - * @param battery The new value for battery - */ - public ButtonData(java.lang.CharSequence power, io.skodjob.datagenerator.models.iotdevice.Battery battery) { - this.power = power; - this.battery = battery; - } - - @Override - public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; } - - @Override - public org.apache.avro.Schema getSchema() { return SCHEMA$; } - - // Used by DatumWriter. Applications should not call. - @Override - public java.lang.Object get(int field$) { - switch (field$) { - case 0: return power; - case 1: return battery; - default: throw new IndexOutOfBoundsException("Invalid index: " + field$); - } - } - - // Used by DatumReader. Applications should not call. - @Override - @SuppressWarnings(value="unchecked") - public void put(int field$, java.lang.Object value$) { - switch (field$) { - case 0: power = (java.lang.CharSequence)value$; break; - case 1: battery = (io.skodjob.datagenerator.models.iotdevice.Battery)value$; break; - default: throw new IndexOutOfBoundsException("Invalid index: " + field$); - } - } - - /** - * Gets the value of the 'power' field. - * @return The value of the 'power' field. - */ - public java.lang.CharSequence getPower() { - return power; - } - - - /** - * Sets the value of the 'power' field. - * @param value the value to set. - */ - public void setPower(java.lang.CharSequence value) { - this.power = value; - } - - /** - * Gets the value of the 'battery' field. - * @return The value of the 'battery' field. - */ - public io.skodjob.datagenerator.models.iotdevice.Battery getBattery() { - return battery; - } - - - /** - * Sets the value of the 'battery' field. - * @param value the value to set. - */ - public void setBattery(io.skodjob.datagenerator.models.iotdevice.Battery value) { - this.battery = value; - } - - /** - * Creates a new ButtonData RecordBuilder. - * @return A new ButtonData RecordBuilder - */ - public static io.skodjob.datagenerator.models.iotdevice.ButtonData.Builder newBuilder() { - return new io.skodjob.datagenerator.models.iotdevice.ButtonData.Builder(); - } - - /** - * Creates a new ButtonData RecordBuilder by copying an existing Builder. - * @param other The existing builder to copy. - * @return A new ButtonData RecordBuilder - */ - public static io.skodjob.datagenerator.models.iotdevice.ButtonData.Builder newBuilder(io.skodjob.datagenerator.models.iotdevice.ButtonData.Builder other) { - if (other == null) { - return new io.skodjob.datagenerator.models.iotdevice.ButtonData.Builder(); - } else { - return new io.skodjob.datagenerator.models.iotdevice.ButtonData.Builder(other); - } - } - - /** - * Creates a new ButtonData RecordBuilder by copying an existing ButtonData instance. - * @param other The existing instance to copy. - * @return A new ButtonData RecordBuilder - */ - public static io.skodjob.datagenerator.models.iotdevice.ButtonData.Builder newBuilder(io.skodjob.datagenerator.models.iotdevice.ButtonData other) { - if (other == null) { - return new io.skodjob.datagenerator.models.iotdevice.ButtonData.Builder(); - } else { - return new io.skodjob.datagenerator.models.iotdevice.ButtonData.Builder(other); - } - } - - /** - * RecordBuilder for ButtonData instances. - */ - @org.apache.avro.specific.AvroGenerated - public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase - implements org.apache.avro.data.RecordBuilder { - - private java.lang.CharSequence power; - private io.skodjob.datagenerator.models.iotdevice.Battery battery; - private io.skodjob.datagenerator.models.iotdevice.Battery.Builder batteryBuilder; - - /** Creates a new Builder */ - private Builder() { - super(SCHEMA$, MODEL$); - } - - /** - * Creates a Builder by copying an existing Builder. - * @param other The existing Builder to copy. - */ - private Builder(io.skodjob.datagenerator.models.iotdevice.ButtonData.Builder other) { - super(other); - if (isValidValue(fields()[0], other.power)) { - this.power = data().deepCopy(fields()[0].schema(), other.power); - fieldSetFlags()[0] = other.fieldSetFlags()[0]; - } - if (isValidValue(fields()[1], other.battery)) { - this.battery = data().deepCopy(fields()[1].schema(), other.battery); - fieldSetFlags()[1] = other.fieldSetFlags()[1]; - } - if (other.hasBatteryBuilder()) { - this.batteryBuilder = io.skodjob.datagenerator.models.iotdevice.Battery.newBuilder(other.getBatteryBuilder()); - } - } - - /** - * Creates a Builder by copying an existing ButtonData instance - * @param other The existing instance to copy. - */ - private Builder(io.skodjob.datagenerator.models.iotdevice.ButtonData other) { - super(SCHEMA$, MODEL$); - if (isValidValue(fields()[0], other.power)) { - this.power = data().deepCopy(fields()[0].schema(), other.power); - fieldSetFlags()[0] = true; - } - if (isValidValue(fields()[1], other.battery)) { - this.battery = data().deepCopy(fields()[1].schema(), other.battery); - fieldSetFlags()[1] = true; - } - this.batteryBuilder = null; - } - - /** - * Gets the value of the 'power' field. - * @return The value. - */ - public java.lang.CharSequence getPower() { - return power; - } - - - /** - * Sets the value of the 'power' field. - * @param value The value of 'power'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.iotdevice.ButtonData.Builder setPower(java.lang.CharSequence value) { - validate(fields()[0], value); - this.power = value; - fieldSetFlags()[0] = true; - return this; - } - - /** - * Checks whether the 'power' field has been set. - * @return True if the 'power' field has been set, false otherwise. - */ - public boolean hasPower() { - return fieldSetFlags()[0]; - } - - - /** - * Clears the value of the 'power' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.iotdevice.ButtonData.Builder clearPower() { - power = null; - fieldSetFlags()[0] = false; - return this; - } - - /** - * Gets the value of the 'battery' field. - * @return The value. - */ - public io.skodjob.datagenerator.models.iotdevice.Battery getBattery() { - return battery; - } - - - /** - * Sets the value of the 'battery' field. - * @param value The value of 'battery'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.iotdevice.ButtonData.Builder setBattery(io.skodjob.datagenerator.models.iotdevice.Battery value) { - validate(fields()[1], value); - this.batteryBuilder = null; - this.battery = value; - fieldSetFlags()[1] = true; - return this; - } - - /** - * Checks whether the 'battery' field has been set. - * @return True if the 'battery' field has been set, false otherwise. - */ - public boolean hasBattery() { - return fieldSetFlags()[1]; - } - - /** - * Gets the Builder instance for the 'battery' field and creates one if it doesn't exist yet. - * @return This builder. - */ - public io.skodjob.datagenerator.models.iotdevice.Battery.Builder getBatteryBuilder() { - if (batteryBuilder == null) { - if (hasBattery()) { - setBatteryBuilder(io.skodjob.datagenerator.models.iotdevice.Battery.newBuilder(battery)); - } else { - setBatteryBuilder(io.skodjob.datagenerator.models.iotdevice.Battery.newBuilder()); - } - } - return batteryBuilder; - } - - /** - * Sets the Builder instance for the 'battery' field - * @param value The builder instance that must be set. - * @return This builder. - */ - - public io.skodjob.datagenerator.models.iotdevice.ButtonData.Builder setBatteryBuilder(io.skodjob.datagenerator.models.iotdevice.Battery.Builder value) { - clearBattery(); - batteryBuilder = value; - return this; - } - - /** - * Checks whether the 'battery' field has an active Builder instance - * @return True if the 'battery' field has an active Builder instance - */ - public boolean hasBatteryBuilder() { - return batteryBuilder != null; - } - - /** - * Clears the value of the 'battery' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.iotdevice.ButtonData.Builder clearBattery() { - battery = null; - batteryBuilder = null; - fieldSetFlags()[1] = false; - return this; - } - - @Override - @SuppressWarnings("unchecked") - public ButtonData build() { - try { - ButtonData record = new ButtonData(); - record.power = fieldSetFlags()[0] ? this.power : (java.lang.CharSequence) defaultValue(fields()[0]); - if (batteryBuilder != null) { - try { - record.battery = this.batteryBuilder.build(); - } catch (org.apache.avro.AvroMissingFieldException e) { - e.addParentField(record.getSchema().getField("battery")); - throw e; - } - } else { - record.battery = fieldSetFlags()[1] ? this.battery : (io.skodjob.datagenerator.models.iotdevice.Battery) defaultValue(fields()[1]); - } - return record; - } catch (org.apache.avro.AvroMissingFieldException e) { - throw e; - } catch (java.lang.Exception e) { - throw new org.apache.avro.AvroRuntimeException(e); - } - } - } - - @SuppressWarnings("unchecked") - private static final org.apache.avro.io.DatumWriter - WRITER$ = (org.apache.avro.io.DatumWriter)MODEL$.createDatumWriter(SCHEMA$); - - @Override public void writeExternal(java.io.ObjectOutput out) - throws java.io.IOException { - WRITER$.write(this, SpecificData.getEncoder(out)); - } - - @SuppressWarnings("unchecked") - private static final org.apache.avro.io.DatumReader - READER$ = (org.apache.avro.io.DatumReader)MODEL$.createDatumReader(SCHEMA$); - - @Override public void readExternal(java.io.ObjectInput in) - throws java.io.IOException { - READER$.read(this, SpecificData.getDecoder(in)); - } - - @Override protected boolean hasCustomCoders() { return true; } - - @Override public void customEncode(org.apache.avro.io.Encoder out) - throws java.io.IOException - { - out.writeString(this.power); - - this.battery.customEncode(out); - - } - - @Override public void customDecode(org.apache.avro.io.ResolvingDecoder in) - throws java.io.IOException - { - org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff(); - if (fieldOrder == null) { - this.power = in.readString(this.power instanceof Utf8 ? (Utf8)this.power : null); - - if (this.battery == null) { - this.battery = new io.skodjob.datagenerator.models.iotdevice.Battery(); - } - this.battery.customDecode(in); - - } else { - for (int i = 0; i < 2; i++) { - switch (fieldOrder[i].pos()) { - case 0: - this.power = in.readString(this.power instanceof Utf8 ? (Utf8)this.power : null); - break; - - case 1: - if (this.battery == null) { - this.battery = new io.skodjob.datagenerator.models.iotdevice.Battery(); - } - this.battery.customDecode(in); - break; - - default: - throw new java.io.IOException("Corrupt ResolvingDecoder."); - } - } - } - } -} - - - - - - - - - - diff --git a/src/main/java/io/skodjob/datagenerator/models/iotdevice/CustomData.java b/src/main/java/io/skodjob/datagenerator/models/iotdevice/CustomData.java deleted file mode 100644 index a453f23..0000000 --- a/src/main/java/io/skodjob/datagenerator/models/iotdevice/CustomData.java +++ /dev/null @@ -1,399 +0,0 @@ -/** - * Autogenerated by Avro - * - * DO NOT EDIT DIRECTLY - */ -package io.skodjob.datagenerator.models.iotdevice; - -import org.apache.avro.generic.GenericArray; -import org.apache.avro.specific.SpecificData; -import org.apache.avro.util.Utf8; -import org.apache.avro.message.BinaryMessageEncoder; -import org.apache.avro.message.BinaryMessageDecoder; -import org.apache.avro.message.SchemaStore; - -@org.apache.avro.specific.AvroGenerated -public class CustomData extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord { - private static final long serialVersionUID = 5873049232784909190L; - - - public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"CustomData\",\"namespace\":\"io.skodjob.datagenerator.models.iotdevice\",\"fields\":[{\"name\":\"info\",\"type\":\"string\"},{\"name\":\"state\",\"type\":\"string\"}]}"); - public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } - - private static final SpecificData MODEL$ = new SpecificData(); - - private static final BinaryMessageEncoder ENCODER = - new BinaryMessageEncoder<>(MODEL$, SCHEMA$); - - private static final BinaryMessageDecoder DECODER = - new BinaryMessageDecoder<>(MODEL$, SCHEMA$); - - /** - * Return the BinaryMessageEncoder instance used by this class. - * @return the message encoder used by this class - */ - public static BinaryMessageEncoder getEncoder() { - return ENCODER; - } - - /** - * Return the BinaryMessageDecoder instance used by this class. - * @return the message decoder used by this class - */ - public static BinaryMessageDecoder getDecoder() { - return DECODER; - } - - /** - * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}. - * @param resolver a {@link SchemaStore} used to find schemas by fingerprint - * @return a BinaryMessageDecoder instance for this class backed by the given SchemaStore - */ - public static BinaryMessageDecoder createDecoder(SchemaStore resolver) { - return new BinaryMessageDecoder<>(MODEL$, SCHEMA$, resolver); - } - - /** - * Serializes this CustomData to a ByteBuffer. - * @return a buffer holding the serialized data for this instance - * @throws java.io.IOException if this instance could not be serialized - */ - public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException { - return ENCODER.encode(this); - } - - /** - * Deserializes a CustomData from a ByteBuffer. - * @param b a byte buffer holding serialized data for an instance of this class - * @return a CustomData instance decoded from the given buffer - * @throws java.io.IOException if the given bytes could not be deserialized into an instance of this class - */ - public static CustomData fromByteBuffer( - java.nio.ByteBuffer b) throws java.io.IOException { - return DECODER.decode(b); - } - - private java.lang.CharSequence info; - private java.lang.CharSequence state; - - /** - * Default constructor. Note that this does not initialize fields - * to their default values from the schema. If that is desired then - * one should use newBuilder(). - */ - public CustomData() {} - - /** - * All-args constructor. - * @param info The new value for info - * @param state The new value for state - */ - public CustomData(java.lang.CharSequence info, java.lang.CharSequence state) { - this.info = info; - this.state = state; - } - - @Override - public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; } - - @Override - public org.apache.avro.Schema getSchema() { return SCHEMA$; } - - // Used by DatumWriter. Applications should not call. - @Override - public java.lang.Object get(int field$) { - switch (field$) { - case 0: return info; - case 1: return state; - default: throw new IndexOutOfBoundsException("Invalid index: " + field$); - } - } - - // Used by DatumReader. Applications should not call. - @Override - @SuppressWarnings(value="unchecked") - public void put(int field$, java.lang.Object value$) { - switch (field$) { - case 0: info = (java.lang.CharSequence)value$; break; - case 1: state = (java.lang.CharSequence)value$; break; - default: throw new IndexOutOfBoundsException("Invalid index: " + field$); - } - } - - /** - * Gets the value of the 'info' field. - * @return The value of the 'info' field. - */ - public java.lang.CharSequence getInfo() { - return info; - } - - - /** - * Sets the value of the 'info' field. - * @param value the value to set. - */ - public void setInfo(java.lang.CharSequence value) { - this.info = value; - } - - /** - * Gets the value of the 'state' field. - * @return The value of the 'state' field. - */ - public java.lang.CharSequence getState() { - return state; - } - - - /** - * Sets the value of the 'state' field. - * @param value the value to set. - */ - public void setState(java.lang.CharSequence value) { - this.state = value; - } - - /** - * Creates a new CustomData RecordBuilder. - * @return A new CustomData RecordBuilder - */ - public static io.skodjob.datagenerator.models.iotdevice.CustomData.Builder newBuilder() { - return new io.skodjob.datagenerator.models.iotdevice.CustomData.Builder(); - } - - /** - * Creates a new CustomData RecordBuilder by copying an existing Builder. - * @param other The existing builder to copy. - * @return A new CustomData RecordBuilder - */ - public static io.skodjob.datagenerator.models.iotdevice.CustomData.Builder newBuilder(io.skodjob.datagenerator.models.iotdevice.CustomData.Builder other) { - if (other == null) { - return new io.skodjob.datagenerator.models.iotdevice.CustomData.Builder(); - } else { - return new io.skodjob.datagenerator.models.iotdevice.CustomData.Builder(other); - } - } - - /** - * Creates a new CustomData RecordBuilder by copying an existing CustomData instance. - * @param other The existing instance to copy. - * @return A new CustomData RecordBuilder - */ - public static io.skodjob.datagenerator.models.iotdevice.CustomData.Builder newBuilder(io.skodjob.datagenerator.models.iotdevice.CustomData other) { - if (other == null) { - return new io.skodjob.datagenerator.models.iotdevice.CustomData.Builder(); - } else { - return new io.skodjob.datagenerator.models.iotdevice.CustomData.Builder(other); - } - } - - /** - * RecordBuilder for CustomData instances. - */ - @org.apache.avro.specific.AvroGenerated - public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase - implements org.apache.avro.data.RecordBuilder { - - private java.lang.CharSequence info; - private java.lang.CharSequence state; - - /** Creates a new Builder */ - private Builder() { - super(SCHEMA$, MODEL$); - } - - /** - * Creates a Builder by copying an existing Builder. - * @param other The existing Builder to copy. - */ - private Builder(io.skodjob.datagenerator.models.iotdevice.CustomData.Builder other) { - super(other); - if (isValidValue(fields()[0], other.info)) { - this.info = data().deepCopy(fields()[0].schema(), other.info); - fieldSetFlags()[0] = other.fieldSetFlags()[0]; - } - if (isValidValue(fields()[1], other.state)) { - this.state = data().deepCopy(fields()[1].schema(), other.state); - fieldSetFlags()[1] = other.fieldSetFlags()[1]; - } - } - - /** - * Creates a Builder by copying an existing CustomData instance - * @param other The existing instance to copy. - */ - private Builder(io.skodjob.datagenerator.models.iotdevice.CustomData other) { - super(SCHEMA$, MODEL$); - if (isValidValue(fields()[0], other.info)) { - this.info = data().deepCopy(fields()[0].schema(), other.info); - fieldSetFlags()[0] = true; - } - if (isValidValue(fields()[1], other.state)) { - this.state = data().deepCopy(fields()[1].schema(), other.state); - fieldSetFlags()[1] = true; - } - } - - /** - * Gets the value of the 'info' field. - * @return The value. - */ - public java.lang.CharSequence getInfo() { - return info; - } - - - /** - * Sets the value of the 'info' field. - * @param value The value of 'info'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.iotdevice.CustomData.Builder setInfo(java.lang.CharSequence value) { - validate(fields()[0], value); - this.info = value; - fieldSetFlags()[0] = true; - return this; - } - - /** - * Checks whether the 'info' field has been set. - * @return True if the 'info' field has been set, false otherwise. - */ - public boolean hasInfo() { - return fieldSetFlags()[0]; - } - - - /** - * Clears the value of the 'info' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.iotdevice.CustomData.Builder clearInfo() { - info = null; - fieldSetFlags()[0] = false; - return this; - } - - /** - * Gets the value of the 'state' field. - * @return The value. - */ - public java.lang.CharSequence getState() { - return state; - } - - - /** - * Sets the value of the 'state' field. - * @param value The value of 'state'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.iotdevice.CustomData.Builder setState(java.lang.CharSequence value) { - validate(fields()[1], value); - this.state = value; - fieldSetFlags()[1] = true; - return this; - } - - /** - * Checks whether the 'state' field has been set. - * @return True if the 'state' field has been set, false otherwise. - */ - public boolean hasState() { - return fieldSetFlags()[1]; - } - - - /** - * Clears the value of the 'state' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.iotdevice.CustomData.Builder clearState() { - state = null; - fieldSetFlags()[1] = false; - return this; - } - - @Override - @SuppressWarnings("unchecked") - public CustomData build() { - try { - CustomData record = new CustomData(); - record.info = fieldSetFlags()[0] ? this.info : (java.lang.CharSequence) defaultValue(fields()[0]); - record.state = fieldSetFlags()[1] ? this.state : (java.lang.CharSequence) defaultValue(fields()[1]); - return record; - } catch (org.apache.avro.AvroMissingFieldException e) { - throw e; - } catch (java.lang.Exception e) { - throw new org.apache.avro.AvroRuntimeException(e); - } - } - } - - @SuppressWarnings("unchecked") - private static final org.apache.avro.io.DatumWriter - WRITER$ = (org.apache.avro.io.DatumWriter)MODEL$.createDatumWriter(SCHEMA$); - - @Override public void writeExternal(java.io.ObjectOutput out) - throws java.io.IOException { - WRITER$.write(this, SpecificData.getEncoder(out)); - } - - @SuppressWarnings("unchecked") - private static final org.apache.avro.io.DatumReader - READER$ = (org.apache.avro.io.DatumReader)MODEL$.createDatumReader(SCHEMA$); - - @Override public void readExternal(java.io.ObjectInput in) - throws java.io.IOException { - READER$.read(this, SpecificData.getDecoder(in)); - } - - @Override protected boolean hasCustomCoders() { return true; } - - @Override public void customEncode(org.apache.avro.io.Encoder out) - throws java.io.IOException - { - out.writeString(this.info); - - out.writeString(this.state); - - } - - @Override public void customDecode(org.apache.avro.io.ResolvingDecoder in) - throws java.io.IOException - { - org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff(); - if (fieldOrder == null) { - this.info = in.readString(this.info instanceof Utf8 ? (Utf8)this.info : null); - - this.state = in.readString(this.state instanceof Utf8 ? (Utf8)this.state : null); - - } else { - for (int i = 0; i < 2; i++) { - switch (fieldOrder[i].pos()) { - case 0: - this.info = in.readString(this.info instanceof Utf8 ? (Utf8)this.info : null); - break; - - case 1: - this.state = in.readString(this.state instanceof Utf8 ? (Utf8)this.state : null); - break; - - default: - throw new java.io.IOException("Corrupt ResolvingDecoder."); - } - } - } - } -} - - - - - - - - - - diff --git a/src/main/java/io/skodjob/datagenerator/models/iotdevice/EnergyCurrent.java b/src/main/java/io/skodjob/datagenerator/models/iotdevice/EnergyCurrent.java deleted file mode 100644 index a0839ce..0000000 --- a/src/main/java/io/skodjob/datagenerator/models/iotdevice/EnergyCurrent.java +++ /dev/null @@ -1,398 +0,0 @@ -/** - * Autogenerated by Avro - * - * DO NOT EDIT DIRECTLY - */ -package io.skodjob.datagenerator.models.iotdevice; - -import org.apache.avro.generic.GenericArray; -import org.apache.avro.specific.SpecificData; -import org.apache.avro.util.Utf8; -import org.apache.avro.message.BinaryMessageEncoder; -import org.apache.avro.message.BinaryMessageDecoder; -import org.apache.avro.message.SchemaStore; - -@org.apache.avro.specific.AvroGenerated -public class EnergyCurrent extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord { - private static final long serialVersionUID = 3815547361048666636L; - - - public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"EnergyCurrent\",\"namespace\":\"io.skodjob.datagenerator.models.iotdevice\",\"fields\":[{\"name\":\"state\",\"type\":\"float\"},{\"name\":\"unit\",\"type\":\"string\"}]}"); - public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } - - private static final SpecificData MODEL$ = new SpecificData(); - - private static final BinaryMessageEncoder ENCODER = - new BinaryMessageEncoder<>(MODEL$, SCHEMA$); - - private static final BinaryMessageDecoder DECODER = - new BinaryMessageDecoder<>(MODEL$, SCHEMA$); - - /** - * Return the BinaryMessageEncoder instance used by this class. - * @return the message encoder used by this class - */ - public static BinaryMessageEncoder getEncoder() { - return ENCODER; - } - - /** - * Return the BinaryMessageDecoder instance used by this class. - * @return the message decoder used by this class - */ - public static BinaryMessageDecoder getDecoder() { - return DECODER; - } - - /** - * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}. - * @param resolver a {@link SchemaStore} used to find schemas by fingerprint - * @return a BinaryMessageDecoder instance for this class backed by the given SchemaStore - */ - public static BinaryMessageDecoder createDecoder(SchemaStore resolver) { - return new BinaryMessageDecoder<>(MODEL$, SCHEMA$, resolver); - } - - /** - * Serializes this EnergyCurrent to a ByteBuffer. - * @return a buffer holding the serialized data for this instance - * @throws java.io.IOException if this instance could not be serialized - */ - public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException { - return ENCODER.encode(this); - } - - /** - * Deserializes a EnergyCurrent from a ByteBuffer. - * @param b a byte buffer holding serialized data for an instance of this class - * @return a EnergyCurrent instance decoded from the given buffer - * @throws java.io.IOException if the given bytes could not be deserialized into an instance of this class - */ - public static EnergyCurrent fromByteBuffer( - java.nio.ByteBuffer b) throws java.io.IOException { - return DECODER.decode(b); - } - - private float state; - private java.lang.CharSequence unit; - - /** - * Default constructor. Note that this does not initialize fields - * to their default values from the schema. If that is desired then - * one should use newBuilder(). - */ - public EnergyCurrent() {} - - /** - * All-args constructor. - * @param state The new value for state - * @param unit The new value for unit - */ - public EnergyCurrent(java.lang.Float state, java.lang.CharSequence unit) { - this.state = state; - this.unit = unit; - } - - @Override - public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; } - - @Override - public org.apache.avro.Schema getSchema() { return SCHEMA$; } - - // Used by DatumWriter. Applications should not call. - @Override - public java.lang.Object get(int field$) { - switch (field$) { - case 0: return state; - case 1: return unit; - default: throw new IndexOutOfBoundsException("Invalid index: " + field$); - } - } - - // Used by DatumReader. Applications should not call. - @Override - @SuppressWarnings(value="unchecked") - public void put(int field$, java.lang.Object value$) { - switch (field$) { - case 0: state = (java.lang.Float)value$; break; - case 1: unit = (java.lang.CharSequence)value$; break; - default: throw new IndexOutOfBoundsException("Invalid index: " + field$); - } - } - - /** - * Gets the value of the 'state' field. - * @return The value of the 'state' field. - */ - public float getState() { - return state; - } - - - /** - * Sets the value of the 'state' field. - * @param value the value to set. - */ - public void setState(float value) { - this.state = value; - } - - /** - * Gets the value of the 'unit' field. - * @return The value of the 'unit' field. - */ - public java.lang.CharSequence getUnit() { - return unit; - } - - - /** - * Sets the value of the 'unit' field. - * @param value the value to set. - */ - public void setUnit(java.lang.CharSequence value) { - this.unit = value; - } - - /** - * Creates a new EnergyCurrent RecordBuilder. - * @return A new EnergyCurrent RecordBuilder - */ - public static io.skodjob.datagenerator.models.iotdevice.EnergyCurrent.Builder newBuilder() { - return new io.skodjob.datagenerator.models.iotdevice.EnergyCurrent.Builder(); - } - - /** - * Creates a new EnergyCurrent RecordBuilder by copying an existing Builder. - * @param other The existing builder to copy. - * @return A new EnergyCurrent RecordBuilder - */ - public static io.skodjob.datagenerator.models.iotdevice.EnergyCurrent.Builder newBuilder(io.skodjob.datagenerator.models.iotdevice.EnergyCurrent.Builder other) { - if (other == null) { - return new io.skodjob.datagenerator.models.iotdevice.EnergyCurrent.Builder(); - } else { - return new io.skodjob.datagenerator.models.iotdevice.EnergyCurrent.Builder(other); - } - } - - /** - * Creates a new EnergyCurrent RecordBuilder by copying an existing EnergyCurrent instance. - * @param other The existing instance to copy. - * @return A new EnergyCurrent RecordBuilder - */ - public static io.skodjob.datagenerator.models.iotdevice.EnergyCurrent.Builder newBuilder(io.skodjob.datagenerator.models.iotdevice.EnergyCurrent other) { - if (other == null) { - return new io.skodjob.datagenerator.models.iotdevice.EnergyCurrent.Builder(); - } else { - return new io.skodjob.datagenerator.models.iotdevice.EnergyCurrent.Builder(other); - } - } - - /** - * RecordBuilder for EnergyCurrent instances. - */ - @org.apache.avro.specific.AvroGenerated - public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase - implements org.apache.avro.data.RecordBuilder { - - private float state; - private java.lang.CharSequence unit; - - /** Creates a new Builder */ - private Builder() { - super(SCHEMA$, MODEL$); - } - - /** - * Creates a Builder by copying an existing Builder. - * @param other The existing Builder to copy. - */ - private Builder(io.skodjob.datagenerator.models.iotdevice.EnergyCurrent.Builder other) { - super(other); - if (isValidValue(fields()[0], other.state)) { - this.state = data().deepCopy(fields()[0].schema(), other.state); - fieldSetFlags()[0] = other.fieldSetFlags()[0]; - } - if (isValidValue(fields()[1], other.unit)) { - this.unit = data().deepCopy(fields()[1].schema(), other.unit); - fieldSetFlags()[1] = other.fieldSetFlags()[1]; - } - } - - /** - * Creates a Builder by copying an existing EnergyCurrent instance - * @param other The existing instance to copy. - */ - private Builder(io.skodjob.datagenerator.models.iotdevice.EnergyCurrent other) { - super(SCHEMA$, MODEL$); - if (isValidValue(fields()[0], other.state)) { - this.state = data().deepCopy(fields()[0].schema(), other.state); - fieldSetFlags()[0] = true; - } - if (isValidValue(fields()[1], other.unit)) { - this.unit = data().deepCopy(fields()[1].schema(), other.unit); - fieldSetFlags()[1] = true; - } - } - - /** - * Gets the value of the 'state' field. - * @return The value. - */ - public float getState() { - return state; - } - - - /** - * Sets the value of the 'state' field. - * @param value The value of 'state'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.iotdevice.EnergyCurrent.Builder setState(float value) { - validate(fields()[0], value); - this.state = value; - fieldSetFlags()[0] = true; - return this; - } - - /** - * Checks whether the 'state' field has been set. - * @return True if the 'state' field has been set, false otherwise. - */ - public boolean hasState() { - return fieldSetFlags()[0]; - } - - - /** - * Clears the value of the 'state' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.iotdevice.EnergyCurrent.Builder clearState() { - fieldSetFlags()[0] = false; - return this; - } - - /** - * Gets the value of the 'unit' field. - * @return The value. - */ - public java.lang.CharSequence getUnit() { - return unit; - } - - - /** - * Sets the value of the 'unit' field. - * @param value The value of 'unit'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.iotdevice.EnergyCurrent.Builder setUnit(java.lang.CharSequence value) { - validate(fields()[1], value); - this.unit = value; - fieldSetFlags()[1] = true; - return this; - } - - /** - * Checks whether the 'unit' field has been set. - * @return True if the 'unit' field has been set, false otherwise. - */ - public boolean hasUnit() { - return fieldSetFlags()[1]; - } - - - /** - * Clears the value of the 'unit' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.iotdevice.EnergyCurrent.Builder clearUnit() { - unit = null; - fieldSetFlags()[1] = false; - return this; - } - - @Override - @SuppressWarnings("unchecked") - public EnergyCurrent build() { - try { - EnergyCurrent record = new EnergyCurrent(); - record.state = fieldSetFlags()[0] ? this.state : (java.lang.Float) defaultValue(fields()[0]); - record.unit = fieldSetFlags()[1] ? this.unit : (java.lang.CharSequence) defaultValue(fields()[1]); - return record; - } catch (org.apache.avro.AvroMissingFieldException e) { - throw e; - } catch (java.lang.Exception e) { - throw new org.apache.avro.AvroRuntimeException(e); - } - } - } - - @SuppressWarnings("unchecked") - private static final org.apache.avro.io.DatumWriter - WRITER$ = (org.apache.avro.io.DatumWriter)MODEL$.createDatumWriter(SCHEMA$); - - @Override public void writeExternal(java.io.ObjectOutput out) - throws java.io.IOException { - WRITER$.write(this, SpecificData.getEncoder(out)); - } - - @SuppressWarnings("unchecked") - private static final org.apache.avro.io.DatumReader - READER$ = (org.apache.avro.io.DatumReader)MODEL$.createDatumReader(SCHEMA$); - - @Override public void readExternal(java.io.ObjectInput in) - throws java.io.IOException { - READER$.read(this, SpecificData.getDecoder(in)); - } - - @Override protected boolean hasCustomCoders() { return true; } - - @Override public void customEncode(org.apache.avro.io.Encoder out) - throws java.io.IOException - { - out.writeFloat(this.state); - - out.writeString(this.unit); - - } - - @Override public void customDecode(org.apache.avro.io.ResolvingDecoder in) - throws java.io.IOException - { - org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff(); - if (fieldOrder == null) { - this.state = in.readFloat(); - - this.unit = in.readString(this.unit instanceof Utf8 ? (Utf8)this.unit : null); - - } else { - for (int i = 0; i < 2; i++) { - switch (fieldOrder[i].pos()) { - case 0: - this.state = in.readFloat(); - break; - - case 1: - this.unit = in.readString(this.unit instanceof Utf8 ? (Utf8)this.unit : null); - break; - - default: - throw new java.io.IOException("Corrupt ResolvingDecoder."); - } - } - } - } -} - - - - - - - - - - diff --git a/src/main/java/io/skodjob/datagenerator/models/iotdevice/EnergyToday.java b/src/main/java/io/skodjob/datagenerator/models/iotdevice/EnergyToday.java deleted file mode 100644 index f4d1955..0000000 --- a/src/main/java/io/skodjob/datagenerator/models/iotdevice/EnergyToday.java +++ /dev/null @@ -1,398 +0,0 @@ -/** - * Autogenerated by Avro - * - * DO NOT EDIT DIRECTLY - */ -package io.skodjob.datagenerator.models.iotdevice; - -import org.apache.avro.generic.GenericArray; -import org.apache.avro.specific.SpecificData; -import org.apache.avro.util.Utf8; -import org.apache.avro.message.BinaryMessageEncoder; -import org.apache.avro.message.BinaryMessageDecoder; -import org.apache.avro.message.SchemaStore; - -@org.apache.avro.specific.AvroGenerated -public class EnergyToday extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord { - private static final long serialVersionUID = -3017110563830999034L; - - - public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"EnergyToday\",\"namespace\":\"io.skodjob.datagenerator.models.iotdevice\",\"fields\":[{\"name\":\"state\",\"type\":\"float\"},{\"name\":\"unit\",\"type\":\"string\"}]}"); - public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } - - private static final SpecificData MODEL$ = new SpecificData(); - - private static final BinaryMessageEncoder ENCODER = - new BinaryMessageEncoder<>(MODEL$, SCHEMA$); - - private static final BinaryMessageDecoder DECODER = - new BinaryMessageDecoder<>(MODEL$, SCHEMA$); - - /** - * Return the BinaryMessageEncoder instance used by this class. - * @return the message encoder used by this class - */ - public static BinaryMessageEncoder getEncoder() { - return ENCODER; - } - - /** - * Return the BinaryMessageDecoder instance used by this class. - * @return the message decoder used by this class - */ - public static BinaryMessageDecoder getDecoder() { - return DECODER; - } - - /** - * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}. - * @param resolver a {@link SchemaStore} used to find schemas by fingerprint - * @return a BinaryMessageDecoder instance for this class backed by the given SchemaStore - */ - public static BinaryMessageDecoder createDecoder(SchemaStore resolver) { - return new BinaryMessageDecoder<>(MODEL$, SCHEMA$, resolver); - } - - /** - * Serializes this EnergyToday to a ByteBuffer. - * @return a buffer holding the serialized data for this instance - * @throws java.io.IOException if this instance could not be serialized - */ - public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException { - return ENCODER.encode(this); - } - - /** - * Deserializes a EnergyToday from a ByteBuffer. - * @param b a byte buffer holding serialized data for an instance of this class - * @return a EnergyToday instance decoded from the given buffer - * @throws java.io.IOException if the given bytes could not be deserialized into an instance of this class - */ - public static EnergyToday fromByteBuffer( - java.nio.ByteBuffer b) throws java.io.IOException { - return DECODER.decode(b); - } - - private float state; - private java.lang.CharSequence unit; - - /** - * Default constructor. Note that this does not initialize fields - * to their default values from the schema. If that is desired then - * one should use newBuilder(). - */ - public EnergyToday() {} - - /** - * All-args constructor. - * @param state The new value for state - * @param unit The new value for unit - */ - public EnergyToday(java.lang.Float state, java.lang.CharSequence unit) { - this.state = state; - this.unit = unit; - } - - @Override - public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; } - - @Override - public org.apache.avro.Schema getSchema() { return SCHEMA$; } - - // Used by DatumWriter. Applications should not call. - @Override - public java.lang.Object get(int field$) { - switch (field$) { - case 0: return state; - case 1: return unit; - default: throw new IndexOutOfBoundsException("Invalid index: " + field$); - } - } - - // Used by DatumReader. Applications should not call. - @Override - @SuppressWarnings(value="unchecked") - public void put(int field$, java.lang.Object value$) { - switch (field$) { - case 0: state = (java.lang.Float)value$; break; - case 1: unit = (java.lang.CharSequence)value$; break; - default: throw new IndexOutOfBoundsException("Invalid index: " + field$); - } - } - - /** - * Gets the value of the 'state' field. - * @return The value of the 'state' field. - */ - public float getState() { - return state; - } - - - /** - * Sets the value of the 'state' field. - * @param value the value to set. - */ - public void setState(float value) { - this.state = value; - } - - /** - * Gets the value of the 'unit' field. - * @return The value of the 'unit' field. - */ - public java.lang.CharSequence getUnit() { - return unit; - } - - - /** - * Sets the value of the 'unit' field. - * @param value the value to set. - */ - public void setUnit(java.lang.CharSequence value) { - this.unit = value; - } - - /** - * Creates a new EnergyToday RecordBuilder. - * @return A new EnergyToday RecordBuilder - */ - public static io.skodjob.datagenerator.models.iotdevice.EnergyToday.Builder newBuilder() { - return new io.skodjob.datagenerator.models.iotdevice.EnergyToday.Builder(); - } - - /** - * Creates a new EnergyToday RecordBuilder by copying an existing Builder. - * @param other The existing builder to copy. - * @return A new EnergyToday RecordBuilder - */ - public static io.skodjob.datagenerator.models.iotdevice.EnergyToday.Builder newBuilder(io.skodjob.datagenerator.models.iotdevice.EnergyToday.Builder other) { - if (other == null) { - return new io.skodjob.datagenerator.models.iotdevice.EnergyToday.Builder(); - } else { - return new io.skodjob.datagenerator.models.iotdevice.EnergyToday.Builder(other); - } - } - - /** - * Creates a new EnergyToday RecordBuilder by copying an existing EnergyToday instance. - * @param other The existing instance to copy. - * @return A new EnergyToday RecordBuilder - */ - public static io.skodjob.datagenerator.models.iotdevice.EnergyToday.Builder newBuilder(io.skodjob.datagenerator.models.iotdevice.EnergyToday other) { - if (other == null) { - return new io.skodjob.datagenerator.models.iotdevice.EnergyToday.Builder(); - } else { - return new io.skodjob.datagenerator.models.iotdevice.EnergyToday.Builder(other); - } - } - - /** - * RecordBuilder for EnergyToday instances. - */ - @org.apache.avro.specific.AvroGenerated - public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase - implements org.apache.avro.data.RecordBuilder { - - private float state; - private java.lang.CharSequence unit; - - /** Creates a new Builder */ - private Builder() { - super(SCHEMA$, MODEL$); - } - - /** - * Creates a Builder by copying an existing Builder. - * @param other The existing Builder to copy. - */ - private Builder(io.skodjob.datagenerator.models.iotdevice.EnergyToday.Builder other) { - super(other); - if (isValidValue(fields()[0], other.state)) { - this.state = data().deepCopy(fields()[0].schema(), other.state); - fieldSetFlags()[0] = other.fieldSetFlags()[0]; - } - if (isValidValue(fields()[1], other.unit)) { - this.unit = data().deepCopy(fields()[1].schema(), other.unit); - fieldSetFlags()[1] = other.fieldSetFlags()[1]; - } - } - - /** - * Creates a Builder by copying an existing EnergyToday instance - * @param other The existing instance to copy. - */ - private Builder(io.skodjob.datagenerator.models.iotdevice.EnergyToday other) { - super(SCHEMA$, MODEL$); - if (isValidValue(fields()[0], other.state)) { - this.state = data().deepCopy(fields()[0].schema(), other.state); - fieldSetFlags()[0] = true; - } - if (isValidValue(fields()[1], other.unit)) { - this.unit = data().deepCopy(fields()[1].schema(), other.unit); - fieldSetFlags()[1] = true; - } - } - - /** - * Gets the value of the 'state' field. - * @return The value. - */ - public float getState() { - return state; - } - - - /** - * Sets the value of the 'state' field. - * @param value The value of 'state'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.iotdevice.EnergyToday.Builder setState(float value) { - validate(fields()[0], value); - this.state = value; - fieldSetFlags()[0] = true; - return this; - } - - /** - * Checks whether the 'state' field has been set. - * @return True if the 'state' field has been set, false otherwise. - */ - public boolean hasState() { - return fieldSetFlags()[0]; - } - - - /** - * Clears the value of the 'state' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.iotdevice.EnergyToday.Builder clearState() { - fieldSetFlags()[0] = false; - return this; - } - - /** - * Gets the value of the 'unit' field. - * @return The value. - */ - public java.lang.CharSequence getUnit() { - return unit; - } - - - /** - * Sets the value of the 'unit' field. - * @param value The value of 'unit'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.iotdevice.EnergyToday.Builder setUnit(java.lang.CharSequence value) { - validate(fields()[1], value); - this.unit = value; - fieldSetFlags()[1] = true; - return this; - } - - /** - * Checks whether the 'unit' field has been set. - * @return True if the 'unit' field has been set, false otherwise. - */ - public boolean hasUnit() { - return fieldSetFlags()[1]; - } - - - /** - * Clears the value of the 'unit' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.iotdevice.EnergyToday.Builder clearUnit() { - unit = null; - fieldSetFlags()[1] = false; - return this; - } - - @Override - @SuppressWarnings("unchecked") - public EnergyToday build() { - try { - EnergyToday record = new EnergyToday(); - record.state = fieldSetFlags()[0] ? this.state : (java.lang.Float) defaultValue(fields()[0]); - record.unit = fieldSetFlags()[1] ? this.unit : (java.lang.CharSequence) defaultValue(fields()[1]); - return record; - } catch (org.apache.avro.AvroMissingFieldException e) { - throw e; - } catch (java.lang.Exception e) { - throw new org.apache.avro.AvroRuntimeException(e); - } - } - } - - @SuppressWarnings("unchecked") - private static final org.apache.avro.io.DatumWriter - WRITER$ = (org.apache.avro.io.DatumWriter)MODEL$.createDatumWriter(SCHEMA$); - - @Override public void writeExternal(java.io.ObjectOutput out) - throws java.io.IOException { - WRITER$.write(this, SpecificData.getEncoder(out)); - } - - @SuppressWarnings("unchecked") - private static final org.apache.avro.io.DatumReader - READER$ = (org.apache.avro.io.DatumReader)MODEL$.createDatumReader(SCHEMA$); - - @Override public void readExternal(java.io.ObjectInput in) - throws java.io.IOException { - READER$.read(this, SpecificData.getDecoder(in)); - } - - @Override protected boolean hasCustomCoders() { return true; } - - @Override public void customEncode(org.apache.avro.io.Encoder out) - throws java.io.IOException - { - out.writeFloat(this.state); - - out.writeString(this.unit); - - } - - @Override public void customDecode(org.apache.avro.io.ResolvingDecoder in) - throws java.io.IOException - { - org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff(); - if (fieldOrder == null) { - this.state = in.readFloat(); - - this.unit = in.readString(this.unit instanceof Utf8 ? (Utf8)this.unit : null); - - } else { - for (int i = 0; i < 2; i++) { - switch (fieldOrder[i].pos()) { - case 0: - this.state = in.readFloat(); - break; - - case 1: - this.unit = in.readString(this.unit instanceof Utf8 ? (Utf8)this.unit : null); - break; - - default: - throw new java.io.IOException("Corrupt ResolvingDecoder."); - } - } - } - } -} - - - - - - - - - - diff --git a/src/main/java/io/skodjob/datagenerator/models/iotdevice/GateData.java b/src/main/java/io/skodjob/datagenerator/models/iotdevice/GateData.java deleted file mode 100644 index a946eae..0000000 --- a/src/main/java/io/skodjob/datagenerator/models/iotdevice/GateData.java +++ /dev/null @@ -1,399 +0,0 @@ -/** - * Autogenerated by Avro - * - * DO NOT EDIT DIRECTLY - */ -package io.skodjob.datagenerator.models.iotdevice; - -import org.apache.avro.generic.GenericArray; -import org.apache.avro.specific.SpecificData; -import org.apache.avro.util.Utf8; -import org.apache.avro.message.BinaryMessageEncoder; -import org.apache.avro.message.BinaryMessageDecoder; -import org.apache.avro.message.SchemaStore; - -@org.apache.avro.specific.AvroGenerated -public class GateData extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord { - private static final long serialVersionUID = -8051302576023405526L; - - - public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"GateData\",\"namespace\":\"io.skodjob.datagenerator.models.iotdevice\",\"fields\":[{\"name\":\"vendor\",\"type\":\"string\"},{\"name\":\"state\",\"type\":\"string\"}]}"); - public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } - - private static final SpecificData MODEL$ = new SpecificData(); - - private static final BinaryMessageEncoder ENCODER = - new BinaryMessageEncoder<>(MODEL$, SCHEMA$); - - private static final BinaryMessageDecoder DECODER = - new BinaryMessageDecoder<>(MODEL$, SCHEMA$); - - /** - * Return the BinaryMessageEncoder instance used by this class. - * @return the message encoder used by this class - */ - public static BinaryMessageEncoder getEncoder() { - return ENCODER; - } - - /** - * Return the BinaryMessageDecoder instance used by this class. - * @return the message decoder used by this class - */ - public static BinaryMessageDecoder getDecoder() { - return DECODER; - } - - /** - * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}. - * @param resolver a {@link SchemaStore} used to find schemas by fingerprint - * @return a BinaryMessageDecoder instance for this class backed by the given SchemaStore - */ - public static BinaryMessageDecoder createDecoder(SchemaStore resolver) { - return new BinaryMessageDecoder<>(MODEL$, SCHEMA$, resolver); - } - - /** - * Serializes this GateData to a ByteBuffer. - * @return a buffer holding the serialized data for this instance - * @throws java.io.IOException if this instance could not be serialized - */ - public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException { - return ENCODER.encode(this); - } - - /** - * Deserializes a GateData from a ByteBuffer. - * @param b a byte buffer holding serialized data for an instance of this class - * @return a GateData instance decoded from the given buffer - * @throws java.io.IOException if the given bytes could not be deserialized into an instance of this class - */ - public static GateData fromByteBuffer( - java.nio.ByteBuffer b) throws java.io.IOException { - return DECODER.decode(b); - } - - private java.lang.CharSequence vendor; - private java.lang.CharSequence state; - - /** - * Default constructor. Note that this does not initialize fields - * to their default values from the schema. If that is desired then - * one should use newBuilder(). - */ - public GateData() {} - - /** - * All-args constructor. - * @param vendor The new value for vendor - * @param state The new value for state - */ - public GateData(java.lang.CharSequence vendor, java.lang.CharSequence state) { - this.vendor = vendor; - this.state = state; - } - - @Override - public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; } - - @Override - public org.apache.avro.Schema getSchema() { return SCHEMA$; } - - // Used by DatumWriter. Applications should not call. - @Override - public java.lang.Object get(int field$) { - switch (field$) { - case 0: return vendor; - case 1: return state; - default: throw new IndexOutOfBoundsException("Invalid index: " + field$); - } - } - - // Used by DatumReader. Applications should not call. - @Override - @SuppressWarnings(value="unchecked") - public void put(int field$, java.lang.Object value$) { - switch (field$) { - case 0: vendor = (java.lang.CharSequence)value$; break; - case 1: state = (java.lang.CharSequence)value$; break; - default: throw new IndexOutOfBoundsException("Invalid index: " + field$); - } - } - - /** - * Gets the value of the 'vendor' field. - * @return The value of the 'vendor' field. - */ - public java.lang.CharSequence getVendor() { - return vendor; - } - - - /** - * Sets the value of the 'vendor' field. - * @param value the value to set. - */ - public void setVendor(java.lang.CharSequence value) { - this.vendor = value; - } - - /** - * Gets the value of the 'state' field. - * @return The value of the 'state' field. - */ - public java.lang.CharSequence getState() { - return state; - } - - - /** - * Sets the value of the 'state' field. - * @param value the value to set. - */ - public void setState(java.lang.CharSequence value) { - this.state = value; - } - - /** - * Creates a new GateData RecordBuilder. - * @return A new GateData RecordBuilder - */ - public static io.skodjob.datagenerator.models.iotdevice.GateData.Builder newBuilder() { - return new io.skodjob.datagenerator.models.iotdevice.GateData.Builder(); - } - - /** - * Creates a new GateData RecordBuilder by copying an existing Builder. - * @param other The existing builder to copy. - * @return A new GateData RecordBuilder - */ - public static io.skodjob.datagenerator.models.iotdevice.GateData.Builder newBuilder(io.skodjob.datagenerator.models.iotdevice.GateData.Builder other) { - if (other == null) { - return new io.skodjob.datagenerator.models.iotdevice.GateData.Builder(); - } else { - return new io.skodjob.datagenerator.models.iotdevice.GateData.Builder(other); - } - } - - /** - * Creates a new GateData RecordBuilder by copying an existing GateData instance. - * @param other The existing instance to copy. - * @return A new GateData RecordBuilder - */ - public static io.skodjob.datagenerator.models.iotdevice.GateData.Builder newBuilder(io.skodjob.datagenerator.models.iotdevice.GateData other) { - if (other == null) { - return new io.skodjob.datagenerator.models.iotdevice.GateData.Builder(); - } else { - return new io.skodjob.datagenerator.models.iotdevice.GateData.Builder(other); - } - } - - /** - * RecordBuilder for GateData instances. - */ - @org.apache.avro.specific.AvroGenerated - public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase - implements org.apache.avro.data.RecordBuilder { - - private java.lang.CharSequence vendor; - private java.lang.CharSequence state; - - /** Creates a new Builder */ - private Builder() { - super(SCHEMA$, MODEL$); - } - - /** - * Creates a Builder by copying an existing Builder. - * @param other The existing Builder to copy. - */ - private Builder(io.skodjob.datagenerator.models.iotdevice.GateData.Builder other) { - super(other); - if (isValidValue(fields()[0], other.vendor)) { - this.vendor = data().deepCopy(fields()[0].schema(), other.vendor); - fieldSetFlags()[0] = other.fieldSetFlags()[0]; - } - if (isValidValue(fields()[1], other.state)) { - this.state = data().deepCopy(fields()[1].schema(), other.state); - fieldSetFlags()[1] = other.fieldSetFlags()[1]; - } - } - - /** - * Creates a Builder by copying an existing GateData instance - * @param other The existing instance to copy. - */ - private Builder(io.skodjob.datagenerator.models.iotdevice.GateData other) { - super(SCHEMA$, MODEL$); - if (isValidValue(fields()[0], other.vendor)) { - this.vendor = data().deepCopy(fields()[0].schema(), other.vendor); - fieldSetFlags()[0] = true; - } - if (isValidValue(fields()[1], other.state)) { - this.state = data().deepCopy(fields()[1].schema(), other.state); - fieldSetFlags()[1] = true; - } - } - - /** - * Gets the value of the 'vendor' field. - * @return The value. - */ - public java.lang.CharSequence getVendor() { - return vendor; - } - - - /** - * Sets the value of the 'vendor' field. - * @param value The value of 'vendor'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.iotdevice.GateData.Builder setVendor(java.lang.CharSequence value) { - validate(fields()[0], value); - this.vendor = value; - fieldSetFlags()[0] = true; - return this; - } - - /** - * Checks whether the 'vendor' field has been set. - * @return True if the 'vendor' field has been set, false otherwise. - */ - public boolean hasVendor() { - return fieldSetFlags()[0]; - } - - - /** - * Clears the value of the 'vendor' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.iotdevice.GateData.Builder clearVendor() { - vendor = null; - fieldSetFlags()[0] = false; - return this; - } - - /** - * Gets the value of the 'state' field. - * @return The value. - */ - public java.lang.CharSequence getState() { - return state; - } - - - /** - * Sets the value of the 'state' field. - * @param value The value of 'state'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.iotdevice.GateData.Builder setState(java.lang.CharSequence value) { - validate(fields()[1], value); - this.state = value; - fieldSetFlags()[1] = true; - return this; - } - - /** - * Checks whether the 'state' field has been set. - * @return True if the 'state' field has been set, false otherwise. - */ - public boolean hasState() { - return fieldSetFlags()[1]; - } - - - /** - * Clears the value of the 'state' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.iotdevice.GateData.Builder clearState() { - state = null; - fieldSetFlags()[1] = false; - return this; - } - - @Override - @SuppressWarnings("unchecked") - public GateData build() { - try { - GateData record = new GateData(); - record.vendor = fieldSetFlags()[0] ? this.vendor : (java.lang.CharSequence) defaultValue(fields()[0]); - record.state = fieldSetFlags()[1] ? this.state : (java.lang.CharSequence) defaultValue(fields()[1]); - return record; - } catch (org.apache.avro.AvroMissingFieldException e) { - throw e; - } catch (java.lang.Exception e) { - throw new org.apache.avro.AvroRuntimeException(e); - } - } - } - - @SuppressWarnings("unchecked") - private static final org.apache.avro.io.DatumWriter - WRITER$ = (org.apache.avro.io.DatumWriter)MODEL$.createDatumWriter(SCHEMA$); - - @Override public void writeExternal(java.io.ObjectOutput out) - throws java.io.IOException { - WRITER$.write(this, SpecificData.getEncoder(out)); - } - - @SuppressWarnings("unchecked") - private static final org.apache.avro.io.DatumReader - READER$ = (org.apache.avro.io.DatumReader)MODEL$.createDatumReader(SCHEMA$); - - @Override public void readExternal(java.io.ObjectInput in) - throws java.io.IOException { - READER$.read(this, SpecificData.getDecoder(in)); - } - - @Override protected boolean hasCustomCoders() { return true; } - - @Override public void customEncode(org.apache.avro.io.Encoder out) - throws java.io.IOException - { - out.writeString(this.vendor); - - out.writeString(this.state); - - } - - @Override public void customDecode(org.apache.avro.io.ResolvingDecoder in) - throws java.io.IOException - { - org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff(); - if (fieldOrder == null) { - this.vendor = in.readString(this.vendor instanceof Utf8 ? (Utf8)this.vendor : null); - - this.state = in.readString(this.state instanceof Utf8 ? (Utf8)this.state : null); - - } else { - for (int i = 0; i < 2; i++) { - switch (fieldOrder[i].pos()) { - case 0: - this.vendor = in.readString(this.vendor instanceof Utf8 ? (Utf8)this.vendor : null); - break; - - case 1: - this.state = in.readString(this.state instanceof Utf8 ? (Utf8)this.state : null); - break; - - default: - throw new java.io.IOException("Corrupt ResolvingDecoder."); - } - } - } - } -} - - - - - - - - - - diff --git a/src/main/java/io/skodjob/datagenerator/models/iotdevice/IotDevice.java b/src/main/java/io/skodjob/datagenerator/models/iotdevice/IotDevice.java deleted file mode 100644 index c4e5be2..0000000 --- a/src/main/java/io/skodjob/datagenerator/models/iotdevice/IotDevice.java +++ /dev/null @@ -1,721 +0,0 @@ -/** - * Autogenerated by Avro - * - * DO NOT EDIT DIRECTLY - */ -package io.skodjob.datagenerator.models.iotdevice; - -import org.apache.avro.generic.GenericArray; -import org.apache.avro.specific.SpecificData; -import org.apache.avro.util.Utf8; -import org.apache.avro.message.BinaryMessageEncoder; -import org.apache.avro.message.BinaryMessageDecoder; -import org.apache.avro.message.SchemaStore; - -@org.apache.avro.specific.AvroGenerated -public class IotDevice extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord { - private static final long serialVersionUID = -6035530976238410191L; - - - public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"IotDevice\",\"namespace\":\"io.skodjob.datagenerator.models.iotdevice\",\"fields\":[{\"name\":\"IPV4\",\"type\":\"string\"},{\"name\":\"MAC\",\"type\":\"string\"},{\"name\":\"ID\",\"type\":\"string\"},{\"name\":\"TYPE\",\"type\":\"string\"},{\"name\":\"LAST_UPDATE\",\"type\":\"string\"},{\"name\":\"LINK_QUALITY\",\"type\":\"int\"},{\"name\":\"DATA\",\"type\":[{\"type\":\"record\",\"name\":\"CustomData\",\"fields\":[{\"name\":\"info\",\"type\":\"string\"},{\"name\":\"state\",\"type\":\"string\"}]},{\"type\":\"record\",\"name\":\"ButtonData\",\"fields\":[{\"name\":\"power\",\"type\":\"string\"},{\"name\":\"battery\",\"type\":{\"type\":\"record\",\"name\":\"Battery\",\"fields\":[{\"name\":\"value\",\"type\":\"int\"},{\"name\":\"unit\",\"type\":\"string\"}]}}]},{\"type\":\"record\",\"name\":\"PlugData\",\"fields\":[{\"name\":\"power\",\"type\":\"string\"},{\"name\":\"energy_current\",\"type\":{\"type\":\"record\",\"name\":\"EnergyCurrent\",\"fields\":[{\"name\":\"state\",\"type\":\"float\"},{\"name\":\"unit\",\"type\":\"string\"}]}},{\"name\":\"energy_today\",\"type\":{\"type\":\"record\",\"name\":\"EnergyToday\",\"fields\":[{\"name\":\"state\",\"type\":\"float\"},{\"name\":\"unit\",\"type\":\"string\"}]}}]},{\"type\":\"record\",\"name\":\"ThermometerData\",\"fields\":[{\"name\":\"temperature\",\"type\":\"float\"},{\"name\":\"humidity\",\"type\":\"float\"},{\"name\":\"battery\",\"type\":\"Battery\"}]},{\"type\":\"record\",\"name\":\"GateData\",\"fields\":[{\"name\":\"vendor\",\"type\":\"string\"},{\"name\":\"state\",\"type\":\"string\"}]},{\"type\":\"record\",\"name\":\"LightData\",\"fields\":[{\"name\":\"power\",\"type\":\"string\"},{\"name\":\"brightness\",\"type\":\"int\"},{\"name\":\"power_on_behavior\",\"type\":\"string\"}]}]}]}"); - public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } - - private static final SpecificData MODEL$ = new SpecificData(); - - private static final BinaryMessageEncoder ENCODER = - new BinaryMessageEncoder<>(MODEL$, SCHEMA$); - - private static final BinaryMessageDecoder DECODER = - new BinaryMessageDecoder<>(MODEL$, SCHEMA$); - - /** - * Return the BinaryMessageEncoder instance used by this class. - * @return the message encoder used by this class - */ - public static BinaryMessageEncoder getEncoder() { - return ENCODER; - } - - /** - * Return the BinaryMessageDecoder instance used by this class. - * @return the message decoder used by this class - */ - public static BinaryMessageDecoder getDecoder() { - return DECODER; - } - - /** - * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}. - * @param resolver a {@link SchemaStore} used to find schemas by fingerprint - * @return a BinaryMessageDecoder instance for this class backed by the given SchemaStore - */ - public static BinaryMessageDecoder createDecoder(SchemaStore resolver) { - return new BinaryMessageDecoder<>(MODEL$, SCHEMA$, resolver); - } - - /** - * Serializes this IotDevice to a ByteBuffer. - * @return a buffer holding the serialized data for this instance - * @throws java.io.IOException if this instance could not be serialized - */ - public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException { - return ENCODER.encode(this); - } - - /** - * Deserializes a IotDevice from a ByteBuffer. - * @param b a byte buffer holding serialized data for an instance of this class - * @return a IotDevice instance decoded from the given buffer - * @throws java.io.IOException if the given bytes could not be deserialized into an instance of this class - */ - public static IotDevice fromByteBuffer( - java.nio.ByteBuffer b) throws java.io.IOException { - return DECODER.decode(b); - } - - private java.lang.CharSequence IPV4; - private java.lang.CharSequence MAC; - private java.lang.CharSequence ID; - private java.lang.CharSequence TYPE; - private java.lang.CharSequence LAST_UPDATE; - private int LINK_QUALITY; - private java.lang.Object DATA; - - /** - * Default constructor. Note that this does not initialize fields - * to their default values from the schema. If that is desired then - * one should use newBuilder(). - */ - public IotDevice() {} - - /** - * All-args constructor. - * @param IPV4 The new value for IPV4 - * @param MAC The new value for MAC - * @param ID The new value for ID - * @param TYPE The new value for TYPE - * @param LAST_UPDATE The new value for LAST_UPDATE - * @param LINK_QUALITY The new value for LINK_QUALITY - * @param DATA The new value for DATA - */ - public IotDevice(java.lang.CharSequence IPV4, java.lang.CharSequence MAC, java.lang.CharSequence ID, java.lang.CharSequence TYPE, java.lang.CharSequence LAST_UPDATE, java.lang.Integer LINK_QUALITY, java.lang.Object DATA) { - this.IPV4 = IPV4; - this.MAC = MAC; - this.ID = ID; - this.TYPE = TYPE; - this.LAST_UPDATE = LAST_UPDATE; - this.LINK_QUALITY = LINK_QUALITY; - this.DATA = DATA; - } - - @Override - public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; } - - @Override - public org.apache.avro.Schema getSchema() { return SCHEMA$; } - - // Used by DatumWriter. Applications should not call. - @Override - public java.lang.Object get(int field$) { - switch (field$) { - case 0: return IPV4; - case 1: return MAC; - case 2: return ID; - case 3: return TYPE; - case 4: return LAST_UPDATE; - case 5: return LINK_QUALITY; - case 6: return DATA; - default: throw new IndexOutOfBoundsException("Invalid index: " + field$); - } - } - - // Used by DatumReader. Applications should not call. - @Override - @SuppressWarnings(value="unchecked") - public void put(int field$, java.lang.Object value$) { - switch (field$) { - case 0: IPV4 = (java.lang.CharSequence)value$; break; - case 1: MAC = (java.lang.CharSequence)value$; break; - case 2: ID = (java.lang.CharSequence)value$; break; - case 3: TYPE = (java.lang.CharSequence)value$; break; - case 4: LAST_UPDATE = (java.lang.CharSequence)value$; break; - case 5: LINK_QUALITY = (java.lang.Integer)value$; break; - case 6: DATA = value$; break; - default: throw new IndexOutOfBoundsException("Invalid index: " + field$); - } - } - - /** - * Gets the value of the 'IPV4' field. - * @return The value of the 'IPV4' field. - */ - public java.lang.CharSequence getIPV4() { - return IPV4; - } - - - /** - * Sets the value of the 'IPV4' field. - * @param value the value to set. - */ - public void setIPV4(java.lang.CharSequence value) { - this.IPV4 = value; - } - - /** - * Gets the value of the 'MAC' field. - * @return The value of the 'MAC' field. - */ - public java.lang.CharSequence getMAC() { - return MAC; - } - - - /** - * Sets the value of the 'MAC' field. - * @param value the value to set. - */ - public void setMAC(java.lang.CharSequence value) { - this.MAC = value; - } - - /** - * Gets the value of the 'ID' field. - * @return The value of the 'ID' field. - */ - public java.lang.CharSequence getID() { - return ID; - } - - - /** - * Sets the value of the 'ID' field. - * @param value the value to set. - */ - public void setID(java.lang.CharSequence value) { - this.ID = value; - } - - /** - * Gets the value of the 'TYPE' field. - * @return The value of the 'TYPE' field. - */ - public java.lang.CharSequence getTYPE() { - return TYPE; - } - - - /** - * Sets the value of the 'TYPE' field. - * @param value the value to set. - */ - public void setTYPE(java.lang.CharSequence value) { - this.TYPE = value; - } - - /** - * Gets the value of the 'LAST_UPDATE' field. - * @return The value of the 'LAST_UPDATE' field. - */ - public java.lang.CharSequence getLASTUPDATE() { - return LAST_UPDATE; - } - - - /** - * Sets the value of the 'LAST_UPDATE' field. - * @param value the value to set. - */ - public void setLASTUPDATE(java.lang.CharSequence value) { - this.LAST_UPDATE = value; - } - - /** - * Gets the value of the 'LINK_QUALITY' field. - * @return The value of the 'LINK_QUALITY' field. - */ - public int getLINKQUALITY() { - return LINK_QUALITY; - } - - - /** - * Sets the value of the 'LINK_QUALITY' field. - * @param value the value to set. - */ - public void setLINKQUALITY(int value) { - this.LINK_QUALITY = value; - } - - /** - * Gets the value of the 'DATA' field. - * @return The value of the 'DATA' field. - */ - public java.lang.Object getDATA() { - return DATA; - } - - - /** - * Sets the value of the 'DATA' field. - * @param value the value to set. - */ - public void setDATA(java.lang.Object value) { - this.DATA = value; - } - - /** - * Creates a new IotDevice RecordBuilder. - * @return A new IotDevice RecordBuilder - */ - public static io.skodjob.datagenerator.models.iotdevice.IotDevice.Builder newBuilder() { - return new io.skodjob.datagenerator.models.iotdevice.IotDevice.Builder(); - } - - /** - * Creates a new IotDevice RecordBuilder by copying an existing Builder. - * @param other The existing builder to copy. - * @return A new IotDevice RecordBuilder - */ - public static io.skodjob.datagenerator.models.iotdevice.IotDevice.Builder newBuilder(io.skodjob.datagenerator.models.iotdevice.IotDevice.Builder other) { - if (other == null) { - return new io.skodjob.datagenerator.models.iotdevice.IotDevice.Builder(); - } else { - return new io.skodjob.datagenerator.models.iotdevice.IotDevice.Builder(other); - } - } - - /** - * Creates a new IotDevice RecordBuilder by copying an existing IotDevice instance. - * @param other The existing instance to copy. - * @return A new IotDevice RecordBuilder - */ - public static io.skodjob.datagenerator.models.iotdevice.IotDevice.Builder newBuilder(io.skodjob.datagenerator.models.iotdevice.IotDevice other) { - if (other == null) { - return new io.skodjob.datagenerator.models.iotdevice.IotDevice.Builder(); - } else { - return new io.skodjob.datagenerator.models.iotdevice.IotDevice.Builder(other); - } - } - - /** - * RecordBuilder for IotDevice instances. - */ - @org.apache.avro.specific.AvroGenerated - public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase - implements org.apache.avro.data.RecordBuilder { - - private java.lang.CharSequence IPV4; - private java.lang.CharSequence MAC; - private java.lang.CharSequence ID; - private java.lang.CharSequence TYPE; - private java.lang.CharSequence LAST_UPDATE; - private int LINK_QUALITY; - private java.lang.Object DATA; - - /** Creates a new Builder */ - private Builder() { - super(SCHEMA$, MODEL$); - } - - /** - * Creates a Builder by copying an existing Builder. - * @param other The existing Builder to copy. - */ - private Builder(io.skodjob.datagenerator.models.iotdevice.IotDevice.Builder other) { - super(other); - if (isValidValue(fields()[0], other.IPV4)) { - this.IPV4 = data().deepCopy(fields()[0].schema(), other.IPV4); - fieldSetFlags()[0] = other.fieldSetFlags()[0]; - } - if (isValidValue(fields()[1], other.MAC)) { - this.MAC = data().deepCopy(fields()[1].schema(), other.MAC); - fieldSetFlags()[1] = other.fieldSetFlags()[1]; - } - if (isValidValue(fields()[2], other.ID)) { - this.ID = data().deepCopy(fields()[2].schema(), other.ID); - fieldSetFlags()[2] = other.fieldSetFlags()[2]; - } - if (isValidValue(fields()[3], other.TYPE)) { - this.TYPE = data().deepCopy(fields()[3].schema(), other.TYPE); - fieldSetFlags()[3] = other.fieldSetFlags()[3]; - } - if (isValidValue(fields()[4], other.LAST_UPDATE)) { - this.LAST_UPDATE = data().deepCopy(fields()[4].schema(), other.LAST_UPDATE); - fieldSetFlags()[4] = other.fieldSetFlags()[4]; - } - if (isValidValue(fields()[5], other.LINK_QUALITY)) { - this.LINK_QUALITY = data().deepCopy(fields()[5].schema(), other.LINK_QUALITY); - fieldSetFlags()[5] = other.fieldSetFlags()[5]; - } - if (isValidValue(fields()[6], other.DATA)) { - this.DATA = data().deepCopy(fields()[6].schema(), other.DATA); - fieldSetFlags()[6] = other.fieldSetFlags()[6]; - } - } - - /** - * Creates a Builder by copying an existing IotDevice instance - * @param other The existing instance to copy. - */ - private Builder(io.skodjob.datagenerator.models.iotdevice.IotDevice other) { - super(SCHEMA$, MODEL$); - if (isValidValue(fields()[0], other.IPV4)) { - this.IPV4 = data().deepCopy(fields()[0].schema(), other.IPV4); - fieldSetFlags()[0] = true; - } - if (isValidValue(fields()[1], other.MAC)) { - this.MAC = data().deepCopy(fields()[1].schema(), other.MAC); - fieldSetFlags()[1] = true; - } - if (isValidValue(fields()[2], other.ID)) { - this.ID = data().deepCopy(fields()[2].schema(), other.ID); - fieldSetFlags()[2] = true; - } - if (isValidValue(fields()[3], other.TYPE)) { - this.TYPE = data().deepCopy(fields()[3].schema(), other.TYPE); - fieldSetFlags()[3] = true; - } - if (isValidValue(fields()[4], other.LAST_UPDATE)) { - this.LAST_UPDATE = data().deepCopy(fields()[4].schema(), other.LAST_UPDATE); - fieldSetFlags()[4] = true; - } - if (isValidValue(fields()[5], other.LINK_QUALITY)) { - this.LINK_QUALITY = data().deepCopy(fields()[5].schema(), other.LINK_QUALITY); - fieldSetFlags()[5] = true; - } - if (isValidValue(fields()[6], other.DATA)) { - this.DATA = data().deepCopy(fields()[6].schema(), other.DATA); - fieldSetFlags()[6] = true; - } - } - - /** - * Gets the value of the 'IPV4' field. - * @return The value. - */ - public java.lang.CharSequence getIPV4() { - return IPV4; - } - - - /** - * Sets the value of the 'IPV4' field. - * @param value The value of 'IPV4'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.iotdevice.IotDevice.Builder setIPV4(java.lang.CharSequence value) { - validate(fields()[0], value); - this.IPV4 = value; - fieldSetFlags()[0] = true; - return this; - } - - /** - * Checks whether the 'IPV4' field has been set. - * @return True if the 'IPV4' field has been set, false otherwise. - */ - public boolean hasIPV4() { - return fieldSetFlags()[0]; - } - - - /** - * Clears the value of the 'IPV4' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.iotdevice.IotDevice.Builder clearIPV4() { - IPV4 = null; - fieldSetFlags()[0] = false; - return this; - } - - /** - * Gets the value of the 'MAC' field. - * @return The value. - */ - public java.lang.CharSequence getMAC() { - return MAC; - } - - - /** - * Sets the value of the 'MAC' field. - * @param value The value of 'MAC'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.iotdevice.IotDevice.Builder setMAC(java.lang.CharSequence value) { - validate(fields()[1], value); - this.MAC = value; - fieldSetFlags()[1] = true; - return this; - } - - /** - * Checks whether the 'MAC' field has been set. - * @return True if the 'MAC' field has been set, false otherwise. - */ - public boolean hasMAC() { - return fieldSetFlags()[1]; - } - - - /** - * Clears the value of the 'MAC' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.iotdevice.IotDevice.Builder clearMAC() { - MAC = null; - fieldSetFlags()[1] = false; - return this; - } - - /** - * Gets the value of the 'ID' field. - * @return The value. - */ - public java.lang.CharSequence getID() { - return ID; - } - - - /** - * Sets the value of the 'ID' field. - * @param value The value of 'ID'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.iotdevice.IotDevice.Builder setID(java.lang.CharSequence value) { - validate(fields()[2], value); - this.ID = value; - fieldSetFlags()[2] = true; - return this; - } - - /** - * Checks whether the 'ID' field has been set. - * @return True if the 'ID' field has been set, false otherwise. - */ - public boolean hasID() { - return fieldSetFlags()[2]; - } - - - /** - * Clears the value of the 'ID' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.iotdevice.IotDevice.Builder clearID() { - ID = null; - fieldSetFlags()[2] = false; - return this; - } - - /** - * Gets the value of the 'TYPE' field. - * @return The value. - */ - public java.lang.CharSequence getTYPE() { - return TYPE; - } - - - /** - * Sets the value of the 'TYPE' field. - * @param value The value of 'TYPE'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.iotdevice.IotDevice.Builder setTYPE(java.lang.CharSequence value) { - validate(fields()[3], value); - this.TYPE = value; - fieldSetFlags()[3] = true; - return this; - } - - /** - * Checks whether the 'TYPE' field has been set. - * @return True if the 'TYPE' field has been set, false otherwise. - */ - public boolean hasTYPE() { - return fieldSetFlags()[3]; - } - - - /** - * Clears the value of the 'TYPE' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.iotdevice.IotDevice.Builder clearTYPE() { - TYPE = null; - fieldSetFlags()[3] = false; - return this; - } - - /** - * Gets the value of the 'LAST_UPDATE' field. - * @return The value. - */ - public java.lang.CharSequence getLASTUPDATE() { - return LAST_UPDATE; - } - - - /** - * Sets the value of the 'LAST_UPDATE' field. - * @param value The value of 'LAST_UPDATE'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.iotdevice.IotDevice.Builder setLASTUPDATE(java.lang.CharSequence value) { - validate(fields()[4], value); - this.LAST_UPDATE = value; - fieldSetFlags()[4] = true; - return this; - } - - /** - * Checks whether the 'LAST_UPDATE' field has been set. - * @return True if the 'LAST_UPDATE' field has been set, false otherwise. - */ - public boolean hasLASTUPDATE() { - return fieldSetFlags()[4]; - } - - - /** - * Clears the value of the 'LAST_UPDATE' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.iotdevice.IotDevice.Builder clearLASTUPDATE() { - LAST_UPDATE = null; - fieldSetFlags()[4] = false; - return this; - } - - /** - * Gets the value of the 'LINK_QUALITY' field. - * @return The value. - */ - public int getLINKQUALITY() { - return LINK_QUALITY; - } - - - /** - * Sets the value of the 'LINK_QUALITY' field. - * @param value The value of 'LINK_QUALITY'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.iotdevice.IotDevice.Builder setLINKQUALITY(int value) { - validate(fields()[5], value); - this.LINK_QUALITY = value; - fieldSetFlags()[5] = true; - return this; - } - - /** - * Checks whether the 'LINK_QUALITY' field has been set. - * @return True if the 'LINK_QUALITY' field has been set, false otherwise. - */ - public boolean hasLINKQUALITY() { - return fieldSetFlags()[5]; - } - - - /** - * Clears the value of the 'LINK_QUALITY' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.iotdevice.IotDevice.Builder clearLINKQUALITY() { - fieldSetFlags()[5] = false; - return this; - } - - /** - * Gets the value of the 'DATA' field. - * @return The value. - */ - public java.lang.Object getDATA() { - return DATA; - } - - - /** - * Sets the value of the 'DATA' field. - * @param value The value of 'DATA'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.iotdevice.IotDevice.Builder setDATA(java.lang.Object value) { - validate(fields()[6], value); - this.DATA = value; - fieldSetFlags()[6] = true; - return this; - } - - /** - * Checks whether the 'DATA' field has been set. - * @return True if the 'DATA' field has been set, false otherwise. - */ - public boolean hasDATA() { - return fieldSetFlags()[6]; - } - - - /** - * Clears the value of the 'DATA' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.iotdevice.IotDevice.Builder clearDATA() { - DATA = null; - fieldSetFlags()[6] = false; - return this; - } - - @Override - @SuppressWarnings("unchecked") - public IotDevice build() { - try { - IotDevice record = new IotDevice(); - record.IPV4 = fieldSetFlags()[0] ? this.IPV4 : (java.lang.CharSequence) defaultValue(fields()[0]); - record.MAC = fieldSetFlags()[1] ? this.MAC : (java.lang.CharSequence) defaultValue(fields()[1]); - record.ID = fieldSetFlags()[2] ? this.ID : (java.lang.CharSequence) defaultValue(fields()[2]); - record.TYPE = fieldSetFlags()[3] ? this.TYPE : (java.lang.CharSequence) defaultValue(fields()[3]); - record.LAST_UPDATE = fieldSetFlags()[4] ? this.LAST_UPDATE : (java.lang.CharSequence) defaultValue(fields()[4]); - record.LINK_QUALITY = fieldSetFlags()[5] ? this.LINK_QUALITY : (java.lang.Integer) defaultValue(fields()[5]); - record.DATA = fieldSetFlags()[6] ? this.DATA : defaultValue(fields()[6]); - return record; - } catch (org.apache.avro.AvroMissingFieldException e) { - throw e; - } catch (java.lang.Exception e) { - throw new org.apache.avro.AvroRuntimeException(e); - } - } - } - - @SuppressWarnings("unchecked") - private static final org.apache.avro.io.DatumWriter - WRITER$ = (org.apache.avro.io.DatumWriter)MODEL$.createDatumWriter(SCHEMA$); - - @Override public void writeExternal(java.io.ObjectOutput out) - throws java.io.IOException { - WRITER$.write(this, SpecificData.getEncoder(out)); - } - - @SuppressWarnings("unchecked") - private static final org.apache.avro.io.DatumReader - READER$ = (org.apache.avro.io.DatumReader)MODEL$.createDatumReader(SCHEMA$); - - @Override public void readExternal(java.io.ObjectInput in) - throws java.io.IOException { - READER$.read(this, SpecificData.getDecoder(in)); - } - -} - - - - - - - - - - diff --git a/src/main/java/io/skodjob/datagenerator/models/iotdevice/LightData.java b/src/main/java/io/skodjob/datagenerator/models/iotdevice/LightData.java deleted file mode 100644 index eaa4c62..0000000 --- a/src/main/java/io/skodjob/datagenerator/models/iotdevice/LightData.java +++ /dev/null @@ -1,478 +0,0 @@ -/** - * Autogenerated by Avro - * - * DO NOT EDIT DIRECTLY - */ -package io.skodjob.datagenerator.models.iotdevice; - -import org.apache.avro.generic.GenericArray; -import org.apache.avro.specific.SpecificData; -import org.apache.avro.util.Utf8; -import org.apache.avro.message.BinaryMessageEncoder; -import org.apache.avro.message.BinaryMessageDecoder; -import org.apache.avro.message.SchemaStore; - -@org.apache.avro.specific.AvroGenerated -public class LightData extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord { - private static final long serialVersionUID = 2564045829790584903L; - - - public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"LightData\",\"namespace\":\"io.skodjob.datagenerator.models.iotdevice\",\"fields\":[{\"name\":\"power\",\"type\":\"string\"},{\"name\":\"brightness\",\"type\":\"int\"},{\"name\":\"power_on_behavior\",\"type\":\"string\"}]}"); - public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } - - private static final SpecificData MODEL$ = new SpecificData(); - - private static final BinaryMessageEncoder ENCODER = - new BinaryMessageEncoder<>(MODEL$, SCHEMA$); - - private static final BinaryMessageDecoder DECODER = - new BinaryMessageDecoder<>(MODEL$, SCHEMA$); - - /** - * Return the BinaryMessageEncoder instance used by this class. - * @return the message encoder used by this class - */ - public static BinaryMessageEncoder getEncoder() { - return ENCODER; - } - - /** - * Return the BinaryMessageDecoder instance used by this class. - * @return the message decoder used by this class - */ - public static BinaryMessageDecoder getDecoder() { - return DECODER; - } - - /** - * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}. - * @param resolver a {@link SchemaStore} used to find schemas by fingerprint - * @return a BinaryMessageDecoder instance for this class backed by the given SchemaStore - */ - public static BinaryMessageDecoder createDecoder(SchemaStore resolver) { - return new BinaryMessageDecoder<>(MODEL$, SCHEMA$, resolver); - } - - /** - * Serializes this LightData to a ByteBuffer. - * @return a buffer holding the serialized data for this instance - * @throws java.io.IOException if this instance could not be serialized - */ - public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException { - return ENCODER.encode(this); - } - - /** - * Deserializes a LightData from a ByteBuffer. - * @param b a byte buffer holding serialized data for an instance of this class - * @return a LightData instance decoded from the given buffer - * @throws java.io.IOException if the given bytes could not be deserialized into an instance of this class - */ - public static LightData fromByteBuffer( - java.nio.ByteBuffer b) throws java.io.IOException { - return DECODER.decode(b); - } - - private java.lang.CharSequence power; - private int brightness; - private java.lang.CharSequence power_on_behavior; - - /** - * Default constructor. Note that this does not initialize fields - * to their default values from the schema. If that is desired then - * one should use newBuilder(). - */ - public LightData() {} - - /** - * All-args constructor. - * @param power The new value for power - * @param brightness The new value for brightness - * @param power_on_behavior The new value for power_on_behavior - */ - public LightData(java.lang.CharSequence power, java.lang.Integer brightness, java.lang.CharSequence power_on_behavior) { - this.power = power; - this.brightness = brightness; - this.power_on_behavior = power_on_behavior; - } - - @Override - public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; } - - @Override - public org.apache.avro.Schema getSchema() { return SCHEMA$; } - - // Used by DatumWriter. Applications should not call. - @Override - public java.lang.Object get(int field$) { - switch (field$) { - case 0: return power; - case 1: return brightness; - case 2: return power_on_behavior; - default: throw new IndexOutOfBoundsException("Invalid index: " + field$); - } - } - - // Used by DatumReader. Applications should not call. - @Override - @SuppressWarnings(value="unchecked") - public void put(int field$, java.lang.Object value$) { - switch (field$) { - case 0: power = (java.lang.CharSequence)value$; break; - case 1: brightness = (java.lang.Integer)value$; break; - case 2: power_on_behavior = (java.lang.CharSequence)value$; break; - default: throw new IndexOutOfBoundsException("Invalid index: " + field$); - } - } - - /** - * Gets the value of the 'power' field. - * @return The value of the 'power' field. - */ - public java.lang.CharSequence getPower() { - return power; - } - - - /** - * Sets the value of the 'power' field. - * @param value the value to set. - */ - public void setPower(java.lang.CharSequence value) { - this.power = value; - } - - /** - * Gets the value of the 'brightness' field. - * @return The value of the 'brightness' field. - */ - public int getBrightness() { - return brightness; - } - - - /** - * Sets the value of the 'brightness' field. - * @param value the value to set. - */ - public void setBrightness(int value) { - this.brightness = value; - } - - /** - * Gets the value of the 'power_on_behavior' field. - * @return The value of the 'power_on_behavior' field. - */ - public java.lang.CharSequence getPowerOnBehavior() { - return power_on_behavior; - } - - - /** - * Sets the value of the 'power_on_behavior' field. - * @param value the value to set. - */ - public void setPowerOnBehavior(java.lang.CharSequence value) { - this.power_on_behavior = value; - } - - /** - * Creates a new LightData RecordBuilder. - * @return A new LightData RecordBuilder - */ - public static io.skodjob.datagenerator.models.iotdevice.LightData.Builder newBuilder() { - return new io.skodjob.datagenerator.models.iotdevice.LightData.Builder(); - } - - /** - * Creates a new LightData RecordBuilder by copying an existing Builder. - * @param other The existing builder to copy. - * @return A new LightData RecordBuilder - */ - public static io.skodjob.datagenerator.models.iotdevice.LightData.Builder newBuilder(io.skodjob.datagenerator.models.iotdevice.LightData.Builder other) { - if (other == null) { - return new io.skodjob.datagenerator.models.iotdevice.LightData.Builder(); - } else { - return new io.skodjob.datagenerator.models.iotdevice.LightData.Builder(other); - } - } - - /** - * Creates a new LightData RecordBuilder by copying an existing LightData instance. - * @param other The existing instance to copy. - * @return A new LightData RecordBuilder - */ - public static io.skodjob.datagenerator.models.iotdevice.LightData.Builder newBuilder(io.skodjob.datagenerator.models.iotdevice.LightData other) { - if (other == null) { - return new io.skodjob.datagenerator.models.iotdevice.LightData.Builder(); - } else { - return new io.skodjob.datagenerator.models.iotdevice.LightData.Builder(other); - } - } - - /** - * RecordBuilder for LightData instances. - */ - @org.apache.avro.specific.AvroGenerated - public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase - implements org.apache.avro.data.RecordBuilder { - - private java.lang.CharSequence power; - private int brightness; - private java.lang.CharSequence power_on_behavior; - - /** Creates a new Builder */ - private Builder() { - super(SCHEMA$, MODEL$); - } - - /** - * Creates a Builder by copying an existing Builder. - * @param other The existing Builder to copy. - */ - private Builder(io.skodjob.datagenerator.models.iotdevice.LightData.Builder other) { - super(other); - if (isValidValue(fields()[0], other.power)) { - this.power = data().deepCopy(fields()[0].schema(), other.power); - fieldSetFlags()[0] = other.fieldSetFlags()[0]; - } - if (isValidValue(fields()[1], other.brightness)) { - this.brightness = data().deepCopy(fields()[1].schema(), other.brightness); - fieldSetFlags()[1] = other.fieldSetFlags()[1]; - } - if (isValidValue(fields()[2], other.power_on_behavior)) { - this.power_on_behavior = data().deepCopy(fields()[2].schema(), other.power_on_behavior); - fieldSetFlags()[2] = other.fieldSetFlags()[2]; - } - } - - /** - * Creates a Builder by copying an existing LightData instance - * @param other The existing instance to copy. - */ - private Builder(io.skodjob.datagenerator.models.iotdevice.LightData other) { - super(SCHEMA$, MODEL$); - if (isValidValue(fields()[0], other.power)) { - this.power = data().deepCopy(fields()[0].schema(), other.power); - fieldSetFlags()[0] = true; - } - if (isValidValue(fields()[1], other.brightness)) { - this.brightness = data().deepCopy(fields()[1].schema(), other.brightness); - fieldSetFlags()[1] = true; - } - if (isValidValue(fields()[2], other.power_on_behavior)) { - this.power_on_behavior = data().deepCopy(fields()[2].schema(), other.power_on_behavior); - fieldSetFlags()[2] = true; - } - } - - /** - * Gets the value of the 'power' field. - * @return The value. - */ - public java.lang.CharSequence getPower() { - return power; - } - - - /** - * Sets the value of the 'power' field. - * @param value The value of 'power'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.iotdevice.LightData.Builder setPower(java.lang.CharSequence value) { - validate(fields()[0], value); - this.power = value; - fieldSetFlags()[0] = true; - return this; - } - - /** - * Checks whether the 'power' field has been set. - * @return True if the 'power' field has been set, false otherwise. - */ - public boolean hasPower() { - return fieldSetFlags()[0]; - } - - - /** - * Clears the value of the 'power' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.iotdevice.LightData.Builder clearPower() { - power = null; - fieldSetFlags()[0] = false; - return this; - } - - /** - * Gets the value of the 'brightness' field. - * @return The value. - */ - public int getBrightness() { - return brightness; - } - - - /** - * Sets the value of the 'brightness' field. - * @param value The value of 'brightness'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.iotdevice.LightData.Builder setBrightness(int value) { - validate(fields()[1], value); - this.brightness = value; - fieldSetFlags()[1] = true; - return this; - } - - /** - * Checks whether the 'brightness' field has been set. - * @return True if the 'brightness' field has been set, false otherwise. - */ - public boolean hasBrightness() { - return fieldSetFlags()[1]; - } - - - /** - * Clears the value of the 'brightness' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.iotdevice.LightData.Builder clearBrightness() { - fieldSetFlags()[1] = false; - return this; - } - - /** - * Gets the value of the 'power_on_behavior' field. - * @return The value. - */ - public java.lang.CharSequence getPowerOnBehavior() { - return power_on_behavior; - } - - - /** - * Sets the value of the 'power_on_behavior' field. - * @param value The value of 'power_on_behavior'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.iotdevice.LightData.Builder setPowerOnBehavior(java.lang.CharSequence value) { - validate(fields()[2], value); - this.power_on_behavior = value; - fieldSetFlags()[2] = true; - return this; - } - - /** - * Checks whether the 'power_on_behavior' field has been set. - * @return True if the 'power_on_behavior' field has been set, false otherwise. - */ - public boolean hasPowerOnBehavior() { - return fieldSetFlags()[2]; - } - - - /** - * Clears the value of the 'power_on_behavior' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.iotdevice.LightData.Builder clearPowerOnBehavior() { - power_on_behavior = null; - fieldSetFlags()[2] = false; - return this; - } - - @Override - @SuppressWarnings("unchecked") - public LightData build() { - try { - LightData record = new LightData(); - record.power = fieldSetFlags()[0] ? this.power : (java.lang.CharSequence) defaultValue(fields()[0]); - record.brightness = fieldSetFlags()[1] ? this.brightness : (java.lang.Integer) defaultValue(fields()[1]); - record.power_on_behavior = fieldSetFlags()[2] ? this.power_on_behavior : (java.lang.CharSequence) defaultValue(fields()[2]); - return record; - } catch (org.apache.avro.AvroMissingFieldException e) { - throw e; - } catch (java.lang.Exception e) { - throw new org.apache.avro.AvroRuntimeException(e); - } - } - } - - @SuppressWarnings("unchecked") - private static final org.apache.avro.io.DatumWriter - WRITER$ = (org.apache.avro.io.DatumWriter)MODEL$.createDatumWriter(SCHEMA$); - - @Override public void writeExternal(java.io.ObjectOutput out) - throws java.io.IOException { - WRITER$.write(this, SpecificData.getEncoder(out)); - } - - @SuppressWarnings("unchecked") - private static final org.apache.avro.io.DatumReader - READER$ = (org.apache.avro.io.DatumReader)MODEL$.createDatumReader(SCHEMA$); - - @Override public void readExternal(java.io.ObjectInput in) - throws java.io.IOException { - READER$.read(this, SpecificData.getDecoder(in)); - } - - @Override protected boolean hasCustomCoders() { return true; } - - @Override public void customEncode(org.apache.avro.io.Encoder out) - throws java.io.IOException - { - out.writeString(this.power); - - out.writeInt(this.brightness); - - out.writeString(this.power_on_behavior); - - } - - @Override public void customDecode(org.apache.avro.io.ResolvingDecoder in) - throws java.io.IOException - { - org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff(); - if (fieldOrder == null) { - this.power = in.readString(this.power instanceof Utf8 ? (Utf8)this.power : null); - - this.brightness = in.readInt(); - - this.power_on_behavior = in.readString(this.power_on_behavior instanceof Utf8 ? (Utf8)this.power_on_behavior : null); - - } else { - for (int i = 0; i < 3; i++) { - switch (fieldOrder[i].pos()) { - case 0: - this.power = in.readString(this.power instanceof Utf8 ? (Utf8)this.power : null); - break; - - case 1: - this.brightness = in.readInt(); - break; - - case 2: - this.power_on_behavior = in.readString(this.power_on_behavior instanceof Utf8 ? (Utf8)this.power_on_behavior : null); - break; - - default: - throw new java.io.IOException("Corrupt ResolvingDecoder."); - } - } - } - } -} - - - - - - - - - - diff --git a/src/main/java/io/skodjob/datagenerator/models/iotdevice/PlugData.java b/src/main/java/io/skodjob/datagenerator/models/iotdevice/PlugData.java deleted file mode 100644 index 6703042..0000000 --- a/src/main/java/io/skodjob/datagenerator/models/iotdevice/PlugData.java +++ /dev/null @@ -1,591 +0,0 @@ -/** - * Autogenerated by Avro - * - * DO NOT EDIT DIRECTLY - */ -package io.skodjob.datagenerator.models.iotdevice; - -import org.apache.avro.generic.GenericArray; -import org.apache.avro.specific.SpecificData; -import org.apache.avro.util.Utf8; -import org.apache.avro.message.BinaryMessageEncoder; -import org.apache.avro.message.BinaryMessageDecoder; -import org.apache.avro.message.SchemaStore; - -@org.apache.avro.specific.AvroGenerated -public class PlugData extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord { - private static final long serialVersionUID = -8358036197985024305L; - - - public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"PlugData\",\"namespace\":\"io.skodjob.datagenerator.models.iotdevice\",\"fields\":[{\"name\":\"power\",\"type\":\"string\"},{\"name\":\"energy_current\",\"type\":{\"type\":\"record\",\"name\":\"EnergyCurrent\",\"fields\":[{\"name\":\"state\",\"type\":\"float\"},{\"name\":\"unit\",\"type\":\"string\"}]}},{\"name\":\"energy_today\",\"type\":{\"type\":\"record\",\"name\":\"EnergyToday\",\"fields\":[{\"name\":\"state\",\"type\":\"float\"},{\"name\":\"unit\",\"type\":\"string\"}]}}]}"); - public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } - - private static final SpecificData MODEL$ = new SpecificData(); - - private static final BinaryMessageEncoder ENCODER = - new BinaryMessageEncoder<>(MODEL$, SCHEMA$); - - private static final BinaryMessageDecoder DECODER = - new BinaryMessageDecoder<>(MODEL$, SCHEMA$); - - /** - * Return the BinaryMessageEncoder instance used by this class. - * @return the message encoder used by this class - */ - public static BinaryMessageEncoder getEncoder() { - return ENCODER; - } - - /** - * Return the BinaryMessageDecoder instance used by this class. - * @return the message decoder used by this class - */ - public static BinaryMessageDecoder getDecoder() { - return DECODER; - } - - /** - * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}. - * @param resolver a {@link SchemaStore} used to find schemas by fingerprint - * @return a BinaryMessageDecoder instance for this class backed by the given SchemaStore - */ - public static BinaryMessageDecoder createDecoder(SchemaStore resolver) { - return new BinaryMessageDecoder<>(MODEL$, SCHEMA$, resolver); - } - - /** - * Serializes this PlugData to a ByteBuffer. - * @return a buffer holding the serialized data for this instance - * @throws java.io.IOException if this instance could not be serialized - */ - public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException { - return ENCODER.encode(this); - } - - /** - * Deserializes a PlugData from a ByteBuffer. - * @param b a byte buffer holding serialized data for an instance of this class - * @return a PlugData instance decoded from the given buffer - * @throws java.io.IOException if the given bytes could not be deserialized into an instance of this class - */ - public static PlugData fromByteBuffer( - java.nio.ByteBuffer b) throws java.io.IOException { - return DECODER.decode(b); - } - - private java.lang.CharSequence power; - private io.skodjob.datagenerator.models.iotdevice.EnergyCurrent energy_current; - private io.skodjob.datagenerator.models.iotdevice.EnergyToday energy_today; - - /** - * Default constructor. Note that this does not initialize fields - * to their default values from the schema. If that is desired then - * one should use newBuilder(). - */ - public PlugData() {} - - /** - * All-args constructor. - * @param power The new value for power - * @param energy_current The new value for energy_current - * @param energy_today The new value for energy_today - */ - public PlugData(java.lang.CharSequence power, io.skodjob.datagenerator.models.iotdevice.EnergyCurrent energy_current, io.skodjob.datagenerator.models.iotdevice.EnergyToday energy_today) { - this.power = power; - this.energy_current = energy_current; - this.energy_today = energy_today; - } - - @Override - public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; } - - @Override - public org.apache.avro.Schema getSchema() { return SCHEMA$; } - - // Used by DatumWriter. Applications should not call. - @Override - public java.lang.Object get(int field$) { - switch (field$) { - case 0: return power; - case 1: return energy_current; - case 2: return energy_today; - default: throw new IndexOutOfBoundsException("Invalid index: " + field$); - } - } - - // Used by DatumReader. Applications should not call. - @Override - @SuppressWarnings(value="unchecked") - public void put(int field$, java.lang.Object value$) { - switch (field$) { - case 0: power = (java.lang.CharSequence)value$; break; - case 1: energy_current = (io.skodjob.datagenerator.models.iotdevice.EnergyCurrent)value$; break; - case 2: energy_today = (io.skodjob.datagenerator.models.iotdevice.EnergyToday)value$; break; - default: throw new IndexOutOfBoundsException("Invalid index: " + field$); - } - } - - /** - * Gets the value of the 'power' field. - * @return The value of the 'power' field. - */ - public java.lang.CharSequence getPower() { - return power; - } - - - /** - * Sets the value of the 'power' field. - * @param value the value to set. - */ - public void setPower(java.lang.CharSequence value) { - this.power = value; - } - - /** - * Gets the value of the 'energy_current' field. - * @return The value of the 'energy_current' field. - */ - public io.skodjob.datagenerator.models.iotdevice.EnergyCurrent getEnergyCurrent() { - return energy_current; - } - - - /** - * Sets the value of the 'energy_current' field. - * @param value the value to set. - */ - public void setEnergyCurrent(io.skodjob.datagenerator.models.iotdevice.EnergyCurrent value) { - this.energy_current = value; - } - - /** - * Gets the value of the 'energy_today' field. - * @return The value of the 'energy_today' field. - */ - public io.skodjob.datagenerator.models.iotdevice.EnergyToday getEnergyToday() { - return energy_today; - } - - - /** - * Sets the value of the 'energy_today' field. - * @param value the value to set. - */ - public void setEnergyToday(io.skodjob.datagenerator.models.iotdevice.EnergyToday value) { - this.energy_today = value; - } - - /** - * Creates a new PlugData RecordBuilder. - * @return A new PlugData RecordBuilder - */ - public static io.skodjob.datagenerator.models.iotdevice.PlugData.Builder newBuilder() { - return new io.skodjob.datagenerator.models.iotdevice.PlugData.Builder(); - } - - /** - * Creates a new PlugData RecordBuilder by copying an existing Builder. - * @param other The existing builder to copy. - * @return A new PlugData RecordBuilder - */ - public static io.skodjob.datagenerator.models.iotdevice.PlugData.Builder newBuilder(io.skodjob.datagenerator.models.iotdevice.PlugData.Builder other) { - if (other == null) { - return new io.skodjob.datagenerator.models.iotdevice.PlugData.Builder(); - } else { - return new io.skodjob.datagenerator.models.iotdevice.PlugData.Builder(other); - } - } - - /** - * Creates a new PlugData RecordBuilder by copying an existing PlugData instance. - * @param other The existing instance to copy. - * @return A new PlugData RecordBuilder - */ - public static io.skodjob.datagenerator.models.iotdevice.PlugData.Builder newBuilder(io.skodjob.datagenerator.models.iotdevice.PlugData other) { - if (other == null) { - return new io.skodjob.datagenerator.models.iotdevice.PlugData.Builder(); - } else { - return new io.skodjob.datagenerator.models.iotdevice.PlugData.Builder(other); - } - } - - /** - * RecordBuilder for PlugData instances. - */ - @org.apache.avro.specific.AvroGenerated - public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase - implements org.apache.avro.data.RecordBuilder { - - private java.lang.CharSequence power; - private io.skodjob.datagenerator.models.iotdevice.EnergyCurrent energy_current; - private io.skodjob.datagenerator.models.iotdevice.EnergyCurrent.Builder energy_currentBuilder; - private io.skodjob.datagenerator.models.iotdevice.EnergyToday energy_today; - private io.skodjob.datagenerator.models.iotdevice.EnergyToday.Builder energy_todayBuilder; - - /** Creates a new Builder */ - private Builder() { - super(SCHEMA$, MODEL$); - } - - /** - * Creates a Builder by copying an existing Builder. - * @param other The existing Builder to copy. - */ - private Builder(io.skodjob.datagenerator.models.iotdevice.PlugData.Builder other) { - super(other); - if (isValidValue(fields()[0], other.power)) { - this.power = data().deepCopy(fields()[0].schema(), other.power); - fieldSetFlags()[0] = other.fieldSetFlags()[0]; - } - if (isValidValue(fields()[1], other.energy_current)) { - this.energy_current = data().deepCopy(fields()[1].schema(), other.energy_current); - fieldSetFlags()[1] = other.fieldSetFlags()[1]; - } - if (other.hasEnergyCurrentBuilder()) { - this.energy_currentBuilder = io.skodjob.datagenerator.models.iotdevice.EnergyCurrent.newBuilder(other.getEnergyCurrentBuilder()); - } - if (isValidValue(fields()[2], other.energy_today)) { - this.energy_today = data().deepCopy(fields()[2].schema(), other.energy_today); - fieldSetFlags()[2] = other.fieldSetFlags()[2]; - } - if (other.hasEnergyTodayBuilder()) { - this.energy_todayBuilder = io.skodjob.datagenerator.models.iotdevice.EnergyToday.newBuilder(other.getEnergyTodayBuilder()); - } - } - - /** - * Creates a Builder by copying an existing PlugData instance - * @param other The existing instance to copy. - */ - private Builder(io.skodjob.datagenerator.models.iotdevice.PlugData other) { - super(SCHEMA$, MODEL$); - if (isValidValue(fields()[0], other.power)) { - this.power = data().deepCopy(fields()[0].schema(), other.power); - fieldSetFlags()[0] = true; - } - if (isValidValue(fields()[1], other.energy_current)) { - this.energy_current = data().deepCopy(fields()[1].schema(), other.energy_current); - fieldSetFlags()[1] = true; - } - this.energy_currentBuilder = null; - if (isValidValue(fields()[2], other.energy_today)) { - this.energy_today = data().deepCopy(fields()[2].schema(), other.energy_today); - fieldSetFlags()[2] = true; - } - this.energy_todayBuilder = null; - } - - /** - * Gets the value of the 'power' field. - * @return The value. - */ - public java.lang.CharSequence getPower() { - return power; - } - - - /** - * Sets the value of the 'power' field. - * @param value The value of 'power'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.iotdevice.PlugData.Builder setPower(java.lang.CharSequence value) { - validate(fields()[0], value); - this.power = value; - fieldSetFlags()[0] = true; - return this; - } - - /** - * Checks whether the 'power' field has been set. - * @return True if the 'power' field has been set, false otherwise. - */ - public boolean hasPower() { - return fieldSetFlags()[0]; - } - - - /** - * Clears the value of the 'power' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.iotdevice.PlugData.Builder clearPower() { - power = null; - fieldSetFlags()[0] = false; - return this; - } - - /** - * Gets the value of the 'energy_current' field. - * @return The value. - */ - public io.skodjob.datagenerator.models.iotdevice.EnergyCurrent getEnergyCurrent() { - return energy_current; - } - - - /** - * Sets the value of the 'energy_current' field. - * @param value The value of 'energy_current'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.iotdevice.PlugData.Builder setEnergyCurrent(io.skodjob.datagenerator.models.iotdevice.EnergyCurrent value) { - validate(fields()[1], value); - this.energy_currentBuilder = null; - this.energy_current = value; - fieldSetFlags()[1] = true; - return this; - } - - /** - * Checks whether the 'energy_current' field has been set. - * @return True if the 'energy_current' field has been set, false otherwise. - */ - public boolean hasEnergyCurrent() { - return fieldSetFlags()[1]; - } - - /** - * Gets the Builder instance for the 'energy_current' field and creates one if it doesn't exist yet. - * @return This builder. - */ - public io.skodjob.datagenerator.models.iotdevice.EnergyCurrent.Builder getEnergyCurrentBuilder() { - if (energy_currentBuilder == null) { - if (hasEnergyCurrent()) { - setEnergyCurrentBuilder(io.skodjob.datagenerator.models.iotdevice.EnergyCurrent.newBuilder(energy_current)); - } else { - setEnergyCurrentBuilder(io.skodjob.datagenerator.models.iotdevice.EnergyCurrent.newBuilder()); - } - } - return energy_currentBuilder; - } - - /** - * Sets the Builder instance for the 'energy_current' field - * @param value The builder instance that must be set. - * @return This builder. - */ - - public io.skodjob.datagenerator.models.iotdevice.PlugData.Builder setEnergyCurrentBuilder(io.skodjob.datagenerator.models.iotdevice.EnergyCurrent.Builder value) { - clearEnergyCurrent(); - energy_currentBuilder = value; - return this; - } - - /** - * Checks whether the 'energy_current' field has an active Builder instance - * @return True if the 'energy_current' field has an active Builder instance - */ - public boolean hasEnergyCurrentBuilder() { - return energy_currentBuilder != null; - } - - /** - * Clears the value of the 'energy_current' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.iotdevice.PlugData.Builder clearEnergyCurrent() { - energy_current = null; - energy_currentBuilder = null; - fieldSetFlags()[1] = false; - return this; - } - - /** - * Gets the value of the 'energy_today' field. - * @return The value. - */ - public io.skodjob.datagenerator.models.iotdevice.EnergyToday getEnergyToday() { - return energy_today; - } - - - /** - * Sets the value of the 'energy_today' field. - * @param value The value of 'energy_today'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.iotdevice.PlugData.Builder setEnergyToday(io.skodjob.datagenerator.models.iotdevice.EnergyToday value) { - validate(fields()[2], value); - this.energy_todayBuilder = null; - this.energy_today = value; - fieldSetFlags()[2] = true; - return this; - } - - /** - * Checks whether the 'energy_today' field has been set. - * @return True if the 'energy_today' field has been set, false otherwise. - */ - public boolean hasEnergyToday() { - return fieldSetFlags()[2]; - } - - /** - * Gets the Builder instance for the 'energy_today' field and creates one if it doesn't exist yet. - * @return This builder. - */ - public io.skodjob.datagenerator.models.iotdevice.EnergyToday.Builder getEnergyTodayBuilder() { - if (energy_todayBuilder == null) { - if (hasEnergyToday()) { - setEnergyTodayBuilder(io.skodjob.datagenerator.models.iotdevice.EnergyToday.newBuilder(energy_today)); - } else { - setEnergyTodayBuilder(io.skodjob.datagenerator.models.iotdevice.EnergyToday.newBuilder()); - } - } - return energy_todayBuilder; - } - - /** - * Sets the Builder instance for the 'energy_today' field - * @param value The builder instance that must be set. - * @return This builder. - */ - - public io.skodjob.datagenerator.models.iotdevice.PlugData.Builder setEnergyTodayBuilder(io.skodjob.datagenerator.models.iotdevice.EnergyToday.Builder value) { - clearEnergyToday(); - energy_todayBuilder = value; - return this; - } - - /** - * Checks whether the 'energy_today' field has an active Builder instance - * @return True if the 'energy_today' field has an active Builder instance - */ - public boolean hasEnergyTodayBuilder() { - return energy_todayBuilder != null; - } - - /** - * Clears the value of the 'energy_today' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.iotdevice.PlugData.Builder clearEnergyToday() { - energy_today = null; - energy_todayBuilder = null; - fieldSetFlags()[2] = false; - return this; - } - - @Override - @SuppressWarnings("unchecked") - public PlugData build() { - try { - PlugData record = new PlugData(); - record.power = fieldSetFlags()[0] ? this.power : (java.lang.CharSequence) defaultValue(fields()[0]); - if (energy_currentBuilder != null) { - try { - record.energy_current = this.energy_currentBuilder.build(); - } catch (org.apache.avro.AvroMissingFieldException e) { - e.addParentField(record.getSchema().getField("energy_current")); - throw e; - } - } else { - record.energy_current = fieldSetFlags()[1] ? this.energy_current : (io.skodjob.datagenerator.models.iotdevice.EnergyCurrent) defaultValue(fields()[1]); - } - if (energy_todayBuilder != null) { - try { - record.energy_today = this.energy_todayBuilder.build(); - } catch (org.apache.avro.AvroMissingFieldException e) { - e.addParentField(record.getSchema().getField("energy_today")); - throw e; - } - } else { - record.energy_today = fieldSetFlags()[2] ? this.energy_today : (io.skodjob.datagenerator.models.iotdevice.EnergyToday) defaultValue(fields()[2]); - } - return record; - } catch (org.apache.avro.AvroMissingFieldException e) { - throw e; - } catch (java.lang.Exception e) { - throw new org.apache.avro.AvroRuntimeException(e); - } - } - } - - @SuppressWarnings("unchecked") - private static final org.apache.avro.io.DatumWriter - WRITER$ = (org.apache.avro.io.DatumWriter)MODEL$.createDatumWriter(SCHEMA$); - - @Override public void writeExternal(java.io.ObjectOutput out) - throws java.io.IOException { - WRITER$.write(this, SpecificData.getEncoder(out)); - } - - @SuppressWarnings("unchecked") - private static final org.apache.avro.io.DatumReader - READER$ = (org.apache.avro.io.DatumReader)MODEL$.createDatumReader(SCHEMA$); - - @Override public void readExternal(java.io.ObjectInput in) - throws java.io.IOException { - READER$.read(this, SpecificData.getDecoder(in)); - } - - @Override protected boolean hasCustomCoders() { return true; } - - @Override public void customEncode(org.apache.avro.io.Encoder out) - throws java.io.IOException - { - out.writeString(this.power); - - this.energy_current.customEncode(out); - - this.energy_today.customEncode(out); - - } - - @Override public void customDecode(org.apache.avro.io.ResolvingDecoder in) - throws java.io.IOException - { - org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff(); - if (fieldOrder == null) { - this.power = in.readString(this.power instanceof Utf8 ? (Utf8)this.power : null); - - if (this.energy_current == null) { - this.energy_current = new io.skodjob.datagenerator.models.iotdevice.EnergyCurrent(); - } - this.energy_current.customDecode(in); - - if (this.energy_today == null) { - this.energy_today = new io.skodjob.datagenerator.models.iotdevice.EnergyToday(); - } - this.energy_today.customDecode(in); - - } else { - for (int i = 0; i < 3; i++) { - switch (fieldOrder[i].pos()) { - case 0: - this.power = in.readString(this.power instanceof Utf8 ? (Utf8)this.power : null); - break; - - case 1: - if (this.energy_current == null) { - this.energy_current = new io.skodjob.datagenerator.models.iotdevice.EnergyCurrent(); - } - this.energy_current.customDecode(in); - break; - - case 2: - if (this.energy_today == null) { - this.energy_today = new io.skodjob.datagenerator.models.iotdevice.EnergyToday(); - } - this.energy_today.customDecode(in); - break; - - default: - throw new java.io.IOException("Corrupt ResolvingDecoder."); - } - } - } - } -} - - - - - - - - - - diff --git a/src/main/java/io/skodjob/datagenerator/models/iotdevice/ThermometerData.java b/src/main/java/io/skodjob/datagenerator/models/iotdevice/ThermometerData.java deleted file mode 100644 index f7fc5d5..0000000 --- a/src/main/java/io/skodjob/datagenerator/models/iotdevice/ThermometerData.java +++ /dev/null @@ -1,533 +0,0 @@ -/** - * Autogenerated by Avro - * - * DO NOT EDIT DIRECTLY - */ -package io.skodjob.datagenerator.models.iotdevice; - -import org.apache.avro.generic.GenericArray; -import org.apache.avro.specific.SpecificData; -import org.apache.avro.util.Utf8; -import org.apache.avro.message.BinaryMessageEncoder; -import org.apache.avro.message.BinaryMessageDecoder; -import org.apache.avro.message.SchemaStore; - -@org.apache.avro.specific.AvroGenerated -public class ThermometerData extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord { - private static final long serialVersionUID = 4268847101870090241L; - - - public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"ThermometerData\",\"namespace\":\"io.skodjob.datagenerator.models.iotdevice\",\"fields\":[{\"name\":\"temperature\",\"type\":\"float\"},{\"name\":\"humidity\",\"type\":\"float\"},{\"name\":\"battery\",\"type\":{\"type\":\"record\",\"name\":\"Battery\",\"fields\":[{\"name\":\"value\",\"type\":\"int\"},{\"name\":\"unit\",\"type\":\"string\"}]}}]}"); - public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } - - private static final SpecificData MODEL$ = new SpecificData(); - - private static final BinaryMessageEncoder ENCODER = - new BinaryMessageEncoder<>(MODEL$, SCHEMA$); - - private static final BinaryMessageDecoder DECODER = - new BinaryMessageDecoder<>(MODEL$, SCHEMA$); - - /** - * Return the BinaryMessageEncoder instance used by this class. - * @return the message encoder used by this class - */ - public static BinaryMessageEncoder getEncoder() { - return ENCODER; - } - - /** - * Return the BinaryMessageDecoder instance used by this class. - * @return the message decoder used by this class - */ - public static BinaryMessageDecoder getDecoder() { - return DECODER; - } - - /** - * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}. - * @param resolver a {@link SchemaStore} used to find schemas by fingerprint - * @return a BinaryMessageDecoder instance for this class backed by the given SchemaStore - */ - public static BinaryMessageDecoder createDecoder(SchemaStore resolver) { - return new BinaryMessageDecoder<>(MODEL$, SCHEMA$, resolver); - } - - /** - * Serializes this ThermometerData to a ByteBuffer. - * @return a buffer holding the serialized data for this instance - * @throws java.io.IOException if this instance could not be serialized - */ - public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException { - return ENCODER.encode(this); - } - - /** - * Deserializes a ThermometerData from a ByteBuffer. - * @param b a byte buffer holding serialized data for an instance of this class - * @return a ThermometerData instance decoded from the given buffer - * @throws java.io.IOException if the given bytes could not be deserialized into an instance of this class - */ - public static ThermometerData fromByteBuffer( - java.nio.ByteBuffer b) throws java.io.IOException { - return DECODER.decode(b); - } - - private float temperature; - private float humidity; - private io.skodjob.datagenerator.models.iotdevice.Battery battery; - - /** - * Default constructor. Note that this does not initialize fields - * to their default values from the schema. If that is desired then - * one should use newBuilder(). - */ - public ThermometerData() {} - - /** - * All-args constructor. - * @param temperature The new value for temperature - * @param humidity The new value for humidity - * @param battery The new value for battery - */ - public ThermometerData(java.lang.Float temperature, java.lang.Float humidity, io.skodjob.datagenerator.models.iotdevice.Battery battery) { - this.temperature = temperature; - this.humidity = humidity; - this.battery = battery; - } - - @Override - public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; } - - @Override - public org.apache.avro.Schema getSchema() { return SCHEMA$; } - - // Used by DatumWriter. Applications should not call. - @Override - public java.lang.Object get(int field$) { - switch (field$) { - case 0: return temperature; - case 1: return humidity; - case 2: return battery; - default: throw new IndexOutOfBoundsException("Invalid index: " + field$); - } - } - - // Used by DatumReader. Applications should not call. - @Override - @SuppressWarnings(value="unchecked") - public void put(int field$, java.lang.Object value$) { - switch (field$) { - case 0: temperature = (java.lang.Float)value$; break; - case 1: humidity = (java.lang.Float)value$; break; - case 2: battery = (io.skodjob.datagenerator.models.iotdevice.Battery)value$; break; - default: throw new IndexOutOfBoundsException("Invalid index: " + field$); - } - } - - /** - * Gets the value of the 'temperature' field. - * @return The value of the 'temperature' field. - */ - public float getTemperature() { - return temperature; - } - - - /** - * Sets the value of the 'temperature' field. - * @param value the value to set. - */ - public void setTemperature(float value) { - this.temperature = value; - } - - /** - * Gets the value of the 'humidity' field. - * @return The value of the 'humidity' field. - */ - public float getHumidity() { - return humidity; - } - - - /** - * Sets the value of the 'humidity' field. - * @param value the value to set. - */ - public void setHumidity(float value) { - this.humidity = value; - } - - /** - * Gets the value of the 'battery' field. - * @return The value of the 'battery' field. - */ - public io.skodjob.datagenerator.models.iotdevice.Battery getBattery() { - return battery; - } - - - /** - * Sets the value of the 'battery' field. - * @param value the value to set. - */ - public void setBattery(io.skodjob.datagenerator.models.iotdevice.Battery value) { - this.battery = value; - } - - /** - * Creates a new ThermometerData RecordBuilder. - * @return A new ThermometerData RecordBuilder - */ - public static io.skodjob.datagenerator.models.iotdevice.ThermometerData.Builder newBuilder() { - return new io.skodjob.datagenerator.models.iotdevice.ThermometerData.Builder(); - } - - /** - * Creates a new ThermometerData RecordBuilder by copying an existing Builder. - * @param other The existing builder to copy. - * @return A new ThermometerData RecordBuilder - */ - public static io.skodjob.datagenerator.models.iotdevice.ThermometerData.Builder newBuilder(io.skodjob.datagenerator.models.iotdevice.ThermometerData.Builder other) { - if (other == null) { - return new io.skodjob.datagenerator.models.iotdevice.ThermometerData.Builder(); - } else { - return new io.skodjob.datagenerator.models.iotdevice.ThermometerData.Builder(other); - } - } - - /** - * Creates a new ThermometerData RecordBuilder by copying an existing ThermometerData instance. - * @param other The existing instance to copy. - * @return A new ThermometerData RecordBuilder - */ - public static io.skodjob.datagenerator.models.iotdevice.ThermometerData.Builder newBuilder(io.skodjob.datagenerator.models.iotdevice.ThermometerData other) { - if (other == null) { - return new io.skodjob.datagenerator.models.iotdevice.ThermometerData.Builder(); - } else { - return new io.skodjob.datagenerator.models.iotdevice.ThermometerData.Builder(other); - } - } - - /** - * RecordBuilder for ThermometerData instances. - */ - @org.apache.avro.specific.AvroGenerated - public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase - implements org.apache.avro.data.RecordBuilder { - - private float temperature; - private float humidity; - private io.skodjob.datagenerator.models.iotdevice.Battery battery; - private io.skodjob.datagenerator.models.iotdevice.Battery.Builder batteryBuilder; - - /** Creates a new Builder */ - private Builder() { - super(SCHEMA$, MODEL$); - } - - /** - * Creates a Builder by copying an existing Builder. - * @param other The existing Builder to copy. - */ - private Builder(io.skodjob.datagenerator.models.iotdevice.ThermometerData.Builder other) { - super(other); - if (isValidValue(fields()[0], other.temperature)) { - this.temperature = data().deepCopy(fields()[0].schema(), other.temperature); - fieldSetFlags()[0] = other.fieldSetFlags()[0]; - } - if (isValidValue(fields()[1], other.humidity)) { - this.humidity = data().deepCopy(fields()[1].schema(), other.humidity); - fieldSetFlags()[1] = other.fieldSetFlags()[1]; - } - if (isValidValue(fields()[2], other.battery)) { - this.battery = data().deepCopy(fields()[2].schema(), other.battery); - fieldSetFlags()[2] = other.fieldSetFlags()[2]; - } - if (other.hasBatteryBuilder()) { - this.batteryBuilder = io.skodjob.datagenerator.models.iotdevice.Battery.newBuilder(other.getBatteryBuilder()); - } - } - - /** - * Creates a Builder by copying an existing ThermometerData instance - * @param other The existing instance to copy. - */ - private Builder(io.skodjob.datagenerator.models.iotdevice.ThermometerData other) { - super(SCHEMA$, MODEL$); - if (isValidValue(fields()[0], other.temperature)) { - this.temperature = data().deepCopy(fields()[0].schema(), other.temperature); - fieldSetFlags()[0] = true; - } - if (isValidValue(fields()[1], other.humidity)) { - this.humidity = data().deepCopy(fields()[1].schema(), other.humidity); - fieldSetFlags()[1] = true; - } - if (isValidValue(fields()[2], other.battery)) { - this.battery = data().deepCopy(fields()[2].schema(), other.battery); - fieldSetFlags()[2] = true; - } - this.batteryBuilder = null; - } - - /** - * Gets the value of the 'temperature' field. - * @return The value. - */ - public float getTemperature() { - return temperature; - } - - - /** - * Sets the value of the 'temperature' field. - * @param value The value of 'temperature'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.iotdevice.ThermometerData.Builder setTemperature(float value) { - validate(fields()[0], value); - this.temperature = value; - fieldSetFlags()[0] = true; - return this; - } - - /** - * Checks whether the 'temperature' field has been set. - * @return True if the 'temperature' field has been set, false otherwise. - */ - public boolean hasTemperature() { - return fieldSetFlags()[0]; - } - - - /** - * Clears the value of the 'temperature' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.iotdevice.ThermometerData.Builder clearTemperature() { - fieldSetFlags()[0] = false; - return this; - } - - /** - * Gets the value of the 'humidity' field. - * @return The value. - */ - public float getHumidity() { - return humidity; - } - - - /** - * Sets the value of the 'humidity' field. - * @param value The value of 'humidity'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.iotdevice.ThermometerData.Builder setHumidity(float value) { - validate(fields()[1], value); - this.humidity = value; - fieldSetFlags()[1] = true; - return this; - } - - /** - * Checks whether the 'humidity' field has been set. - * @return True if the 'humidity' field has been set, false otherwise. - */ - public boolean hasHumidity() { - return fieldSetFlags()[1]; - } - - - /** - * Clears the value of the 'humidity' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.iotdevice.ThermometerData.Builder clearHumidity() { - fieldSetFlags()[1] = false; - return this; - } - - /** - * Gets the value of the 'battery' field. - * @return The value. - */ - public io.skodjob.datagenerator.models.iotdevice.Battery getBattery() { - return battery; - } - - - /** - * Sets the value of the 'battery' field. - * @param value The value of 'battery'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.iotdevice.ThermometerData.Builder setBattery(io.skodjob.datagenerator.models.iotdevice.Battery value) { - validate(fields()[2], value); - this.batteryBuilder = null; - this.battery = value; - fieldSetFlags()[2] = true; - return this; - } - - /** - * Checks whether the 'battery' field has been set. - * @return True if the 'battery' field has been set, false otherwise. - */ - public boolean hasBattery() { - return fieldSetFlags()[2]; - } - - /** - * Gets the Builder instance for the 'battery' field and creates one if it doesn't exist yet. - * @return This builder. - */ - public io.skodjob.datagenerator.models.iotdevice.Battery.Builder getBatteryBuilder() { - if (batteryBuilder == null) { - if (hasBattery()) { - setBatteryBuilder(io.skodjob.datagenerator.models.iotdevice.Battery.newBuilder(battery)); - } else { - setBatteryBuilder(io.skodjob.datagenerator.models.iotdevice.Battery.newBuilder()); - } - } - return batteryBuilder; - } - - /** - * Sets the Builder instance for the 'battery' field - * @param value The builder instance that must be set. - * @return This builder. - */ - - public io.skodjob.datagenerator.models.iotdevice.ThermometerData.Builder setBatteryBuilder(io.skodjob.datagenerator.models.iotdevice.Battery.Builder value) { - clearBattery(); - batteryBuilder = value; - return this; - } - - /** - * Checks whether the 'battery' field has an active Builder instance - * @return True if the 'battery' field has an active Builder instance - */ - public boolean hasBatteryBuilder() { - return batteryBuilder != null; - } - - /** - * Clears the value of the 'battery' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.iotdevice.ThermometerData.Builder clearBattery() { - battery = null; - batteryBuilder = null; - fieldSetFlags()[2] = false; - return this; - } - - @Override - @SuppressWarnings("unchecked") - public ThermometerData build() { - try { - ThermometerData record = new ThermometerData(); - record.temperature = fieldSetFlags()[0] ? this.temperature : (java.lang.Float) defaultValue(fields()[0]); - record.humidity = fieldSetFlags()[1] ? this.humidity : (java.lang.Float) defaultValue(fields()[1]); - if (batteryBuilder != null) { - try { - record.battery = this.batteryBuilder.build(); - } catch (org.apache.avro.AvroMissingFieldException e) { - e.addParentField(record.getSchema().getField("battery")); - throw e; - } - } else { - record.battery = fieldSetFlags()[2] ? this.battery : (io.skodjob.datagenerator.models.iotdevice.Battery) defaultValue(fields()[2]); - } - return record; - } catch (org.apache.avro.AvroMissingFieldException e) { - throw e; - } catch (java.lang.Exception e) { - throw new org.apache.avro.AvroRuntimeException(e); - } - } - } - - @SuppressWarnings("unchecked") - private static final org.apache.avro.io.DatumWriter - WRITER$ = (org.apache.avro.io.DatumWriter)MODEL$.createDatumWriter(SCHEMA$); - - @Override public void writeExternal(java.io.ObjectOutput out) - throws java.io.IOException { - WRITER$.write(this, SpecificData.getEncoder(out)); - } - - @SuppressWarnings("unchecked") - private static final org.apache.avro.io.DatumReader - READER$ = (org.apache.avro.io.DatumReader)MODEL$.createDatumReader(SCHEMA$); - - @Override public void readExternal(java.io.ObjectInput in) - throws java.io.IOException { - READER$.read(this, SpecificData.getDecoder(in)); - } - - @Override protected boolean hasCustomCoders() { return true; } - - @Override public void customEncode(org.apache.avro.io.Encoder out) - throws java.io.IOException - { - out.writeFloat(this.temperature); - - out.writeFloat(this.humidity); - - this.battery.customEncode(out); - - } - - @Override public void customDecode(org.apache.avro.io.ResolvingDecoder in) - throws java.io.IOException - { - org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff(); - if (fieldOrder == null) { - this.temperature = in.readFloat(); - - this.humidity = in.readFloat(); - - if (this.battery == null) { - this.battery = new io.skodjob.datagenerator.models.iotdevice.Battery(); - } - this.battery.customDecode(in); - - } else { - for (int i = 0; i < 3; i++) { - switch (fieldOrder[i].pos()) { - case 0: - this.temperature = in.readFloat(); - break; - - case 1: - this.humidity = in.readFloat(); - break; - - case 2: - if (this.battery == null) { - this.battery = new io.skodjob.datagenerator.models.iotdevice.Battery(); - } - this.battery.customDecode(in); - break; - - default: - throw new java.io.IOException("Corrupt ResolvingDecoder."); - } - } - } - } -} - - - - - - - - - - diff --git a/src/main/java/io/skodjob/datagenerator/models/paymentfiat/Address.java b/src/main/java/io/skodjob/datagenerator/models/paymentfiat/Address.java deleted file mode 100644 index a71abed..0000000 --- a/src/main/java/io/skodjob/datagenerator/models/paymentfiat/Address.java +++ /dev/null @@ -1,639 +0,0 @@ -/** - * Autogenerated by Avro - * - * DO NOT EDIT DIRECTLY - */ -package io.skodjob.datagenerator.models.paymentfiat; - -import org.apache.avro.generic.GenericArray; -import org.apache.avro.specific.SpecificData; -import org.apache.avro.util.Utf8; -import org.apache.avro.message.BinaryMessageEncoder; -import org.apache.avro.message.BinaryMessageDecoder; -import org.apache.avro.message.SchemaStore; - -@org.apache.avro.specific.AvroGenerated -public class Address extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord { - private static final long serialVersionUID = 8829654573407560916L; - - - public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"Address\",\"namespace\":\"io.skodjob.datagenerator.models.paymentfiat\",\"fields\":[{\"name\":\"street\",\"type\":\"string\"},{\"name\":\"city\",\"type\":\"string\"},{\"name\":\"state\",\"type\":\"string\"},{\"name\":\"country\",\"type\":\"string\"},{\"name\":\"postalCode\",\"type\":\"string\"}]}"); - public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } - - private static final SpecificData MODEL$ = new SpecificData(); - - private static final BinaryMessageEncoder
ENCODER = - new BinaryMessageEncoder<>(MODEL$, SCHEMA$); - - private static final BinaryMessageDecoder
DECODER = - new BinaryMessageDecoder<>(MODEL$, SCHEMA$); - - /** - * Return the BinaryMessageEncoder instance used by this class. - * @return the message encoder used by this class - */ - public static BinaryMessageEncoder
getEncoder() { - return ENCODER; - } - - /** - * Return the BinaryMessageDecoder instance used by this class. - * @return the message decoder used by this class - */ - public static BinaryMessageDecoder
getDecoder() { - return DECODER; - } - - /** - * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}. - * @param resolver a {@link SchemaStore} used to find schemas by fingerprint - * @return a BinaryMessageDecoder instance for this class backed by the given SchemaStore - */ - public static BinaryMessageDecoder
createDecoder(SchemaStore resolver) { - return new BinaryMessageDecoder<>(MODEL$, SCHEMA$, resolver); - } - - /** - * Serializes this Address to a ByteBuffer. - * @return a buffer holding the serialized data for this instance - * @throws java.io.IOException if this instance could not be serialized - */ - public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException { - return ENCODER.encode(this); - } - - /** - * Deserializes a Address from a ByteBuffer. - * @param b a byte buffer holding serialized data for an instance of this class - * @return a Address instance decoded from the given buffer - * @throws java.io.IOException if the given bytes could not be deserialized into an instance of this class - */ - public static Address fromByteBuffer( - java.nio.ByteBuffer b) throws java.io.IOException { - return DECODER.decode(b); - } - - private java.lang.CharSequence street; - private java.lang.CharSequence city; - private java.lang.CharSequence state; - private java.lang.CharSequence country; - private java.lang.CharSequence postalCode; - - /** - * Default constructor. Note that this does not initialize fields - * to their default values from the schema. If that is desired then - * one should use newBuilder(). - */ - public Address() {} - - /** - * All-args constructor. - * @param street The new value for street - * @param city The new value for city - * @param state The new value for state - * @param country The new value for country - * @param postalCode The new value for postalCode - */ - public Address(java.lang.CharSequence street, java.lang.CharSequence city, java.lang.CharSequence state, java.lang.CharSequence country, java.lang.CharSequence postalCode) { - this.street = street; - this.city = city; - this.state = state; - this.country = country; - this.postalCode = postalCode; - } - - @Override - public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; } - - @Override - public org.apache.avro.Schema getSchema() { return SCHEMA$; } - - // Used by DatumWriter. Applications should not call. - @Override - public java.lang.Object get(int field$) { - switch (field$) { - case 0: return street; - case 1: return city; - case 2: return state; - case 3: return country; - case 4: return postalCode; - default: throw new IndexOutOfBoundsException("Invalid index: " + field$); - } - } - - // Used by DatumReader. Applications should not call. - @Override - @SuppressWarnings(value="unchecked") - public void put(int field$, java.lang.Object value$) { - switch (field$) { - case 0: street = (java.lang.CharSequence)value$; break; - case 1: city = (java.lang.CharSequence)value$; break; - case 2: state = (java.lang.CharSequence)value$; break; - case 3: country = (java.lang.CharSequence)value$; break; - case 4: postalCode = (java.lang.CharSequence)value$; break; - default: throw new IndexOutOfBoundsException("Invalid index: " + field$); - } - } - - /** - * Gets the value of the 'street' field. - * @return The value of the 'street' field. - */ - public java.lang.CharSequence getStreet() { - return street; - } - - - /** - * Sets the value of the 'street' field. - * @param value the value to set. - */ - public void setStreet(java.lang.CharSequence value) { - this.street = value; - } - - /** - * Gets the value of the 'city' field. - * @return The value of the 'city' field. - */ - public java.lang.CharSequence getCity() { - return city; - } - - - /** - * Sets the value of the 'city' field. - * @param value the value to set. - */ - public void setCity(java.lang.CharSequence value) { - this.city = value; - } - - /** - * Gets the value of the 'state' field. - * @return The value of the 'state' field. - */ - public java.lang.CharSequence getState() { - return state; - } - - - /** - * Sets the value of the 'state' field. - * @param value the value to set. - */ - public void setState(java.lang.CharSequence value) { - this.state = value; - } - - /** - * Gets the value of the 'country' field. - * @return The value of the 'country' field. - */ - public java.lang.CharSequence getCountry() { - return country; - } - - - /** - * Sets the value of the 'country' field. - * @param value the value to set. - */ - public void setCountry(java.lang.CharSequence value) { - this.country = value; - } - - /** - * Gets the value of the 'postalCode' field. - * @return The value of the 'postalCode' field. - */ - public java.lang.CharSequence getPostalCode() { - return postalCode; - } - - - /** - * Sets the value of the 'postalCode' field. - * @param value the value to set. - */ - public void setPostalCode(java.lang.CharSequence value) { - this.postalCode = value; - } - - /** - * Creates a new Address RecordBuilder. - * @return A new Address RecordBuilder - */ - public static io.skodjob.datagenerator.models.paymentfiat.Address.Builder newBuilder() { - return new io.skodjob.datagenerator.models.paymentfiat.Address.Builder(); - } - - /** - * Creates a new Address RecordBuilder by copying an existing Builder. - * @param other The existing builder to copy. - * @return A new Address RecordBuilder - */ - public static io.skodjob.datagenerator.models.paymentfiat.Address.Builder newBuilder(io.skodjob.datagenerator.models.paymentfiat.Address.Builder other) { - if (other == null) { - return new io.skodjob.datagenerator.models.paymentfiat.Address.Builder(); - } else { - return new io.skodjob.datagenerator.models.paymentfiat.Address.Builder(other); - } - } - - /** - * Creates a new Address RecordBuilder by copying an existing Address instance. - * @param other The existing instance to copy. - * @return A new Address RecordBuilder - */ - public static io.skodjob.datagenerator.models.paymentfiat.Address.Builder newBuilder(io.skodjob.datagenerator.models.paymentfiat.Address other) { - if (other == null) { - return new io.skodjob.datagenerator.models.paymentfiat.Address.Builder(); - } else { - return new io.skodjob.datagenerator.models.paymentfiat.Address.Builder(other); - } - } - - /** - * RecordBuilder for Address instances. - */ - @org.apache.avro.specific.AvroGenerated - public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase
- implements org.apache.avro.data.RecordBuilder
{ - - private java.lang.CharSequence street; - private java.lang.CharSequence city; - private java.lang.CharSequence state; - private java.lang.CharSequence country; - private java.lang.CharSequence postalCode; - - /** Creates a new Builder */ - private Builder() { - super(SCHEMA$, MODEL$); - } - - /** - * Creates a Builder by copying an existing Builder. - * @param other The existing Builder to copy. - */ - private Builder(io.skodjob.datagenerator.models.paymentfiat.Address.Builder other) { - super(other); - if (isValidValue(fields()[0], other.street)) { - this.street = data().deepCopy(fields()[0].schema(), other.street); - fieldSetFlags()[0] = other.fieldSetFlags()[0]; - } - if (isValidValue(fields()[1], other.city)) { - this.city = data().deepCopy(fields()[1].schema(), other.city); - fieldSetFlags()[1] = other.fieldSetFlags()[1]; - } - if (isValidValue(fields()[2], other.state)) { - this.state = data().deepCopy(fields()[2].schema(), other.state); - fieldSetFlags()[2] = other.fieldSetFlags()[2]; - } - if (isValidValue(fields()[3], other.country)) { - this.country = data().deepCopy(fields()[3].schema(), other.country); - fieldSetFlags()[3] = other.fieldSetFlags()[3]; - } - if (isValidValue(fields()[4], other.postalCode)) { - this.postalCode = data().deepCopy(fields()[4].schema(), other.postalCode); - fieldSetFlags()[4] = other.fieldSetFlags()[4]; - } - } - - /** - * Creates a Builder by copying an existing Address instance - * @param other The existing instance to copy. - */ - private Builder(io.skodjob.datagenerator.models.paymentfiat.Address other) { - super(SCHEMA$, MODEL$); - if (isValidValue(fields()[0], other.street)) { - this.street = data().deepCopy(fields()[0].schema(), other.street); - fieldSetFlags()[0] = true; - } - if (isValidValue(fields()[1], other.city)) { - this.city = data().deepCopy(fields()[1].schema(), other.city); - fieldSetFlags()[1] = true; - } - if (isValidValue(fields()[2], other.state)) { - this.state = data().deepCopy(fields()[2].schema(), other.state); - fieldSetFlags()[2] = true; - } - if (isValidValue(fields()[3], other.country)) { - this.country = data().deepCopy(fields()[3].schema(), other.country); - fieldSetFlags()[3] = true; - } - if (isValidValue(fields()[4], other.postalCode)) { - this.postalCode = data().deepCopy(fields()[4].schema(), other.postalCode); - fieldSetFlags()[4] = true; - } - } - - /** - * Gets the value of the 'street' field. - * @return The value. - */ - public java.lang.CharSequence getStreet() { - return street; - } - - - /** - * Sets the value of the 'street' field. - * @param value The value of 'street'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.paymentfiat.Address.Builder setStreet(java.lang.CharSequence value) { - validate(fields()[0], value); - this.street = value; - fieldSetFlags()[0] = true; - return this; - } - - /** - * Checks whether the 'street' field has been set. - * @return True if the 'street' field has been set, false otherwise. - */ - public boolean hasStreet() { - return fieldSetFlags()[0]; - } - - - /** - * Clears the value of the 'street' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.paymentfiat.Address.Builder clearStreet() { - street = null; - fieldSetFlags()[0] = false; - return this; - } - - /** - * Gets the value of the 'city' field. - * @return The value. - */ - public java.lang.CharSequence getCity() { - return city; - } - - - /** - * Sets the value of the 'city' field. - * @param value The value of 'city'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.paymentfiat.Address.Builder setCity(java.lang.CharSequence value) { - validate(fields()[1], value); - this.city = value; - fieldSetFlags()[1] = true; - return this; - } - - /** - * Checks whether the 'city' field has been set. - * @return True if the 'city' field has been set, false otherwise. - */ - public boolean hasCity() { - return fieldSetFlags()[1]; - } - - - /** - * Clears the value of the 'city' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.paymentfiat.Address.Builder clearCity() { - city = null; - fieldSetFlags()[1] = false; - return this; - } - - /** - * Gets the value of the 'state' field. - * @return The value. - */ - public java.lang.CharSequence getState() { - return state; - } - - - /** - * Sets the value of the 'state' field. - * @param value The value of 'state'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.paymentfiat.Address.Builder setState(java.lang.CharSequence value) { - validate(fields()[2], value); - this.state = value; - fieldSetFlags()[2] = true; - return this; - } - - /** - * Checks whether the 'state' field has been set. - * @return True if the 'state' field has been set, false otherwise. - */ - public boolean hasState() { - return fieldSetFlags()[2]; - } - - - /** - * Clears the value of the 'state' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.paymentfiat.Address.Builder clearState() { - state = null; - fieldSetFlags()[2] = false; - return this; - } - - /** - * Gets the value of the 'country' field. - * @return The value. - */ - public java.lang.CharSequence getCountry() { - return country; - } - - - /** - * Sets the value of the 'country' field. - * @param value The value of 'country'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.paymentfiat.Address.Builder setCountry(java.lang.CharSequence value) { - validate(fields()[3], value); - this.country = value; - fieldSetFlags()[3] = true; - return this; - } - - /** - * Checks whether the 'country' field has been set. - * @return True if the 'country' field has been set, false otherwise. - */ - public boolean hasCountry() { - return fieldSetFlags()[3]; - } - - - /** - * Clears the value of the 'country' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.paymentfiat.Address.Builder clearCountry() { - country = null; - fieldSetFlags()[3] = false; - return this; - } - - /** - * Gets the value of the 'postalCode' field. - * @return The value. - */ - public java.lang.CharSequence getPostalCode() { - return postalCode; - } - - - /** - * Sets the value of the 'postalCode' field. - * @param value The value of 'postalCode'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.paymentfiat.Address.Builder setPostalCode(java.lang.CharSequence value) { - validate(fields()[4], value); - this.postalCode = value; - fieldSetFlags()[4] = true; - return this; - } - - /** - * Checks whether the 'postalCode' field has been set. - * @return True if the 'postalCode' field has been set, false otherwise. - */ - public boolean hasPostalCode() { - return fieldSetFlags()[4]; - } - - - /** - * Clears the value of the 'postalCode' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.paymentfiat.Address.Builder clearPostalCode() { - postalCode = null; - fieldSetFlags()[4] = false; - return this; - } - - @Override - @SuppressWarnings("unchecked") - public Address build() { - try { - Address record = new Address(); - record.street = fieldSetFlags()[0] ? this.street : (java.lang.CharSequence) defaultValue(fields()[0]); - record.city = fieldSetFlags()[1] ? this.city : (java.lang.CharSequence) defaultValue(fields()[1]); - record.state = fieldSetFlags()[2] ? this.state : (java.lang.CharSequence) defaultValue(fields()[2]); - record.country = fieldSetFlags()[3] ? this.country : (java.lang.CharSequence) defaultValue(fields()[3]); - record.postalCode = fieldSetFlags()[4] ? this.postalCode : (java.lang.CharSequence) defaultValue(fields()[4]); - return record; - } catch (org.apache.avro.AvroMissingFieldException e) { - throw e; - } catch (java.lang.Exception e) { - throw new org.apache.avro.AvroRuntimeException(e); - } - } - } - - @SuppressWarnings("unchecked") - private static final org.apache.avro.io.DatumWriter
- WRITER$ = (org.apache.avro.io.DatumWriter
)MODEL$.createDatumWriter(SCHEMA$); - - @Override public void writeExternal(java.io.ObjectOutput out) - throws java.io.IOException { - WRITER$.write(this, SpecificData.getEncoder(out)); - } - - @SuppressWarnings("unchecked") - private static final org.apache.avro.io.DatumReader
- READER$ = (org.apache.avro.io.DatumReader
)MODEL$.createDatumReader(SCHEMA$); - - @Override public void readExternal(java.io.ObjectInput in) - throws java.io.IOException { - READER$.read(this, SpecificData.getDecoder(in)); - } - - @Override protected boolean hasCustomCoders() { return true; } - - @Override public void customEncode(org.apache.avro.io.Encoder out) - throws java.io.IOException - { - out.writeString(this.street); - - out.writeString(this.city); - - out.writeString(this.state); - - out.writeString(this.country); - - out.writeString(this.postalCode); - - } - - @Override public void customDecode(org.apache.avro.io.ResolvingDecoder in) - throws java.io.IOException - { - org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff(); - if (fieldOrder == null) { - this.street = in.readString(this.street instanceof Utf8 ? (Utf8)this.street : null); - - this.city = in.readString(this.city instanceof Utf8 ? (Utf8)this.city : null); - - this.state = in.readString(this.state instanceof Utf8 ? (Utf8)this.state : null); - - this.country = in.readString(this.country instanceof Utf8 ? (Utf8)this.country : null); - - this.postalCode = in.readString(this.postalCode instanceof Utf8 ? (Utf8)this.postalCode : null); - - } else { - for (int i = 0; i < 5; i++) { - switch (fieldOrder[i].pos()) { - case 0: - this.street = in.readString(this.street instanceof Utf8 ? (Utf8)this.street : null); - break; - - case 1: - this.city = in.readString(this.city instanceof Utf8 ? (Utf8)this.city : null); - break; - - case 2: - this.state = in.readString(this.state instanceof Utf8 ? (Utf8)this.state : null); - break; - - case 3: - this.country = in.readString(this.country instanceof Utf8 ? (Utf8)this.country : null); - break; - - case 4: - this.postalCode = in.readString(this.postalCode instanceof Utf8 ? (Utf8)this.postalCode : null); - break; - - default: - throw new java.io.IOException("Corrupt ResolvingDecoder."); - } - } - } - } -} - - - - - - - - - - diff --git a/src/main/java/io/skodjob/datagenerator/models/paymentfiat/Payee.java b/src/main/java/io/skodjob/datagenerator/models/paymentfiat/Payee.java deleted file mode 100644 index 3dec3cf..0000000 --- a/src/main/java/io/skodjob/datagenerator/models/paymentfiat/Payee.java +++ /dev/null @@ -1,694 +0,0 @@ -/** - * Autogenerated by Avro - * - * DO NOT EDIT DIRECTLY - */ -package io.skodjob.datagenerator.models.paymentfiat; - -import org.apache.avro.specific.SpecificData; -import org.apache.avro.util.Utf8; -import org.apache.avro.message.BinaryMessageEncoder; -import org.apache.avro.message.BinaryMessageDecoder; -import org.apache.avro.message.SchemaStore; - -@org.apache.avro.specific.AvroGenerated -public class Payee extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord { - private static final long serialVersionUID = -4078330169720103566L; - - - public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"Payee\",\"namespace\":\"io.skodjob.datagenerator.models\",\"fields\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"payeeType\",\"type\":\"string\"},{\"name\":\"accountNumber\",\"type\":\"string\"},{\"name\":\"bank\",\"type\":\"string\"},{\"name\":\"address\",\"type\":{\"type\":\"record\",\"name\":\"Address\",\"fields\":[{\"name\":\"street\",\"type\":\"string\"},{\"name\":\"city\",\"type\":\"string\"},{\"name\":\"state\",\"type\":\"string\"},{\"name\":\"country\",\"type\":\"string\"},{\"name\":\"postalCode\",\"type\":\"string\"}]}}]}"); - public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } - - private static final SpecificData MODEL$ = new SpecificData(); - - private static final BinaryMessageEncoder ENCODER = - new BinaryMessageEncoder<>(MODEL$, SCHEMA$); - - private static final BinaryMessageDecoder DECODER = - new BinaryMessageDecoder<>(MODEL$, SCHEMA$); - - /** - * Return the BinaryMessageEncoder instance used by this class. - * @return the message encoder used by this class - */ - public static BinaryMessageEncoder getEncoder() { - return ENCODER; - } - - /** - * Return the BinaryMessageDecoder instance used by this class. - * @return the message decoder used by this class - */ - public static BinaryMessageDecoder getDecoder() { - return DECODER; - } - - /** - * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}. - * @param resolver a {@link SchemaStore} used to find schemas by fingerprint - * @return a BinaryMessageDecoder instance for this class backed by the given SchemaStore - */ - public static BinaryMessageDecoder createDecoder(SchemaStore resolver) { - return new BinaryMessageDecoder<>(MODEL$, SCHEMA$, resolver); - } - - /** - * Serializes this Payee to a ByteBuffer. - * @return a buffer holding the serialized data for this instance - * @throws java.io.IOException if this instance could not be serialized - */ - public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException { - return ENCODER.encode(this); - } - - /** - * Deserializes a Payee from a ByteBuffer. - * @param b a byte buffer holding serialized data for an instance of this class - * @return a Payee instance decoded from the given buffer - * @throws java.io.IOException if the given bytes could not be deserialized into an instance of this class - */ - public static Payee fromByteBuffer( - java.nio.ByteBuffer b) throws java.io.IOException { - return DECODER.decode(b); - } - - private java.lang.CharSequence name; - private java.lang.CharSequence payeeType; - private java.lang.CharSequence accountNumber; - private java.lang.CharSequence bank; - private Address address; - - /** - * Default constructor. Note that this does not initialize fields - * to their default values from the schema. If that is desired then - * one should use newBuilder(). - */ - public Payee() {} - - /** - * All-args constructor. - * @param name The new value for name - * @param payeeType The new value for payeeType - * @param accountNumber The new value for accountNumber - * @param bank The new value for bank - * @param address The new value for address - */ - public Payee(java.lang.CharSequence name, java.lang.CharSequence payeeType, java.lang.CharSequence accountNumber, java.lang.CharSequence bank, Address address) { - this.name = name; - this.payeeType = payeeType; - this.accountNumber = accountNumber; - this.bank = bank; - this.address = address; - } - - @Override - public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; } - - @Override - public org.apache.avro.Schema getSchema() { return SCHEMA$; } - - // Used by DatumWriter. Applications should not call. - @Override - public java.lang.Object get(int field$) { - switch (field$) { - case 0: return name; - case 1: return payeeType; - case 2: return accountNumber; - case 3: return bank; - case 4: return address; - default: throw new IndexOutOfBoundsException("Invalid index: " + field$); - } - } - - // Used by DatumReader. Applications should not call. - @Override - @SuppressWarnings(value="unchecked") - public void put(int field$, java.lang.Object value$) { - switch (field$) { - case 0: name = (java.lang.CharSequence)value$; break; - case 1: payeeType = (java.lang.CharSequence)value$; break; - case 2: accountNumber = (java.lang.CharSequence)value$; break; - case 3: bank = (java.lang.CharSequence)value$; break; - case 4: address = (Address)value$; break; - default: throw new IndexOutOfBoundsException("Invalid index: " + field$); - } - } - - /** - * Gets the value of the 'name' field. - * @return The value of the 'name' field. - */ - public java.lang.CharSequence getName() { - return name; - } - - - /** - * Sets the value of the 'name' field. - * @param value the value to set. - */ - public void setName(java.lang.CharSequence value) { - this.name = value; - } - - /** - * Gets the value of the 'payeeType' field. - * @return The value of the 'payeeType' field. - */ - public java.lang.CharSequence getPayeeType() { - return payeeType; - } - - - /** - * Sets the value of the 'payeeType' field. - * @param value the value to set. - */ - public void setPayeeType(java.lang.CharSequence value) { - this.payeeType = value; - } - - /** - * Gets the value of the 'accountNumber' field. - * @return The value of the 'accountNumber' field. - */ - public java.lang.CharSequence getAccountNumber() { - return accountNumber; - } - - - /** - * Sets the value of the 'accountNumber' field. - * @param value the value to set. - */ - public void setAccountNumber(java.lang.CharSequence value) { - this.accountNumber = value; - } - - /** - * Gets the value of the 'bank' field. - * @return The value of the 'bank' field. - */ - public java.lang.CharSequence getBank() { - return bank; - } - - - /** - * Sets the value of the 'bank' field. - * @param value the value to set. - */ - public void setBank(java.lang.CharSequence value) { - this.bank = value; - } - - /** - * Gets the value of the 'address' field. - * @return The value of the 'address' field. - */ - public Address getAddress() { - return address; - } - - - /** - * Sets the value of the 'address' field. - * @param value the value to set. - */ - public void setAddress(Address value) { - this.address = value; - } - - /** - * Creates a new Payee RecordBuilder. - * @return A new Payee RecordBuilder - */ - public static Payee.Builder newBuilder() { - return new Payee.Builder(); - } - - /** - * Creates a new Payee RecordBuilder by copying an existing Builder. - * @param other The existing builder to copy. - * @return A new Payee RecordBuilder - */ - public static Payee.Builder newBuilder(Payee.Builder other) { - if (other == null) { - return new Payee.Builder(); - } else { - return new Payee.Builder(other); - } - } - - /** - * Creates a new Payee RecordBuilder by copying an existing Payee instance. - * @param other The existing instance to copy. - * @return A new Payee RecordBuilder - */ - public static Payee.Builder newBuilder(Payee other) { - if (other == null) { - return new Payee.Builder(); - } else { - return new Payee.Builder(other); - } - } - - /** - * RecordBuilder for Payee instances. - */ - @org.apache.avro.specific.AvroGenerated - public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase - implements org.apache.avro.data.RecordBuilder { - - private java.lang.CharSequence name; - private java.lang.CharSequence payeeType; - private java.lang.CharSequence accountNumber; - private java.lang.CharSequence bank; - private Address address; - private Address.Builder addressBuilder; - - /** Creates a new Builder */ - private Builder() { - super(SCHEMA$, MODEL$); - } - - /** - * Creates a Builder by copying an existing Builder. - * @param other The existing Builder to copy. - */ - private Builder(Payee.Builder other) { - super(other); - if (isValidValue(fields()[0], other.name)) { - this.name = data().deepCopy(fields()[0].schema(), other.name); - fieldSetFlags()[0] = other.fieldSetFlags()[0]; - } - if (isValidValue(fields()[1], other.payeeType)) { - this.payeeType = data().deepCopy(fields()[1].schema(), other.payeeType); - fieldSetFlags()[1] = other.fieldSetFlags()[1]; - } - if (isValidValue(fields()[2], other.accountNumber)) { - this.accountNumber = data().deepCopy(fields()[2].schema(), other.accountNumber); - fieldSetFlags()[2] = other.fieldSetFlags()[2]; - } - if (isValidValue(fields()[3], other.bank)) { - this.bank = data().deepCopy(fields()[3].schema(), other.bank); - fieldSetFlags()[3] = other.fieldSetFlags()[3]; - } - if (isValidValue(fields()[4], other.address)) { - this.address = data().deepCopy(fields()[4].schema(), other.address); - fieldSetFlags()[4] = other.fieldSetFlags()[4]; - } - if (other.hasAddressBuilder()) { - this.addressBuilder = Address.newBuilder(other.getAddressBuilder()); - } - } - - /** - * Creates a Builder by copying an existing Payee instance - * @param other The existing instance to copy. - */ - private Builder(Payee other) { - super(SCHEMA$, MODEL$); - if (isValidValue(fields()[0], other.name)) { - this.name = data().deepCopy(fields()[0].schema(), other.name); - fieldSetFlags()[0] = true; - } - if (isValidValue(fields()[1], other.payeeType)) { - this.payeeType = data().deepCopy(fields()[1].schema(), other.payeeType); - fieldSetFlags()[1] = true; - } - if (isValidValue(fields()[2], other.accountNumber)) { - this.accountNumber = data().deepCopy(fields()[2].schema(), other.accountNumber); - fieldSetFlags()[2] = true; - } - if (isValidValue(fields()[3], other.bank)) { - this.bank = data().deepCopy(fields()[3].schema(), other.bank); - fieldSetFlags()[3] = true; - } - if (isValidValue(fields()[4], other.address)) { - this.address = data().deepCopy(fields()[4].schema(), other.address); - fieldSetFlags()[4] = true; - } - this.addressBuilder = null; - } - - /** - * Gets the value of the 'name' field. - * @return The value. - */ - public java.lang.CharSequence getName() { - return name; - } - - - /** - * Sets the value of the 'name' field. - * @param value The value of 'name'. - * @return This builder. - */ - public Payee.Builder setName(java.lang.CharSequence value) { - validate(fields()[0], value); - this.name = value; - fieldSetFlags()[0] = true; - return this; - } - - /** - * Checks whether the 'name' field has been set. - * @return True if the 'name' field has been set, false otherwise. - */ - public boolean hasName() { - return fieldSetFlags()[0]; - } - - - /** - * Clears the value of the 'name' field. - * @return This builder. - */ - public Payee.Builder clearName() { - name = null; - fieldSetFlags()[0] = false; - return this; - } - - /** - * Gets the value of the 'payeeType' field. - * @return The value. - */ - public java.lang.CharSequence getPayeeType() { - return payeeType; - } - - - /** - * Sets the value of the 'payeeType' field. - * @param value The value of 'payeeType'. - * @return This builder. - */ - public Payee.Builder setPayeeType(java.lang.CharSequence value) { - validate(fields()[1], value); - this.payeeType = value; - fieldSetFlags()[1] = true; - return this; - } - - /** - * Checks whether the 'payeeType' field has been set. - * @return True if the 'payeeType' field has been set, false otherwise. - */ - public boolean hasPayeeType() { - return fieldSetFlags()[1]; - } - - - /** - * Clears the value of the 'payeeType' field. - * @return This builder. - */ - public Payee.Builder clearPayeeType() { - payeeType = null; - fieldSetFlags()[1] = false; - return this; - } - - /** - * Gets the value of the 'accountNumber' field. - * @return The value. - */ - public java.lang.CharSequence getAccountNumber() { - return accountNumber; - } - - - /** - * Sets the value of the 'accountNumber' field. - * @param value The value of 'accountNumber'. - * @return This builder. - */ - public Payee.Builder setAccountNumber(java.lang.CharSequence value) { - validate(fields()[2], value); - this.accountNumber = value; - fieldSetFlags()[2] = true; - return this; - } - - /** - * Checks whether the 'accountNumber' field has been set. - * @return True if the 'accountNumber' field has been set, false otherwise. - */ - public boolean hasAccountNumber() { - return fieldSetFlags()[2]; - } - - - /** - * Clears the value of the 'accountNumber' field. - * @return This builder. - */ - public Payee.Builder clearAccountNumber() { - accountNumber = null; - fieldSetFlags()[2] = false; - return this; - } - - /** - * Gets the value of the 'bank' field. - * @return The value. - */ - public java.lang.CharSequence getBank() { - return bank; - } - - - /** - * Sets the value of the 'bank' field. - * @param value The value of 'bank'. - * @return This builder. - */ - public Payee.Builder setBank(java.lang.CharSequence value) { - validate(fields()[3], value); - this.bank = value; - fieldSetFlags()[3] = true; - return this; - } - - /** - * Checks whether the 'bank' field has been set. - * @return True if the 'bank' field has been set, false otherwise. - */ - public boolean hasBank() { - return fieldSetFlags()[3]; - } - - - /** - * Clears the value of the 'bank' field. - * @return This builder. - */ - public Payee.Builder clearBank() { - bank = null; - fieldSetFlags()[3] = false; - return this; - } - - /** - * Gets the value of the 'address' field. - * @return The value. - */ - public Address getAddress() { - return address; - } - - - /** - * Sets the value of the 'address' field. - * @param value The value of 'address'. - * @return This builder. - */ - public Payee.Builder setAddress(Address value) { - validate(fields()[4], value); - this.addressBuilder = null; - this.address = value; - fieldSetFlags()[4] = true; - return this; - } - - /** - * Checks whether the 'address' field has been set. - * @return True if the 'address' field has been set, false otherwise. - */ - public boolean hasAddress() { - return fieldSetFlags()[4]; - } - - /** - * Gets the Builder instance for the 'address' field and creates one if it doesn't exist yet. - * @return This builder. - */ - public Address.Builder getAddressBuilder() { - if (addressBuilder == null) { - if (hasAddress()) { - setAddressBuilder(Address.newBuilder(address)); - } else { - setAddressBuilder(Address.newBuilder()); - } - } - return addressBuilder; - } - - /** - * Sets the Builder instance for the 'address' field - * @param value The builder instance that must be set. - * @return This builder. - */ - - public Payee.Builder setAddressBuilder(Address.Builder value) { - clearAddress(); - addressBuilder = value; - return this; - } - - /** - * Checks whether the 'address' field has an active Builder instance - * @return True if the 'address' field has an active Builder instance - */ - public boolean hasAddressBuilder() { - return addressBuilder != null; - } - - /** - * Clears the value of the 'address' field. - * @return This builder. - */ - public Payee.Builder clearAddress() { - address = null; - addressBuilder = null; - fieldSetFlags()[4] = false; - return this; - } - - @Override - @SuppressWarnings("unchecked") - public Payee build() { - try { - Payee record = new Payee(); - record.name = fieldSetFlags()[0] ? this.name : (java.lang.CharSequence) defaultValue(fields()[0]); - record.payeeType = fieldSetFlags()[1] ? this.payeeType : (java.lang.CharSequence) defaultValue(fields()[1]); - record.accountNumber = fieldSetFlags()[2] ? this.accountNumber : (java.lang.CharSequence) defaultValue(fields()[2]); - record.bank = fieldSetFlags()[3] ? this.bank : (java.lang.CharSequence) defaultValue(fields()[3]); - if (addressBuilder != null) { - try { - record.address = this.addressBuilder.build(); - } catch (org.apache.avro.AvroMissingFieldException e) { - e.addParentField(record.getSchema().getField("address")); - throw e; - } - } else { - record.address = fieldSetFlags()[4] ? this.address : (Address) defaultValue(fields()[4]); - } - return record; - } catch (org.apache.avro.AvroMissingFieldException e) { - throw e; - } catch (java.lang.Exception e) { - throw new org.apache.avro.AvroRuntimeException(e); - } - } - } - - @SuppressWarnings("unchecked") - private static final org.apache.avro.io.DatumWriter - WRITER$ = (org.apache.avro.io.DatumWriter)MODEL$.createDatumWriter(SCHEMA$); - - @Override public void writeExternal(java.io.ObjectOutput out) - throws java.io.IOException { - WRITER$.write(this, SpecificData.getEncoder(out)); - } - - @SuppressWarnings("unchecked") - private static final org.apache.avro.io.DatumReader - READER$ = (org.apache.avro.io.DatumReader)MODEL$.createDatumReader(SCHEMA$); - - @Override public void readExternal(java.io.ObjectInput in) - throws java.io.IOException { - READER$.read(this, SpecificData.getDecoder(in)); - } - - @Override protected boolean hasCustomCoders() { return true; } - - @Override public void customEncode(org.apache.avro.io.Encoder out) - throws java.io.IOException - { - out.writeString(this.name); - - out.writeString(this.payeeType); - - out.writeString(this.accountNumber); - - out.writeString(this.bank); - - this.address.customEncode(out); - - } - - @Override public void customDecode(org.apache.avro.io.ResolvingDecoder in) - throws java.io.IOException - { - org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff(); - if (fieldOrder == null) { - this.name = in.readString(this.name instanceof Utf8 ? (Utf8)this.name : null); - - this.payeeType = in.readString(this.payeeType instanceof Utf8 ? (Utf8)this.payeeType : null); - - this.accountNumber = in.readString(this.accountNumber instanceof Utf8 ? (Utf8)this.accountNumber : null); - - this.bank = in.readString(this.bank instanceof Utf8 ? (Utf8)this.bank : null); - - if (this.address == null) { - this.address = new Address(); - } - this.address.customDecode(in); - - } else { - for (int i = 0; i < 5; i++) { - switch (fieldOrder[i].pos()) { - case 0: - this.name = in.readString(this.name instanceof Utf8 ? (Utf8)this.name : null); - break; - - case 1: - this.payeeType = in.readString(this.payeeType instanceof Utf8 ? (Utf8)this.payeeType : null); - break; - - case 2: - this.accountNumber = in.readString(this.accountNumber instanceof Utf8 ? (Utf8)this.accountNumber : null); - break; - - case 3: - this.bank = in.readString(this.bank instanceof Utf8 ? (Utf8)this.bank : null); - break; - - case 4: - if (this.address == null) { - this.address = new Address(); - } - this.address.customDecode(in); - break; - - default: - throw new java.io.IOException("Corrupt ResolvingDecoder."); - } - } - } - } -} - - - - - - - - - - diff --git a/src/main/java/io/skodjob/datagenerator/models/paymentfiat/Payer.java b/src/main/java/io/skodjob/datagenerator/models/paymentfiat/Payer.java deleted file mode 100644 index 373c6c9..0000000 --- a/src/main/java/io/skodjob/datagenerator/models/paymentfiat/Payer.java +++ /dev/null @@ -1,983 +0,0 @@ -/** - * Autogenerated by Avro - * - * DO NOT EDIT DIRECTLY - */ -package io.skodjob.datagenerator.models.paymentfiat; - -import org.apache.avro.generic.GenericArray; -import org.apache.avro.specific.SpecificData; -import org.apache.avro.util.Utf8; -import org.apache.avro.message.BinaryMessageEncoder; -import org.apache.avro.message.BinaryMessageDecoder; -import org.apache.avro.message.SchemaStore; - -@org.apache.avro.specific.AvroGenerated -public class Payer extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord { - private static final long serialVersionUID = 5810398614907498299L; - - - public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"Payer\",\"namespace\":\"io.skodjob.datagenerator.models.paymentfiat\",\"fields\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"payerType\",\"type\":\"string\"},{\"name\":\"accountNumber\",\"type\":\"string\"},{\"name\":\"bank\",\"type\":\"string\"},{\"name\":\"billingAddress\",\"type\":{\"type\":\"record\",\"name\":\"Address\",\"fields\":[{\"name\":\"street\",\"type\":\"string\"},{\"name\":\"city\",\"type\":\"string\"},{\"name\":\"state\",\"type\":\"string\"},{\"name\":\"country\",\"type\":\"string\"},{\"name\":\"postalCode\",\"type\":\"string\"}]}},{\"name\":\"cardNumber\",\"type\":[\"null\",\"string\"],\"default\":null},{\"name\":\"cardType\",\"type\":[\"null\",\"string\"],\"default\":null},{\"name\":\"expiryDate\",\"type\":[\"null\",\"string\"],\"default\":null}]}"); - public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } - - private static final SpecificData MODEL$ = new SpecificData(); - - private static final BinaryMessageEncoder ENCODER = - new BinaryMessageEncoder<>(MODEL$, SCHEMA$); - - private static final BinaryMessageDecoder DECODER = - new BinaryMessageDecoder<>(MODEL$, SCHEMA$); - - /** - * Return the BinaryMessageEncoder instance used by this class. - * @return the message encoder used by this class - */ - public static BinaryMessageEncoder getEncoder() { - return ENCODER; - } - - /** - * Return the BinaryMessageDecoder instance used by this class. - * @return the message decoder used by this class - */ - public static BinaryMessageDecoder getDecoder() { - return DECODER; - } - - /** - * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}. - * @param resolver a {@link SchemaStore} used to find schemas by fingerprint - * @return a BinaryMessageDecoder instance for this class backed by the given SchemaStore - */ - public static BinaryMessageDecoder createDecoder(SchemaStore resolver) { - return new BinaryMessageDecoder<>(MODEL$, SCHEMA$, resolver); - } - - /** - * Serializes this Payer to a ByteBuffer. - * @return a buffer holding the serialized data for this instance - * @throws java.io.IOException if this instance could not be serialized - */ - public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException { - return ENCODER.encode(this); - } - - /** - * Deserializes a Payer from a ByteBuffer. - * @param b a byte buffer holding serialized data for an instance of this class - * @return a Payer instance decoded from the given buffer - * @throws java.io.IOException if the given bytes could not be deserialized into an instance of this class - */ - public static Payer fromByteBuffer( - java.nio.ByteBuffer b) throws java.io.IOException { - return DECODER.decode(b); - } - - private java.lang.CharSequence name; - private java.lang.CharSequence payerType; - private java.lang.CharSequence accountNumber; - private java.lang.CharSequence bank; - private io.skodjob.datagenerator.models.paymentfiat.Address billingAddress; - private java.lang.CharSequence cardNumber; - private java.lang.CharSequence cardType; - private java.lang.CharSequence expiryDate; - - /** - * Default constructor. Note that this does not initialize fields - * to their default values from the schema. If that is desired then - * one should use newBuilder(). - */ - public Payer() {} - - /** - * All-args constructor. - * @param name The new value for name - * @param payerType The new value for payerType - * @param accountNumber The new value for accountNumber - * @param bank The new value for bank - * @param billingAddress The new value for billingAddress - * @param cardNumber The new value for cardNumber - * @param cardType The new value for cardType - * @param expiryDate The new value for expiryDate - */ - public Payer(java.lang.CharSequence name, java.lang.CharSequence payerType, java.lang.CharSequence accountNumber, java.lang.CharSequence bank, io.skodjob.datagenerator.models.paymentfiat.Address billingAddress, java.lang.CharSequence cardNumber, java.lang.CharSequence cardType, java.lang.CharSequence expiryDate) { - this.name = name; - this.payerType = payerType; - this.accountNumber = accountNumber; - this.bank = bank; - this.billingAddress = billingAddress; - this.cardNumber = cardNumber; - this.cardType = cardType; - this.expiryDate = expiryDate; - } - - @Override - public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; } - - @Override - public org.apache.avro.Schema getSchema() { return SCHEMA$; } - - // Used by DatumWriter. Applications should not call. - @Override - public java.lang.Object get(int field$) { - switch (field$) { - case 0: return name; - case 1: return payerType; - case 2: return accountNumber; - case 3: return bank; - case 4: return billingAddress; - case 5: return cardNumber; - case 6: return cardType; - case 7: return expiryDate; - default: throw new IndexOutOfBoundsException("Invalid index: " + field$); - } - } - - // Used by DatumReader. Applications should not call. - @Override - @SuppressWarnings(value="unchecked") - public void put(int field$, java.lang.Object value$) { - switch (field$) { - case 0: name = (java.lang.CharSequence)value$; break; - case 1: payerType = (java.lang.CharSequence)value$; break; - case 2: accountNumber = (java.lang.CharSequence)value$; break; - case 3: bank = (java.lang.CharSequence)value$; break; - case 4: billingAddress = (io.skodjob.datagenerator.models.paymentfiat.Address)value$; break; - case 5: cardNumber = (java.lang.CharSequence)value$; break; - case 6: cardType = (java.lang.CharSequence)value$; break; - case 7: expiryDate = (java.lang.CharSequence)value$; break; - default: throw new IndexOutOfBoundsException("Invalid index: " + field$); - } - } - - /** - * Gets the value of the 'name' field. - * @return The value of the 'name' field. - */ - public java.lang.CharSequence getName() { - return name; - } - - - /** - * Sets the value of the 'name' field. - * @param value the value to set. - */ - public void setName(java.lang.CharSequence value) { - this.name = value; - } - - /** - * Gets the value of the 'payerType' field. - * @return The value of the 'payerType' field. - */ - public java.lang.CharSequence getPayerType() { - return payerType; - } - - - /** - * Sets the value of the 'payerType' field. - * @param value the value to set. - */ - public void setPayerType(java.lang.CharSequence value) { - this.payerType = value; - } - - /** - * Gets the value of the 'accountNumber' field. - * @return The value of the 'accountNumber' field. - */ - public java.lang.CharSequence getAccountNumber() { - return accountNumber; - } - - - /** - * Sets the value of the 'accountNumber' field. - * @param value the value to set. - */ - public void setAccountNumber(java.lang.CharSequence value) { - this.accountNumber = value; - } - - /** - * Gets the value of the 'bank' field. - * @return The value of the 'bank' field. - */ - public java.lang.CharSequence getBank() { - return bank; - } - - - /** - * Sets the value of the 'bank' field. - * @param value the value to set. - */ - public void setBank(java.lang.CharSequence value) { - this.bank = value; - } - - /** - * Gets the value of the 'billingAddress' field. - * @return The value of the 'billingAddress' field. - */ - public io.skodjob.datagenerator.models.paymentfiat.Address getBillingAddress() { - return billingAddress; - } - - - /** - * Sets the value of the 'billingAddress' field. - * @param value the value to set. - */ - public void setBillingAddress(io.skodjob.datagenerator.models.paymentfiat.Address value) { - this.billingAddress = value; - } - - /** - * Gets the value of the 'cardNumber' field. - * @return The value of the 'cardNumber' field. - */ - public java.lang.CharSequence getCardNumber() { - return cardNumber; - } - - - /** - * Sets the value of the 'cardNumber' field. - * @param value the value to set. - */ - public void setCardNumber(java.lang.CharSequence value) { - this.cardNumber = value; - } - - /** - * Gets the value of the 'cardType' field. - * @return The value of the 'cardType' field. - */ - public java.lang.CharSequence getCardType() { - return cardType; - } - - - /** - * Sets the value of the 'cardType' field. - * @param value the value to set. - */ - public void setCardType(java.lang.CharSequence value) { - this.cardType = value; - } - - /** - * Gets the value of the 'expiryDate' field. - * @return The value of the 'expiryDate' field. - */ - public java.lang.CharSequence getExpiryDate() { - return expiryDate; - } - - - /** - * Sets the value of the 'expiryDate' field. - * @param value the value to set. - */ - public void setExpiryDate(java.lang.CharSequence value) { - this.expiryDate = value; - } - - /** - * Creates a new Payer RecordBuilder. - * @return A new Payer RecordBuilder - */ - public static io.skodjob.datagenerator.models.paymentfiat.Payer.Builder newBuilder() { - return new io.skodjob.datagenerator.models.paymentfiat.Payer.Builder(); - } - - /** - * Creates a new Payer RecordBuilder by copying an existing Builder. - * @param other The existing builder to copy. - * @return A new Payer RecordBuilder - */ - public static io.skodjob.datagenerator.models.paymentfiat.Payer.Builder newBuilder(io.skodjob.datagenerator.models.paymentfiat.Payer.Builder other) { - if (other == null) { - return new io.skodjob.datagenerator.models.paymentfiat.Payer.Builder(); - } else { - return new io.skodjob.datagenerator.models.paymentfiat.Payer.Builder(other); - } - } - - /** - * Creates a new Payer RecordBuilder by copying an existing Payer instance. - * @param other The existing instance to copy. - * @return A new Payer RecordBuilder - */ - public static io.skodjob.datagenerator.models.paymentfiat.Payer.Builder newBuilder(io.skodjob.datagenerator.models.paymentfiat.Payer other) { - if (other == null) { - return new io.skodjob.datagenerator.models.paymentfiat.Payer.Builder(); - } else { - return new io.skodjob.datagenerator.models.paymentfiat.Payer.Builder(other); - } - } - - /** - * RecordBuilder for Payer instances. - */ - @org.apache.avro.specific.AvroGenerated - public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase - implements org.apache.avro.data.RecordBuilder { - - private java.lang.CharSequence name; - private java.lang.CharSequence payerType; - private java.lang.CharSequence accountNumber; - private java.lang.CharSequence bank; - private io.skodjob.datagenerator.models.paymentfiat.Address billingAddress; - private io.skodjob.datagenerator.models.paymentfiat.Address.Builder billingAddressBuilder; - private java.lang.CharSequence cardNumber; - private java.lang.CharSequence cardType; - private java.lang.CharSequence expiryDate; - - /** Creates a new Builder */ - private Builder() { - super(SCHEMA$, MODEL$); - } - - /** - * Creates a Builder by copying an existing Builder. - * @param other The existing Builder to copy. - */ - private Builder(io.skodjob.datagenerator.models.paymentfiat.Payer.Builder other) { - super(other); - if (isValidValue(fields()[0], other.name)) { - this.name = data().deepCopy(fields()[0].schema(), other.name); - fieldSetFlags()[0] = other.fieldSetFlags()[0]; - } - if (isValidValue(fields()[1], other.payerType)) { - this.payerType = data().deepCopy(fields()[1].schema(), other.payerType); - fieldSetFlags()[1] = other.fieldSetFlags()[1]; - } - if (isValidValue(fields()[2], other.accountNumber)) { - this.accountNumber = data().deepCopy(fields()[2].schema(), other.accountNumber); - fieldSetFlags()[2] = other.fieldSetFlags()[2]; - } - if (isValidValue(fields()[3], other.bank)) { - this.bank = data().deepCopy(fields()[3].schema(), other.bank); - fieldSetFlags()[3] = other.fieldSetFlags()[3]; - } - if (isValidValue(fields()[4], other.billingAddress)) { - this.billingAddress = data().deepCopy(fields()[4].schema(), other.billingAddress); - fieldSetFlags()[4] = other.fieldSetFlags()[4]; - } - if (other.hasBillingAddressBuilder()) { - this.billingAddressBuilder = io.skodjob.datagenerator.models.paymentfiat.Address.newBuilder(other.getBillingAddressBuilder()); - } - if (isValidValue(fields()[5], other.cardNumber)) { - this.cardNumber = data().deepCopy(fields()[5].schema(), other.cardNumber); - fieldSetFlags()[5] = other.fieldSetFlags()[5]; - } - if (isValidValue(fields()[6], other.cardType)) { - this.cardType = data().deepCopy(fields()[6].schema(), other.cardType); - fieldSetFlags()[6] = other.fieldSetFlags()[6]; - } - if (isValidValue(fields()[7], other.expiryDate)) { - this.expiryDate = data().deepCopy(fields()[7].schema(), other.expiryDate); - fieldSetFlags()[7] = other.fieldSetFlags()[7]; - } - } - - /** - * Creates a Builder by copying an existing Payer instance - * @param other The existing instance to copy. - */ - private Builder(io.skodjob.datagenerator.models.paymentfiat.Payer other) { - super(SCHEMA$, MODEL$); - if (isValidValue(fields()[0], other.name)) { - this.name = data().deepCopy(fields()[0].schema(), other.name); - fieldSetFlags()[0] = true; - } - if (isValidValue(fields()[1], other.payerType)) { - this.payerType = data().deepCopy(fields()[1].schema(), other.payerType); - fieldSetFlags()[1] = true; - } - if (isValidValue(fields()[2], other.accountNumber)) { - this.accountNumber = data().deepCopy(fields()[2].schema(), other.accountNumber); - fieldSetFlags()[2] = true; - } - if (isValidValue(fields()[3], other.bank)) { - this.bank = data().deepCopy(fields()[3].schema(), other.bank); - fieldSetFlags()[3] = true; - } - if (isValidValue(fields()[4], other.billingAddress)) { - this.billingAddress = data().deepCopy(fields()[4].schema(), other.billingAddress); - fieldSetFlags()[4] = true; - } - this.billingAddressBuilder = null; - if (isValidValue(fields()[5], other.cardNumber)) { - this.cardNumber = data().deepCopy(fields()[5].schema(), other.cardNumber); - fieldSetFlags()[5] = true; - } - if (isValidValue(fields()[6], other.cardType)) { - this.cardType = data().deepCopy(fields()[6].schema(), other.cardType); - fieldSetFlags()[6] = true; - } - if (isValidValue(fields()[7], other.expiryDate)) { - this.expiryDate = data().deepCopy(fields()[7].schema(), other.expiryDate); - fieldSetFlags()[7] = true; - } - } - - /** - * Gets the value of the 'name' field. - * @return The value. - */ - public java.lang.CharSequence getName() { - return name; - } - - - /** - * Sets the value of the 'name' field. - * @param value The value of 'name'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.paymentfiat.Payer.Builder setName(java.lang.CharSequence value) { - validate(fields()[0], value); - this.name = value; - fieldSetFlags()[0] = true; - return this; - } - - /** - * Checks whether the 'name' field has been set. - * @return True if the 'name' field has been set, false otherwise. - */ - public boolean hasName() { - return fieldSetFlags()[0]; - } - - - /** - * Clears the value of the 'name' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.paymentfiat.Payer.Builder clearName() { - name = null; - fieldSetFlags()[0] = false; - return this; - } - - /** - * Gets the value of the 'payerType' field. - * @return The value. - */ - public java.lang.CharSequence getPayerType() { - return payerType; - } - - - /** - * Sets the value of the 'payerType' field. - * @param value The value of 'payerType'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.paymentfiat.Payer.Builder setPayerType(java.lang.CharSequence value) { - validate(fields()[1], value); - this.payerType = value; - fieldSetFlags()[1] = true; - return this; - } - - /** - * Checks whether the 'payerType' field has been set. - * @return True if the 'payerType' field has been set, false otherwise. - */ - public boolean hasPayerType() { - return fieldSetFlags()[1]; - } - - - /** - * Clears the value of the 'payerType' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.paymentfiat.Payer.Builder clearPayerType() { - payerType = null; - fieldSetFlags()[1] = false; - return this; - } - - /** - * Gets the value of the 'accountNumber' field. - * @return The value. - */ - public java.lang.CharSequence getAccountNumber() { - return accountNumber; - } - - - /** - * Sets the value of the 'accountNumber' field. - * @param value The value of 'accountNumber'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.paymentfiat.Payer.Builder setAccountNumber(java.lang.CharSequence value) { - validate(fields()[2], value); - this.accountNumber = value; - fieldSetFlags()[2] = true; - return this; - } - - /** - * Checks whether the 'accountNumber' field has been set. - * @return True if the 'accountNumber' field has been set, false otherwise. - */ - public boolean hasAccountNumber() { - return fieldSetFlags()[2]; - } - - - /** - * Clears the value of the 'accountNumber' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.paymentfiat.Payer.Builder clearAccountNumber() { - accountNumber = null; - fieldSetFlags()[2] = false; - return this; - } - - /** - * Gets the value of the 'bank' field. - * @return The value. - */ - public java.lang.CharSequence getBank() { - return bank; - } - - - /** - * Sets the value of the 'bank' field. - * @param value The value of 'bank'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.paymentfiat.Payer.Builder setBank(java.lang.CharSequence value) { - validate(fields()[3], value); - this.bank = value; - fieldSetFlags()[3] = true; - return this; - } - - /** - * Checks whether the 'bank' field has been set. - * @return True if the 'bank' field has been set, false otherwise. - */ - public boolean hasBank() { - return fieldSetFlags()[3]; - } - - - /** - * Clears the value of the 'bank' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.paymentfiat.Payer.Builder clearBank() { - bank = null; - fieldSetFlags()[3] = false; - return this; - } - - /** - * Gets the value of the 'billingAddress' field. - * @return The value. - */ - public io.skodjob.datagenerator.models.paymentfiat.Address getBillingAddress() { - return billingAddress; - } - - - /** - * Sets the value of the 'billingAddress' field. - * @param value The value of 'billingAddress'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.paymentfiat.Payer.Builder setBillingAddress(io.skodjob.datagenerator.models.paymentfiat.Address value) { - validate(fields()[4], value); - this.billingAddressBuilder = null; - this.billingAddress = value; - fieldSetFlags()[4] = true; - return this; - } - - /** - * Checks whether the 'billingAddress' field has been set. - * @return True if the 'billingAddress' field has been set, false otherwise. - */ - public boolean hasBillingAddress() { - return fieldSetFlags()[4]; - } - - /** - * Gets the Builder instance for the 'billingAddress' field and creates one if it doesn't exist yet. - * @return This builder. - */ - public io.skodjob.datagenerator.models.paymentfiat.Address.Builder getBillingAddressBuilder() { - if (billingAddressBuilder == null) { - if (hasBillingAddress()) { - setBillingAddressBuilder(io.skodjob.datagenerator.models.paymentfiat.Address.newBuilder(billingAddress)); - } else { - setBillingAddressBuilder(io.skodjob.datagenerator.models.paymentfiat.Address.newBuilder()); - } - } - return billingAddressBuilder; - } - - /** - * Sets the Builder instance for the 'billingAddress' field - * @param value The builder instance that must be set. - * @return This builder. - */ - - public io.skodjob.datagenerator.models.paymentfiat.Payer.Builder setBillingAddressBuilder(io.skodjob.datagenerator.models.paymentfiat.Address.Builder value) { - clearBillingAddress(); - billingAddressBuilder = value; - return this; - } - - /** - * Checks whether the 'billingAddress' field has an active Builder instance - * @return True if the 'billingAddress' field has an active Builder instance - */ - public boolean hasBillingAddressBuilder() { - return billingAddressBuilder != null; - } - - /** - * Clears the value of the 'billingAddress' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.paymentfiat.Payer.Builder clearBillingAddress() { - billingAddress = null; - billingAddressBuilder = null; - fieldSetFlags()[4] = false; - return this; - } - - /** - * Gets the value of the 'cardNumber' field. - * @return The value. - */ - public java.lang.CharSequence getCardNumber() { - return cardNumber; - } - - - /** - * Sets the value of the 'cardNumber' field. - * @param value The value of 'cardNumber'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.paymentfiat.Payer.Builder setCardNumber(java.lang.CharSequence value) { - validate(fields()[5], value); - this.cardNumber = value; - fieldSetFlags()[5] = true; - return this; - } - - /** - * Checks whether the 'cardNumber' field has been set. - * @return True if the 'cardNumber' field has been set, false otherwise. - */ - public boolean hasCardNumber() { - return fieldSetFlags()[5]; - } - - - /** - * Clears the value of the 'cardNumber' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.paymentfiat.Payer.Builder clearCardNumber() { - cardNumber = null; - fieldSetFlags()[5] = false; - return this; - } - - /** - * Gets the value of the 'cardType' field. - * @return The value. - */ - public java.lang.CharSequence getCardType() { - return cardType; - } - - - /** - * Sets the value of the 'cardType' field. - * @param value The value of 'cardType'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.paymentfiat.Payer.Builder setCardType(java.lang.CharSequence value) { - validate(fields()[6], value); - this.cardType = value; - fieldSetFlags()[6] = true; - return this; - } - - /** - * Checks whether the 'cardType' field has been set. - * @return True if the 'cardType' field has been set, false otherwise. - */ - public boolean hasCardType() { - return fieldSetFlags()[6]; - } - - - /** - * Clears the value of the 'cardType' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.paymentfiat.Payer.Builder clearCardType() { - cardType = null; - fieldSetFlags()[6] = false; - return this; - } - - /** - * Gets the value of the 'expiryDate' field. - * @return The value. - */ - public java.lang.CharSequence getExpiryDate() { - return expiryDate; - } - - - /** - * Sets the value of the 'expiryDate' field. - * @param value The value of 'expiryDate'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.paymentfiat.Payer.Builder setExpiryDate(java.lang.CharSequence value) { - validate(fields()[7], value); - this.expiryDate = value; - fieldSetFlags()[7] = true; - return this; - } - - /** - * Checks whether the 'expiryDate' field has been set. - * @return True if the 'expiryDate' field has been set, false otherwise. - */ - public boolean hasExpiryDate() { - return fieldSetFlags()[7]; - } - - - /** - * Clears the value of the 'expiryDate' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.paymentfiat.Payer.Builder clearExpiryDate() { - expiryDate = null; - fieldSetFlags()[7] = false; - return this; - } - - @Override - @SuppressWarnings("unchecked") - public Payer build() { - try { - Payer record = new Payer(); - record.name = fieldSetFlags()[0] ? this.name : (java.lang.CharSequence) defaultValue(fields()[0]); - record.payerType = fieldSetFlags()[1] ? this.payerType : (java.lang.CharSequence) defaultValue(fields()[1]); - record.accountNumber = fieldSetFlags()[2] ? this.accountNumber : (java.lang.CharSequence) defaultValue(fields()[2]); - record.bank = fieldSetFlags()[3] ? this.bank : (java.lang.CharSequence) defaultValue(fields()[3]); - if (billingAddressBuilder != null) { - try { - record.billingAddress = this.billingAddressBuilder.build(); - } catch (org.apache.avro.AvroMissingFieldException e) { - e.addParentField(record.getSchema().getField("billingAddress")); - throw e; - } - } else { - record.billingAddress = fieldSetFlags()[4] ? this.billingAddress : (io.skodjob.datagenerator.models.paymentfiat.Address) defaultValue(fields()[4]); - } - record.cardNumber = fieldSetFlags()[5] ? this.cardNumber : (java.lang.CharSequence) defaultValue(fields()[5]); - record.cardType = fieldSetFlags()[6] ? this.cardType : (java.lang.CharSequence) defaultValue(fields()[6]); - record.expiryDate = fieldSetFlags()[7] ? this.expiryDate : (java.lang.CharSequence) defaultValue(fields()[7]); - return record; - } catch (org.apache.avro.AvroMissingFieldException e) { - throw e; - } catch (java.lang.Exception e) { - throw new org.apache.avro.AvroRuntimeException(e); - } - } - } - - @SuppressWarnings("unchecked") - private static final org.apache.avro.io.DatumWriter - WRITER$ = (org.apache.avro.io.DatumWriter)MODEL$.createDatumWriter(SCHEMA$); - - @Override public void writeExternal(java.io.ObjectOutput out) - throws java.io.IOException { - WRITER$.write(this, SpecificData.getEncoder(out)); - } - - @SuppressWarnings("unchecked") - private static final org.apache.avro.io.DatumReader - READER$ = (org.apache.avro.io.DatumReader)MODEL$.createDatumReader(SCHEMA$); - - @Override public void readExternal(java.io.ObjectInput in) - throws java.io.IOException { - READER$.read(this, SpecificData.getDecoder(in)); - } - - @Override protected boolean hasCustomCoders() { return true; } - - @Override public void customEncode(org.apache.avro.io.Encoder out) - throws java.io.IOException - { - out.writeString(this.name); - - out.writeString(this.payerType); - - out.writeString(this.accountNumber); - - out.writeString(this.bank); - - this.billingAddress.customEncode(out); - - if (this.cardNumber == null) { - out.writeIndex(0); - out.writeNull(); - } else { - out.writeIndex(1); - out.writeString(this.cardNumber); - } - - if (this.cardType == null) { - out.writeIndex(0); - out.writeNull(); - } else { - out.writeIndex(1); - out.writeString(this.cardType); - } - - if (this.expiryDate == null) { - out.writeIndex(0); - out.writeNull(); - } else { - out.writeIndex(1); - out.writeString(this.expiryDate); - } - - } - - @Override public void customDecode(org.apache.avro.io.ResolvingDecoder in) - throws java.io.IOException - { - org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff(); - if (fieldOrder == null) { - this.name = in.readString(this.name instanceof Utf8 ? (Utf8)this.name : null); - - this.payerType = in.readString(this.payerType instanceof Utf8 ? (Utf8)this.payerType : null); - - this.accountNumber = in.readString(this.accountNumber instanceof Utf8 ? (Utf8)this.accountNumber : null); - - this.bank = in.readString(this.bank instanceof Utf8 ? (Utf8)this.bank : null); - - if (this.billingAddress == null) { - this.billingAddress = new io.skodjob.datagenerator.models.paymentfiat.Address(); - } - this.billingAddress.customDecode(in); - - if (in.readIndex() != 1) { - in.readNull(); - this.cardNumber = null; - } else { - this.cardNumber = in.readString(this.cardNumber instanceof Utf8 ? (Utf8)this.cardNumber : null); - } - - if (in.readIndex() != 1) { - in.readNull(); - this.cardType = null; - } else { - this.cardType = in.readString(this.cardType instanceof Utf8 ? (Utf8)this.cardType : null); - } - - if (in.readIndex() != 1) { - in.readNull(); - this.expiryDate = null; - } else { - this.expiryDate = in.readString(this.expiryDate instanceof Utf8 ? (Utf8)this.expiryDate : null); - } - - } else { - for (int i = 0; i < 8; i++) { - switch (fieldOrder[i].pos()) { - case 0: - this.name = in.readString(this.name instanceof Utf8 ? (Utf8)this.name : null); - break; - - case 1: - this.payerType = in.readString(this.payerType instanceof Utf8 ? (Utf8)this.payerType : null); - break; - - case 2: - this.accountNumber = in.readString(this.accountNumber instanceof Utf8 ? (Utf8)this.accountNumber : null); - break; - - case 3: - this.bank = in.readString(this.bank instanceof Utf8 ? (Utf8)this.bank : null); - break; - - case 4: - if (this.billingAddress == null) { - this.billingAddress = new io.skodjob.datagenerator.models.paymentfiat.Address(); - } - this.billingAddress.customDecode(in); - break; - - case 5: - if (in.readIndex() != 1) { - in.readNull(); - this.cardNumber = null; - } else { - this.cardNumber = in.readString(this.cardNumber instanceof Utf8 ? (Utf8)this.cardNumber : null); - } - break; - - case 6: - if (in.readIndex() != 1) { - in.readNull(); - this.cardType = null; - } else { - this.cardType = in.readString(this.cardType instanceof Utf8 ? (Utf8)this.cardType : null); - } - break; - - case 7: - if (in.readIndex() != 1) { - in.readNull(); - this.expiryDate = null; - } else { - this.expiryDate = in.readString(this.expiryDate instanceof Utf8 ? (Utf8)this.expiryDate : null); - } - break; - - default: - throw new java.io.IOException("Corrupt ResolvingDecoder."); - } - } - } - } -} - - - - - - - - - - diff --git a/src/main/java/io/skodjob/datagenerator/models/paymentfiat/Payment.java b/src/main/java/io/skodjob/datagenerator/models/paymentfiat/Payment.java deleted file mode 100644 index 3904239..0000000 --- a/src/main/java/io/skodjob/datagenerator/models/paymentfiat/Payment.java +++ /dev/null @@ -1,717 +0,0 @@ -/** - * Autogenerated by Avro - * - * DO NOT EDIT DIRECTLY - */ -package io.skodjob.datagenerator.models.paymentfiat; - -import org.apache.avro.specific.SpecificData; -import org.apache.avro.util.Utf8; -import org.apache.avro.message.BinaryMessageEncoder; -import org.apache.avro.message.BinaryMessageDecoder; -import org.apache.avro.message.SchemaStore; - -@org.apache.avro.specific.AvroGenerated -public class Payment extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord { - private static final long serialVersionUID = 12828759078550806L; - - - public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"Payment\",\"namespace\":\"io.skodjob.datagenerator.models\",\"fields\":[{\"name\":\"transactionId\",\"type\":\"string\"},{\"name\":\"type\",\"type\":\"string\"},{\"name\":\"amount\",\"type\":\"double\"},{\"name\":\"currency\",\"type\":\"string\"},{\"name\":\"date\",\"type\":\"string\"},{\"name\":\"status\",\"type\":\"string\"}]}"); - public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } - - private static final SpecificData MODEL$ = new SpecificData(); - - private static final BinaryMessageEncoder ENCODER = - new BinaryMessageEncoder<>(MODEL$, SCHEMA$); - - private static final BinaryMessageDecoder DECODER = - new BinaryMessageDecoder<>(MODEL$, SCHEMA$); - - /** - * Return the BinaryMessageEncoder instance used by this class. - * @return the message encoder used by this class - */ - public static BinaryMessageEncoder getEncoder() { - return ENCODER; - } - - /** - * Return the BinaryMessageDecoder instance used by this class. - * @return the message decoder used by this class - */ - public static BinaryMessageDecoder getDecoder() { - return DECODER; - } - - /** - * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}. - * @param resolver a {@link SchemaStore} used to find schemas by fingerprint - * @return a BinaryMessageDecoder instance for this class backed by the given SchemaStore - */ - public static BinaryMessageDecoder createDecoder(SchemaStore resolver) { - return new BinaryMessageDecoder<>(MODEL$, SCHEMA$, resolver); - } - - /** - * Serializes this Payment to a ByteBuffer. - * @return a buffer holding the serialized data for this instance - * @throws java.io.IOException if this instance could not be serialized - */ - public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException { - return ENCODER.encode(this); - } - - /** - * Deserializes a Payment from a ByteBuffer. - * @param b a byte buffer holding serialized data for an instance of this class - * @return a Payment instance decoded from the given buffer - * @throws java.io.IOException if the given bytes could not be deserialized into an instance of this class - */ - public static Payment fromByteBuffer( - java.nio.ByteBuffer b) throws java.io.IOException { - return DECODER.decode(b); - } - - private java.lang.CharSequence transactionId; - private java.lang.CharSequence type; - private double amount; - private java.lang.CharSequence currency; - private java.lang.CharSequence date; - private java.lang.CharSequence status; - - /** - * Default constructor. Note that this does not initialize fields - * to their default values from the schema. If that is desired then - * one should use newBuilder(). - */ - public Payment() {} - - /** - * All-args constructor. - * @param transactionId The new value for transactionId - * @param type The new value for type - * @param amount The new value for amount - * @param currency The new value for currency - * @param date The new value for date - * @param status The new value for status - */ - public Payment(java.lang.CharSequence transactionId, java.lang.CharSequence type, java.lang.Double amount, java.lang.CharSequence currency, java.lang.CharSequence date, java.lang.CharSequence status) { - this.transactionId = transactionId; - this.type = type; - this.amount = amount; - this.currency = currency; - this.date = date; - this.status = status; - } - - @Override - public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; } - - @Override - public org.apache.avro.Schema getSchema() { return SCHEMA$; } - - // Used by DatumWriter. Applications should not call. - @Override - public java.lang.Object get(int field$) { - switch (field$) { - case 0: return transactionId; - case 1: return type; - case 2: return amount; - case 3: return currency; - case 4: return date; - case 5: return status; - default: throw new IndexOutOfBoundsException("Invalid index: " + field$); - } - } - - // Used by DatumReader. Applications should not call. - @Override - @SuppressWarnings(value="unchecked") - public void put(int field$, java.lang.Object value$) { - switch (field$) { - case 0: transactionId = (java.lang.CharSequence)value$; break; - case 1: type = (java.lang.CharSequence)value$; break; - case 2: amount = (java.lang.Double)value$; break; - case 3: currency = (java.lang.CharSequence)value$; break; - case 4: date = (java.lang.CharSequence)value$; break; - case 5: status = (java.lang.CharSequence)value$; break; - default: throw new IndexOutOfBoundsException("Invalid index: " + field$); - } - } - - /** - * Gets the value of the 'transactionId' field. - * @return The value of the 'transactionId' field. - */ - public java.lang.CharSequence getTransactionId() { - return transactionId; - } - - - /** - * Sets the value of the 'transactionId' field. - * @param value the value to set. - */ - public void setTransactionId(java.lang.CharSequence value) { - this.transactionId = value; - } - - /** - * Gets the value of the 'type' field. - * @return The value of the 'type' field. - */ - public java.lang.CharSequence getType() { - return type; - } - - - /** - * Sets the value of the 'type' field. - * @param value the value to set. - */ - public void setType(java.lang.CharSequence value) { - this.type = value; - } - - /** - * Gets the value of the 'amount' field. - * @return The value of the 'amount' field. - */ - public double getAmount() { - return amount; - } - - - /** - * Sets the value of the 'amount' field. - * @param value the value to set. - */ - public void setAmount(double value) { - this.amount = value; - } - - /** - * Gets the value of the 'currency' field. - * @return The value of the 'currency' field. - */ - public java.lang.CharSequence getCurrency() { - return currency; - } - - - /** - * Sets the value of the 'currency' field. - * @param value the value to set. - */ - public void setCurrency(java.lang.CharSequence value) { - this.currency = value; - } - - /** - * Gets the value of the 'date' field. - * @return The value of the 'date' field. - */ - public java.lang.CharSequence getDate() { - return date; - } - - - /** - * Sets the value of the 'date' field. - * @param value the value to set. - */ - public void setDate(java.lang.CharSequence value) { - this.date = value; - } - - /** - * Gets the value of the 'status' field. - * @return The value of the 'status' field. - */ - public java.lang.CharSequence getStatus() { - return status; - } - - - /** - * Sets the value of the 'status' field. - * @param value the value to set. - */ - public void setStatus(java.lang.CharSequence value) { - this.status = value; - } - - /** - * Creates a new Payment RecordBuilder. - * @return A new Payment RecordBuilder - */ - public static Payment.Builder newBuilder() { - return new Payment.Builder(); - } - - /** - * Creates a new Payment RecordBuilder by copying an existing Builder. - * @param other The existing builder to copy. - * @return A new Payment RecordBuilder - */ - public static Payment.Builder newBuilder(Payment.Builder other) { - if (other == null) { - return new Payment.Builder(); - } else { - return new Payment.Builder(other); - } - } - - /** - * Creates a new Payment RecordBuilder by copying an existing Payment instance. - * @param other The existing instance to copy. - * @return A new Payment RecordBuilder - */ - public static Payment.Builder newBuilder(Payment other) { - if (other == null) { - return new Payment.Builder(); - } else { - return new Payment.Builder(other); - } - } - - /** - * RecordBuilder for Payment instances. - */ - @org.apache.avro.specific.AvroGenerated - public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase - implements org.apache.avro.data.RecordBuilder { - - private java.lang.CharSequence transactionId; - private java.lang.CharSequence type; - private double amount; - private java.lang.CharSequence currency; - private java.lang.CharSequence date; - private java.lang.CharSequence status; - - /** Creates a new Builder */ - private Builder() { - super(SCHEMA$, MODEL$); - } - - /** - * Creates a Builder by copying an existing Builder. - * @param other The existing Builder to copy. - */ - private Builder(Payment.Builder other) { - super(other); - if (isValidValue(fields()[0], other.transactionId)) { - this.transactionId = data().deepCopy(fields()[0].schema(), other.transactionId); - fieldSetFlags()[0] = other.fieldSetFlags()[0]; - } - if (isValidValue(fields()[1], other.type)) { - this.type = data().deepCopy(fields()[1].schema(), other.type); - fieldSetFlags()[1] = other.fieldSetFlags()[1]; - } - if (isValidValue(fields()[2], other.amount)) { - this.amount = data().deepCopy(fields()[2].schema(), other.amount); - fieldSetFlags()[2] = other.fieldSetFlags()[2]; - } - if (isValidValue(fields()[3], other.currency)) { - this.currency = data().deepCopy(fields()[3].schema(), other.currency); - fieldSetFlags()[3] = other.fieldSetFlags()[3]; - } - if (isValidValue(fields()[4], other.date)) { - this.date = data().deepCopy(fields()[4].schema(), other.date); - fieldSetFlags()[4] = other.fieldSetFlags()[4]; - } - if (isValidValue(fields()[5], other.status)) { - this.status = data().deepCopy(fields()[5].schema(), other.status); - fieldSetFlags()[5] = other.fieldSetFlags()[5]; - } - } - - /** - * Creates a Builder by copying an existing Payment instance - * @param other The existing instance to copy. - */ - private Builder(Payment other) { - super(SCHEMA$, MODEL$); - if (isValidValue(fields()[0], other.transactionId)) { - this.transactionId = data().deepCopy(fields()[0].schema(), other.transactionId); - fieldSetFlags()[0] = true; - } - if (isValidValue(fields()[1], other.type)) { - this.type = data().deepCopy(fields()[1].schema(), other.type); - fieldSetFlags()[1] = true; - } - if (isValidValue(fields()[2], other.amount)) { - this.amount = data().deepCopy(fields()[2].schema(), other.amount); - fieldSetFlags()[2] = true; - } - if (isValidValue(fields()[3], other.currency)) { - this.currency = data().deepCopy(fields()[3].schema(), other.currency); - fieldSetFlags()[3] = true; - } - if (isValidValue(fields()[4], other.date)) { - this.date = data().deepCopy(fields()[4].schema(), other.date); - fieldSetFlags()[4] = true; - } - if (isValidValue(fields()[5], other.status)) { - this.status = data().deepCopy(fields()[5].schema(), other.status); - fieldSetFlags()[5] = true; - } - } - - /** - * Gets the value of the 'transactionId' field. - * @return The value. - */ - public java.lang.CharSequence getTransactionId() { - return transactionId; - } - - - /** - * Sets the value of the 'transactionId' field. - * @param value The value of 'transactionId'. - * @return This builder. - */ - public Payment.Builder setTransactionId(java.lang.CharSequence value) { - validate(fields()[0], value); - this.transactionId = value; - fieldSetFlags()[0] = true; - return this; - } - - /** - * Checks whether the 'transactionId' field has been set. - * @return True if the 'transactionId' field has been set, false otherwise. - */ - public boolean hasTransactionId() { - return fieldSetFlags()[0]; - } - - - /** - * Clears the value of the 'transactionId' field. - * @return This builder. - */ - public Payment.Builder clearTransactionId() { - transactionId = null; - fieldSetFlags()[0] = false; - return this; - } - - /** - * Gets the value of the 'type' field. - * @return The value. - */ - public java.lang.CharSequence getType() { - return type; - } - - - /** - * Sets the value of the 'type' field. - * @param value The value of 'type'. - * @return This builder. - */ - public Payment.Builder setType(java.lang.CharSequence value) { - validate(fields()[1], value); - this.type = value; - fieldSetFlags()[1] = true; - return this; - } - - /** - * Checks whether the 'type' field has been set. - * @return True if the 'type' field has been set, false otherwise. - */ - public boolean hasType() { - return fieldSetFlags()[1]; - } - - - /** - * Clears the value of the 'type' field. - * @return This builder. - */ - public Payment.Builder clearType() { - type = null; - fieldSetFlags()[1] = false; - return this; - } - - /** - * Gets the value of the 'amount' field. - * @return The value. - */ - public double getAmount() { - return amount; - } - - - /** - * Sets the value of the 'amount' field. - * @param value The value of 'amount'. - * @return This builder. - */ - public Payment.Builder setAmount(double value) { - validate(fields()[2], value); - this.amount = value; - fieldSetFlags()[2] = true; - return this; - } - - /** - * Checks whether the 'amount' field has been set. - * @return True if the 'amount' field has been set, false otherwise. - */ - public boolean hasAmount() { - return fieldSetFlags()[2]; - } - - - /** - * Clears the value of the 'amount' field. - * @return This builder. - */ - public Payment.Builder clearAmount() { - fieldSetFlags()[2] = false; - return this; - } - - /** - * Gets the value of the 'currency' field. - * @return The value. - */ - public java.lang.CharSequence getCurrency() { - return currency; - } - - - /** - * Sets the value of the 'currency' field. - * @param value The value of 'currency'. - * @return This builder. - */ - public Payment.Builder setCurrency(java.lang.CharSequence value) { - validate(fields()[3], value); - this.currency = value; - fieldSetFlags()[3] = true; - return this; - } - - /** - * Checks whether the 'currency' field has been set. - * @return True if the 'currency' field has been set, false otherwise. - */ - public boolean hasCurrency() { - return fieldSetFlags()[3]; - } - - - /** - * Clears the value of the 'currency' field. - * @return This builder. - */ - public Payment.Builder clearCurrency() { - currency = null; - fieldSetFlags()[3] = false; - return this; - } - - /** - * Gets the value of the 'date' field. - * @return The value. - */ - public java.lang.CharSequence getDate() { - return date; - } - - - /** - * Sets the value of the 'date' field. - * @param value The value of 'date'. - * @return This builder. - */ - public Payment.Builder setDate(java.lang.CharSequence value) { - validate(fields()[4], value); - this.date = value; - fieldSetFlags()[4] = true; - return this; - } - - /** - * Checks whether the 'date' field has been set. - * @return True if the 'date' field has been set, false otherwise. - */ - public boolean hasDate() { - return fieldSetFlags()[4]; - } - - - /** - * Clears the value of the 'date' field. - * @return This builder. - */ - public Payment.Builder clearDate() { - date = null; - fieldSetFlags()[4] = false; - return this; - } - - /** - * Gets the value of the 'status' field. - * @return The value. - */ - public java.lang.CharSequence getStatus() { - return status; - } - - - /** - * Sets the value of the 'status' field. - * @param value The value of 'status'. - * @return This builder. - */ - public Payment.Builder setStatus(java.lang.CharSequence value) { - validate(fields()[5], value); - this.status = value; - fieldSetFlags()[5] = true; - return this; - } - - /** - * Checks whether the 'status' field has been set. - * @return True if the 'status' field has been set, false otherwise. - */ - public boolean hasStatus() { - return fieldSetFlags()[5]; - } - - - /** - * Clears the value of the 'status' field. - * @return This builder. - */ - public Payment.Builder clearStatus() { - status = null; - fieldSetFlags()[5] = false; - return this; - } - - @Override - @SuppressWarnings("unchecked") - public Payment build() { - try { - Payment record = new Payment(); - record.transactionId = fieldSetFlags()[0] ? this.transactionId : (java.lang.CharSequence) defaultValue(fields()[0]); - record.type = fieldSetFlags()[1] ? this.type : (java.lang.CharSequence) defaultValue(fields()[1]); - record.amount = fieldSetFlags()[2] ? this.amount : (java.lang.Double) defaultValue(fields()[2]); - record.currency = fieldSetFlags()[3] ? this.currency : (java.lang.CharSequence) defaultValue(fields()[3]); - record.date = fieldSetFlags()[4] ? this.date : (java.lang.CharSequence) defaultValue(fields()[4]); - record.status = fieldSetFlags()[5] ? this.status : (java.lang.CharSequence) defaultValue(fields()[5]); - return record; - } catch (org.apache.avro.AvroMissingFieldException e) { - throw e; - } catch (java.lang.Exception e) { - throw new org.apache.avro.AvroRuntimeException(e); - } - } - } - - @SuppressWarnings("unchecked") - private static final org.apache.avro.io.DatumWriter - WRITER$ = (org.apache.avro.io.DatumWriter)MODEL$.createDatumWriter(SCHEMA$); - - @Override public void writeExternal(java.io.ObjectOutput out) - throws java.io.IOException { - WRITER$.write(this, SpecificData.getEncoder(out)); - } - - @SuppressWarnings("unchecked") - private static final org.apache.avro.io.DatumReader - READER$ = (org.apache.avro.io.DatumReader)MODEL$.createDatumReader(SCHEMA$); - - @Override public void readExternal(java.io.ObjectInput in) - throws java.io.IOException { - READER$.read(this, SpecificData.getDecoder(in)); - } - - @Override protected boolean hasCustomCoders() { return true; } - - @Override public void customEncode(org.apache.avro.io.Encoder out) - throws java.io.IOException - { - out.writeString(this.transactionId); - - out.writeString(this.type); - - out.writeDouble(this.amount); - - out.writeString(this.currency); - - out.writeString(this.date); - - out.writeString(this.status); - - } - - @Override public void customDecode(org.apache.avro.io.ResolvingDecoder in) - throws java.io.IOException - { - org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff(); - if (fieldOrder == null) { - this.transactionId = in.readString(this.transactionId instanceof Utf8 ? (Utf8)this.transactionId : null); - - this.type = in.readString(this.type instanceof Utf8 ? (Utf8)this.type : null); - - this.amount = in.readDouble(); - - this.currency = in.readString(this.currency instanceof Utf8 ? (Utf8)this.currency : null); - - this.date = in.readString(this.date instanceof Utf8 ? (Utf8)this.date : null); - - this.status = in.readString(this.status instanceof Utf8 ? (Utf8)this.status : null); - - } else { - for (int i = 0; i < 6; i++) { - switch (fieldOrder[i].pos()) { - case 0: - this.transactionId = in.readString(this.transactionId instanceof Utf8 ? (Utf8)this.transactionId : null); - break; - - case 1: - this.type = in.readString(this.type instanceof Utf8 ? (Utf8)this.type : null); - break; - - case 2: - this.amount = in.readDouble(); - break; - - case 3: - this.currency = in.readString(this.currency instanceof Utf8 ? (Utf8)this.currency : null); - break; - - case 4: - this.date = in.readString(this.date instanceof Utf8 ? (Utf8)this.date : null); - break; - - case 5: - this.status = in.readString(this.status instanceof Utf8 ? (Utf8)this.status : null); - break; - - default: - throw new java.io.IOException("Corrupt ResolvingDecoder."); - } - } - } - } -} - - - - - - - - - - diff --git a/src/main/java/io/skodjob/datagenerator/models/paymentfiat/PaymentDetails.java b/src/main/java/io/skodjob/datagenerator/models/paymentfiat/PaymentDetails.java deleted file mode 100644 index c948a0f..0000000 --- a/src/main/java/io/skodjob/datagenerator/models/paymentfiat/PaymentDetails.java +++ /dev/null @@ -1,717 +0,0 @@ -/** - * Autogenerated by Avro - * - * DO NOT EDIT DIRECTLY - */ -package io.skodjob.datagenerator.models.paymentfiat; - -import org.apache.avro.specific.SpecificData; -import org.apache.avro.util.Utf8; -import org.apache.avro.message.BinaryMessageEncoder; -import org.apache.avro.message.BinaryMessageDecoder; -import org.apache.avro.message.SchemaStore; - -@org.apache.avro.specific.AvroGenerated -public class PaymentDetails extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord { - private static final long serialVersionUID = -5774604774004341124L; - - - public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"PaymentDetails\",\"namespace\":\"io.skodjob.datagenerator.models\",\"fields\":[{\"name\":\"transactionId\",\"type\":\"string\"},{\"name\":\"type\",\"type\":\"string\"},{\"name\":\"amount\",\"type\":\"double\"},{\"name\":\"currency\",\"type\":\"string\"},{\"name\":\"date\",\"type\":\"string\"},{\"name\":\"status\",\"type\":\"string\"}]}"); - public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } - - private static final SpecificData MODEL$ = new SpecificData(); - - private static final BinaryMessageEncoder ENCODER = - new BinaryMessageEncoder<>(MODEL$, SCHEMA$); - - private static final BinaryMessageDecoder DECODER = - new BinaryMessageDecoder<>(MODEL$, SCHEMA$); - - /** - * Return the BinaryMessageEncoder instance used by this class. - * @return the message encoder used by this class - */ - public static BinaryMessageEncoder getEncoder() { - return ENCODER; - } - - /** - * Return the BinaryMessageDecoder instance used by this class. - * @return the message decoder used by this class - */ - public static BinaryMessageDecoder getDecoder() { - return DECODER; - } - - /** - * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}. - * @param resolver a {@link SchemaStore} used to find schemas by fingerprint - * @return a BinaryMessageDecoder instance for this class backed by the given SchemaStore - */ - public static BinaryMessageDecoder createDecoder(SchemaStore resolver) { - return new BinaryMessageDecoder<>(MODEL$, SCHEMA$, resolver); - } - - /** - * Serializes this PaymentDetails to a ByteBuffer. - * @return a buffer holding the serialized data for this instance - * @throws java.io.IOException if this instance could not be serialized - */ - public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException { - return ENCODER.encode(this); - } - - /** - * Deserializes a PaymentDetails from a ByteBuffer. - * @param b a byte buffer holding serialized data for an instance of this class - * @return a PaymentDetails instance decoded from the given buffer - * @throws java.io.IOException if the given bytes could not be deserialized into an instance of this class - */ - public static PaymentDetails fromByteBuffer( - java.nio.ByteBuffer b) throws java.io.IOException { - return DECODER.decode(b); - } - - private java.lang.CharSequence transactionId; - private java.lang.CharSequence type; - private double amount; - private java.lang.CharSequence currency; - private java.lang.CharSequence date; - private java.lang.CharSequence status; - - /** - * Default constructor. Note that this does not initialize fields - * to their default values from the schema. If that is desired then - * one should use newBuilder(). - */ - public PaymentDetails() {} - - /** - * All-args constructor. - * @param transactionId The new value for transactionId - * @param type The new value for type - * @param amount The new value for amount - * @param currency The new value for currency - * @param date The new value for date - * @param status The new value for status - */ - public PaymentDetails(java.lang.CharSequence transactionId, java.lang.CharSequence type, java.lang.Double amount, java.lang.CharSequence currency, java.lang.CharSequence date, java.lang.CharSequence status) { - this.transactionId = transactionId; - this.type = type; - this.amount = amount; - this.currency = currency; - this.date = date; - this.status = status; - } - - @Override - public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; } - - @Override - public org.apache.avro.Schema getSchema() { return SCHEMA$; } - - // Used by DatumWriter. Applications should not call. - @Override - public java.lang.Object get(int field$) { - switch (field$) { - case 0: return transactionId; - case 1: return type; - case 2: return amount; - case 3: return currency; - case 4: return date; - case 5: return status; - default: throw new IndexOutOfBoundsException("Invalid index: " + field$); - } - } - - // Used by DatumReader. Applications should not call. - @Override - @SuppressWarnings(value="unchecked") - public void put(int field$, java.lang.Object value$) { - switch (field$) { - case 0: transactionId = (java.lang.CharSequence)value$; break; - case 1: type = (java.lang.CharSequence)value$; break; - case 2: amount = (java.lang.Double)value$; break; - case 3: currency = (java.lang.CharSequence)value$; break; - case 4: date = (java.lang.CharSequence)value$; break; - case 5: status = (java.lang.CharSequence)value$; break; - default: throw new IndexOutOfBoundsException("Invalid index: " + field$); - } - } - - /** - * Gets the value of the 'transactionId' field. - * @return The value of the 'transactionId' field. - */ - public java.lang.CharSequence getTransactionId() { - return transactionId; - } - - - /** - * Sets the value of the 'transactionId' field. - * @param value the value to set. - */ - public void setTransactionId(java.lang.CharSequence value) { - this.transactionId = value; - } - - /** - * Gets the value of the 'type' field. - * @return The value of the 'type' field. - */ - public java.lang.CharSequence getType() { - return type; - } - - - /** - * Sets the value of the 'type' field. - * @param value the value to set. - */ - public void setType(java.lang.CharSequence value) { - this.type = value; - } - - /** - * Gets the value of the 'amount' field. - * @return The value of the 'amount' field. - */ - public double getAmount() { - return amount; - } - - - /** - * Sets the value of the 'amount' field. - * @param value the value to set. - */ - public void setAmount(double value) { - this.amount = value; - } - - /** - * Gets the value of the 'currency' field. - * @return The value of the 'currency' field. - */ - public java.lang.CharSequence getCurrency() { - return currency; - } - - - /** - * Sets the value of the 'currency' field. - * @param value the value to set. - */ - public void setCurrency(java.lang.CharSequence value) { - this.currency = value; - } - - /** - * Gets the value of the 'date' field. - * @return The value of the 'date' field. - */ - public java.lang.CharSequence getDate() { - return date; - } - - - /** - * Sets the value of the 'date' field. - * @param value the value to set. - */ - public void setDate(java.lang.CharSequence value) { - this.date = value; - } - - /** - * Gets the value of the 'status' field. - * @return The value of the 'status' field. - */ - public java.lang.CharSequence getStatus() { - return status; - } - - - /** - * Sets the value of the 'status' field. - * @param value the value to set. - */ - public void setStatus(java.lang.CharSequence value) { - this.status = value; - } - - /** - * Creates a new PaymentDetails RecordBuilder. - * @return A new PaymentDetails RecordBuilder - */ - public static PaymentDetails.Builder newBuilder() { - return new PaymentDetails.Builder(); - } - - /** - * Creates a new PaymentDetails RecordBuilder by copying an existing Builder. - * @param other The existing builder to copy. - * @return A new PaymentDetails RecordBuilder - */ - public static PaymentDetails.Builder newBuilder(PaymentDetails.Builder other) { - if (other == null) { - return new PaymentDetails.Builder(); - } else { - return new PaymentDetails.Builder(other); - } - } - - /** - * Creates a new PaymentDetails RecordBuilder by copying an existing PaymentDetails instance. - * @param other The existing instance to copy. - * @return A new PaymentDetails RecordBuilder - */ - public static PaymentDetails.Builder newBuilder(PaymentDetails other) { - if (other == null) { - return new PaymentDetails.Builder(); - } else { - return new PaymentDetails.Builder(other); - } - } - - /** - * RecordBuilder for PaymentDetails instances. - */ - @org.apache.avro.specific.AvroGenerated - public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase - implements org.apache.avro.data.RecordBuilder { - - private java.lang.CharSequence transactionId; - private java.lang.CharSequence type; - private double amount; - private java.lang.CharSequence currency; - private java.lang.CharSequence date; - private java.lang.CharSequence status; - - /** Creates a new Builder */ - private Builder() { - super(SCHEMA$, MODEL$); - } - - /** - * Creates a Builder by copying an existing Builder. - * @param other The existing Builder to copy. - */ - private Builder(PaymentDetails.Builder other) { - super(other); - if (isValidValue(fields()[0], other.transactionId)) { - this.transactionId = data().deepCopy(fields()[0].schema(), other.transactionId); - fieldSetFlags()[0] = other.fieldSetFlags()[0]; - } - if (isValidValue(fields()[1], other.type)) { - this.type = data().deepCopy(fields()[1].schema(), other.type); - fieldSetFlags()[1] = other.fieldSetFlags()[1]; - } - if (isValidValue(fields()[2], other.amount)) { - this.amount = data().deepCopy(fields()[2].schema(), other.amount); - fieldSetFlags()[2] = other.fieldSetFlags()[2]; - } - if (isValidValue(fields()[3], other.currency)) { - this.currency = data().deepCopy(fields()[3].schema(), other.currency); - fieldSetFlags()[3] = other.fieldSetFlags()[3]; - } - if (isValidValue(fields()[4], other.date)) { - this.date = data().deepCopy(fields()[4].schema(), other.date); - fieldSetFlags()[4] = other.fieldSetFlags()[4]; - } - if (isValidValue(fields()[5], other.status)) { - this.status = data().deepCopy(fields()[5].schema(), other.status); - fieldSetFlags()[5] = other.fieldSetFlags()[5]; - } - } - - /** - * Creates a Builder by copying an existing PaymentDetails instance - * @param other The existing instance to copy. - */ - private Builder(PaymentDetails other) { - super(SCHEMA$, MODEL$); - if (isValidValue(fields()[0], other.transactionId)) { - this.transactionId = data().deepCopy(fields()[0].schema(), other.transactionId); - fieldSetFlags()[0] = true; - } - if (isValidValue(fields()[1], other.type)) { - this.type = data().deepCopy(fields()[1].schema(), other.type); - fieldSetFlags()[1] = true; - } - if (isValidValue(fields()[2], other.amount)) { - this.amount = data().deepCopy(fields()[2].schema(), other.amount); - fieldSetFlags()[2] = true; - } - if (isValidValue(fields()[3], other.currency)) { - this.currency = data().deepCopy(fields()[3].schema(), other.currency); - fieldSetFlags()[3] = true; - } - if (isValidValue(fields()[4], other.date)) { - this.date = data().deepCopy(fields()[4].schema(), other.date); - fieldSetFlags()[4] = true; - } - if (isValidValue(fields()[5], other.status)) { - this.status = data().deepCopy(fields()[5].schema(), other.status); - fieldSetFlags()[5] = true; - } - } - - /** - * Gets the value of the 'transactionId' field. - * @return The value. - */ - public java.lang.CharSequence getTransactionId() { - return transactionId; - } - - - /** - * Sets the value of the 'transactionId' field. - * @param value The value of 'transactionId'. - * @return This builder. - */ - public PaymentDetails.Builder setTransactionId(java.lang.CharSequence value) { - validate(fields()[0], value); - this.transactionId = value; - fieldSetFlags()[0] = true; - return this; - } - - /** - * Checks whether the 'transactionId' field has been set. - * @return True if the 'transactionId' field has been set, false otherwise. - */ - public boolean hasTransactionId() { - return fieldSetFlags()[0]; - } - - - /** - * Clears the value of the 'transactionId' field. - * @return This builder. - */ - public PaymentDetails.Builder clearTransactionId() { - transactionId = null; - fieldSetFlags()[0] = false; - return this; - } - - /** - * Gets the value of the 'type' field. - * @return The value. - */ - public java.lang.CharSequence getType() { - return type; - } - - - /** - * Sets the value of the 'type' field. - * @param value The value of 'type'. - * @return This builder. - */ - public PaymentDetails.Builder setType(java.lang.CharSequence value) { - validate(fields()[1], value); - this.type = value; - fieldSetFlags()[1] = true; - return this; - } - - /** - * Checks whether the 'type' field has been set. - * @return True if the 'type' field has been set, false otherwise. - */ - public boolean hasType() { - return fieldSetFlags()[1]; - } - - - /** - * Clears the value of the 'type' field. - * @return This builder. - */ - public PaymentDetails.Builder clearType() { - type = null; - fieldSetFlags()[1] = false; - return this; - } - - /** - * Gets the value of the 'amount' field. - * @return The value. - */ - public double getAmount() { - return amount; - } - - - /** - * Sets the value of the 'amount' field. - * @param value The value of 'amount'. - * @return This builder. - */ - public PaymentDetails.Builder setAmount(double value) { - validate(fields()[2], value); - this.amount = value; - fieldSetFlags()[2] = true; - return this; - } - - /** - * Checks whether the 'amount' field has been set. - * @return True if the 'amount' field has been set, false otherwise. - */ - public boolean hasAmount() { - return fieldSetFlags()[2]; - } - - - /** - * Clears the value of the 'amount' field. - * @return This builder. - */ - public PaymentDetails.Builder clearAmount() { - fieldSetFlags()[2] = false; - return this; - } - - /** - * Gets the value of the 'currency' field. - * @return The value. - */ - public java.lang.CharSequence getCurrency() { - return currency; - } - - - /** - * Sets the value of the 'currency' field. - * @param value The value of 'currency'. - * @return This builder. - */ - public PaymentDetails.Builder setCurrency(java.lang.CharSequence value) { - validate(fields()[3], value); - this.currency = value; - fieldSetFlags()[3] = true; - return this; - } - - /** - * Checks whether the 'currency' field has been set. - * @return True if the 'currency' field has been set, false otherwise. - */ - public boolean hasCurrency() { - return fieldSetFlags()[3]; - } - - - /** - * Clears the value of the 'currency' field. - * @return This builder. - */ - public PaymentDetails.Builder clearCurrency() { - currency = null; - fieldSetFlags()[3] = false; - return this; - } - - /** - * Gets the value of the 'date' field. - * @return The value. - */ - public java.lang.CharSequence getDate() { - return date; - } - - - /** - * Sets the value of the 'date' field. - * @param value The value of 'date'. - * @return This builder. - */ - public PaymentDetails.Builder setDate(java.lang.CharSequence value) { - validate(fields()[4], value); - this.date = value; - fieldSetFlags()[4] = true; - return this; - } - - /** - * Checks whether the 'date' field has been set. - * @return True if the 'date' field has been set, false otherwise. - */ - public boolean hasDate() { - return fieldSetFlags()[4]; - } - - - /** - * Clears the value of the 'date' field. - * @return This builder. - */ - public PaymentDetails.Builder clearDate() { - date = null; - fieldSetFlags()[4] = false; - return this; - } - - /** - * Gets the value of the 'status' field. - * @return The value. - */ - public java.lang.CharSequence getStatus() { - return status; - } - - - /** - * Sets the value of the 'status' field. - * @param value The value of 'status'. - * @return This builder. - */ - public PaymentDetails.Builder setStatus(java.lang.CharSequence value) { - validate(fields()[5], value); - this.status = value; - fieldSetFlags()[5] = true; - return this; - } - - /** - * Checks whether the 'status' field has been set. - * @return True if the 'status' field has been set, false otherwise. - */ - public boolean hasStatus() { - return fieldSetFlags()[5]; - } - - - /** - * Clears the value of the 'status' field. - * @return This builder. - */ - public PaymentDetails.Builder clearStatus() { - status = null; - fieldSetFlags()[5] = false; - return this; - } - - @Override - @SuppressWarnings("unchecked") - public PaymentDetails build() { - try { - PaymentDetails record = new PaymentDetails(); - record.transactionId = fieldSetFlags()[0] ? this.transactionId : (java.lang.CharSequence) defaultValue(fields()[0]); - record.type = fieldSetFlags()[1] ? this.type : (java.lang.CharSequence) defaultValue(fields()[1]); - record.amount = fieldSetFlags()[2] ? this.amount : (java.lang.Double) defaultValue(fields()[2]); - record.currency = fieldSetFlags()[3] ? this.currency : (java.lang.CharSequence) defaultValue(fields()[3]); - record.date = fieldSetFlags()[4] ? this.date : (java.lang.CharSequence) defaultValue(fields()[4]); - record.status = fieldSetFlags()[5] ? this.status : (java.lang.CharSequence) defaultValue(fields()[5]); - return record; - } catch (org.apache.avro.AvroMissingFieldException e) { - throw e; - } catch (java.lang.Exception e) { - throw new org.apache.avro.AvroRuntimeException(e); - } - } - } - - @SuppressWarnings("unchecked") - private static final org.apache.avro.io.DatumWriter - WRITER$ = (org.apache.avro.io.DatumWriter)MODEL$.createDatumWriter(SCHEMA$); - - @Override public void writeExternal(java.io.ObjectOutput out) - throws java.io.IOException { - WRITER$.write(this, SpecificData.getEncoder(out)); - } - - @SuppressWarnings("unchecked") - private static final org.apache.avro.io.DatumReader - READER$ = (org.apache.avro.io.DatumReader)MODEL$.createDatumReader(SCHEMA$); - - @Override public void readExternal(java.io.ObjectInput in) - throws java.io.IOException { - READER$.read(this, SpecificData.getDecoder(in)); - } - - @Override protected boolean hasCustomCoders() { return true; } - - @Override public void customEncode(org.apache.avro.io.Encoder out) - throws java.io.IOException - { - out.writeString(this.transactionId); - - out.writeString(this.type); - - out.writeDouble(this.amount); - - out.writeString(this.currency); - - out.writeString(this.date); - - out.writeString(this.status); - - } - - @Override public void customDecode(org.apache.avro.io.ResolvingDecoder in) - throws java.io.IOException - { - org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff(); - if (fieldOrder == null) { - this.transactionId = in.readString(this.transactionId instanceof Utf8 ? (Utf8)this.transactionId : null); - - this.type = in.readString(this.type instanceof Utf8 ? (Utf8)this.type : null); - - this.amount = in.readDouble(); - - this.currency = in.readString(this.currency instanceof Utf8 ? (Utf8)this.currency : null); - - this.date = in.readString(this.date instanceof Utf8 ? (Utf8)this.date : null); - - this.status = in.readString(this.status instanceof Utf8 ? (Utf8)this.status : null); - - } else { - for (int i = 0; i < 6; i++) { - switch (fieldOrder[i].pos()) { - case 0: - this.transactionId = in.readString(this.transactionId instanceof Utf8 ? (Utf8)this.transactionId : null); - break; - - case 1: - this.type = in.readString(this.type instanceof Utf8 ? (Utf8)this.type : null); - break; - - case 2: - this.amount = in.readDouble(); - break; - - case 3: - this.currency = in.readString(this.currency instanceof Utf8 ? (Utf8)this.currency : null); - break; - - case 4: - this.date = in.readString(this.date instanceof Utf8 ? (Utf8)this.date : null); - break; - - case 5: - this.status = in.readString(this.status instanceof Utf8 ? (Utf8)this.status : null); - break; - - default: - throw new java.io.IOException("Corrupt ResolvingDecoder."); - } - } - } - } -} - - - - - - - - - - diff --git a/src/main/java/io/skodjob/datagenerator/models/paymentfiat/PaymentFiat.java b/src/main/java/io/skodjob/datagenerator/models/paymentfiat/PaymentFiat.java deleted file mode 100644 index 8dba5b9..0000000 --- a/src/main/java/io/skodjob/datagenerator/models/paymentfiat/PaymentFiat.java +++ /dev/null @@ -1,647 +0,0 @@ -/** - * Autogenerated by Avro - * - * DO NOT EDIT DIRECTLY - */ -package io.skodjob.datagenerator.models.paymentfiat; - -import org.apache.avro.generic.GenericArray; -import org.apache.avro.specific.SpecificData; -import org.apache.avro.util.Utf8; -import org.apache.avro.message.BinaryMessageEncoder; -import org.apache.avro.message.BinaryMessageDecoder; -import org.apache.avro.message.SchemaStore; - -@org.apache.avro.specific.AvroGenerated -public class PaymentFiat extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord { - private static final long serialVersionUID = 4555590429550840016L; - - - public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"PaymentFiat\",\"namespace\":\"io.skodjob.datagenerator.models.paymentfiat\",\"fields\":[{\"name\":\"paymentDetails\",\"type\":{\"type\":\"record\",\"name\":\"PaymentDetails\",\"fields\":[{\"name\":\"transactionId\",\"type\":\"string\"},{\"name\":\"type\",\"type\":\"string\"},{\"name\":\"amount\",\"type\":\"double\"},{\"name\":\"currency\",\"type\":\"string\"},{\"name\":\"date\",\"type\":\"string\"},{\"name\":\"status\",\"type\":\"string\"}]}},{\"name\":\"payer\",\"type\":{\"type\":\"record\",\"name\":\"Payer\",\"fields\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"payerType\",\"type\":\"string\"},{\"name\":\"accountNumber\",\"type\":\"string\"},{\"name\":\"bank\",\"type\":\"string\"},{\"name\":\"billingAddress\",\"type\":{\"type\":\"record\",\"name\":\"Address\",\"fields\":[{\"name\":\"street\",\"type\":\"string\"},{\"name\":\"city\",\"type\":\"string\"},{\"name\":\"state\",\"type\":\"string\"},{\"name\":\"country\",\"type\":\"string\"},{\"name\":\"postalCode\",\"type\":\"string\"}]}},{\"name\":\"cardNumber\",\"type\":[\"null\",\"string\"],\"default\":null},{\"name\":\"cardType\",\"type\":[\"null\",\"string\"],\"default\":null},{\"name\":\"expiryDate\",\"type\":[\"null\",\"string\"],\"default\":null}]}},{\"name\":\"payee\",\"type\":{\"type\":\"record\",\"name\":\"Payee\",\"fields\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"payeeType\",\"type\":\"string\"},{\"name\":\"accountNumber\",\"type\":\"string\"},{\"name\":\"bank\",\"type\":\"string\"},{\"name\":\"address\",\"type\":\"Address\"}]}}]}"); - public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } - - private static final SpecificData MODEL$ = new SpecificData(); - - private static final BinaryMessageEncoder ENCODER = - new BinaryMessageEncoder<>(MODEL$, SCHEMA$); - - private static final BinaryMessageDecoder DECODER = - new BinaryMessageDecoder<>(MODEL$, SCHEMA$); - - /** - * Return the BinaryMessageEncoder instance used by this class. - * @return the message encoder used by this class - */ - public static BinaryMessageEncoder getEncoder() { - return ENCODER; - } - - /** - * Return the BinaryMessageDecoder instance used by this class. - * @return the message decoder used by this class - */ - public static BinaryMessageDecoder getDecoder() { - return DECODER; - } - - /** - * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}. - * @param resolver a {@link SchemaStore} used to find schemas by fingerprint - * @return a BinaryMessageDecoder instance for this class backed by the given SchemaStore - */ - public static BinaryMessageDecoder createDecoder(SchemaStore resolver) { - return new BinaryMessageDecoder<>(MODEL$, SCHEMA$, resolver); - } - - /** - * Serializes this PaymentFiat to a ByteBuffer. - * @return a buffer holding the serialized data for this instance - * @throws java.io.IOException if this instance could not be serialized - */ - public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException { - return ENCODER.encode(this); - } - - /** - * Deserializes a PaymentFiat from a ByteBuffer. - * @param b a byte buffer holding serialized data for an instance of this class - * @return a PaymentFiat instance decoded from the given buffer - * @throws java.io.IOException if the given bytes could not be deserialized into an instance of this class - */ - public static PaymentFiat fromByteBuffer( - java.nio.ByteBuffer b) throws java.io.IOException { - return DECODER.decode(b); - } - - private io.skodjob.datagenerator.models.paymentfiat.PaymentDetails paymentDetails; - private io.skodjob.datagenerator.models.paymentfiat.Payer payer; - private io.skodjob.datagenerator.models.paymentfiat.Payee payee; - - /** - * Default constructor. Note that this does not initialize fields - * to their default values from the schema. If that is desired then - * one should use newBuilder(). - */ - public PaymentFiat() {} - - /** - * All-args constructor. - * @param paymentDetails The new value for paymentDetails - * @param payer The new value for payer - * @param payee The new value for payee - */ - public PaymentFiat(io.skodjob.datagenerator.models.paymentfiat.PaymentDetails paymentDetails, io.skodjob.datagenerator.models.paymentfiat.Payer payer, io.skodjob.datagenerator.models.paymentfiat.Payee payee) { - this.paymentDetails = paymentDetails; - this.payer = payer; - this.payee = payee; - } - - @Override - public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; } - - @Override - public org.apache.avro.Schema getSchema() { return SCHEMA$; } - - // Used by DatumWriter. Applications should not call. - @Override - public java.lang.Object get(int field$) { - switch (field$) { - case 0: return paymentDetails; - case 1: return payer; - case 2: return payee; - default: throw new IndexOutOfBoundsException("Invalid index: " + field$); - } - } - - // Used by DatumReader. Applications should not call. - @Override - @SuppressWarnings(value="unchecked") - public void put(int field$, java.lang.Object value$) { - switch (field$) { - case 0: paymentDetails = (io.skodjob.datagenerator.models.paymentfiat.PaymentDetails)value$; break; - case 1: payer = (io.skodjob.datagenerator.models.paymentfiat.Payer)value$; break; - case 2: payee = (io.skodjob.datagenerator.models.paymentfiat.Payee)value$; break; - default: throw new IndexOutOfBoundsException("Invalid index: " + field$); - } - } - - /** - * Gets the value of the 'paymentDetails' field. - * @return The value of the 'paymentDetails' field. - */ - public io.skodjob.datagenerator.models.paymentfiat.PaymentDetails getPaymentDetails() { - return paymentDetails; - } - - - /** - * Sets the value of the 'paymentDetails' field. - * @param value the value to set. - */ - public void setPaymentDetails(io.skodjob.datagenerator.models.paymentfiat.PaymentDetails value) { - this.paymentDetails = value; - } - - /** - * Gets the value of the 'payer' field. - * @return The value of the 'payer' field. - */ - public io.skodjob.datagenerator.models.paymentfiat.Payer getPayer() { - return payer; - } - - - /** - * Sets the value of the 'payer' field. - * @param value the value to set. - */ - public void setPayer(io.skodjob.datagenerator.models.paymentfiat.Payer value) { - this.payer = value; - } - - /** - * Gets the value of the 'payee' field. - * @return The value of the 'payee' field. - */ - public io.skodjob.datagenerator.models.paymentfiat.Payee getPayee() { - return payee; - } - - - /** - * Sets the value of the 'payee' field. - * @param value the value to set. - */ - public void setPayee(io.skodjob.datagenerator.models.paymentfiat.Payee value) { - this.payee = value; - } - - /** - * Creates a new PaymentFiat RecordBuilder. - * @return A new PaymentFiat RecordBuilder - */ - public static io.skodjob.datagenerator.models.paymentfiat.PaymentFiat.Builder newBuilder() { - return new io.skodjob.datagenerator.models.paymentfiat.PaymentFiat.Builder(); - } - - /** - * Creates a new PaymentFiat RecordBuilder by copying an existing Builder. - * @param other The existing builder to copy. - * @return A new PaymentFiat RecordBuilder - */ - public static io.skodjob.datagenerator.models.paymentfiat.PaymentFiat.Builder newBuilder(io.skodjob.datagenerator.models.paymentfiat.PaymentFiat.Builder other) { - if (other == null) { - return new io.skodjob.datagenerator.models.paymentfiat.PaymentFiat.Builder(); - } else { - return new io.skodjob.datagenerator.models.paymentfiat.PaymentFiat.Builder(other); - } - } - - /** - * Creates a new PaymentFiat RecordBuilder by copying an existing PaymentFiat instance. - * @param other The existing instance to copy. - * @return A new PaymentFiat RecordBuilder - */ - public static io.skodjob.datagenerator.models.paymentfiat.PaymentFiat.Builder newBuilder(io.skodjob.datagenerator.models.paymentfiat.PaymentFiat other) { - if (other == null) { - return new io.skodjob.datagenerator.models.paymentfiat.PaymentFiat.Builder(); - } else { - return new io.skodjob.datagenerator.models.paymentfiat.PaymentFiat.Builder(other); - } - } - - /** - * RecordBuilder for PaymentFiat instances. - */ - @org.apache.avro.specific.AvroGenerated - public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase - implements org.apache.avro.data.RecordBuilder { - - private io.skodjob.datagenerator.models.paymentfiat.PaymentDetails paymentDetails; - private io.skodjob.datagenerator.models.paymentfiat.PaymentDetails.Builder paymentDetailsBuilder; - private io.skodjob.datagenerator.models.paymentfiat.Payer payer; - private io.skodjob.datagenerator.models.paymentfiat.Payer.Builder payerBuilder; - private io.skodjob.datagenerator.models.paymentfiat.Payee payee; - private io.skodjob.datagenerator.models.paymentfiat.Payee.Builder payeeBuilder; - - /** Creates a new Builder */ - private Builder() { - super(SCHEMA$, MODEL$); - } - - /** - * Creates a Builder by copying an existing Builder. - * @param other The existing Builder to copy. - */ - private Builder(io.skodjob.datagenerator.models.paymentfiat.PaymentFiat.Builder other) { - super(other); - if (isValidValue(fields()[0], other.paymentDetails)) { - this.paymentDetails = data().deepCopy(fields()[0].schema(), other.paymentDetails); - fieldSetFlags()[0] = other.fieldSetFlags()[0]; - } - if (other.hasPaymentDetailsBuilder()) { - this.paymentDetailsBuilder = io.skodjob.datagenerator.models.paymentfiat.PaymentDetails.newBuilder(other.getPaymentDetailsBuilder()); - } - if (isValidValue(fields()[1], other.payer)) { - this.payer = data().deepCopy(fields()[1].schema(), other.payer); - fieldSetFlags()[1] = other.fieldSetFlags()[1]; - } - if (other.hasPayerBuilder()) { - this.payerBuilder = io.skodjob.datagenerator.models.paymentfiat.Payer.newBuilder(other.getPayerBuilder()); - } - if (isValidValue(fields()[2], other.payee)) { - this.payee = data().deepCopy(fields()[2].schema(), other.payee); - fieldSetFlags()[2] = other.fieldSetFlags()[2]; - } - if (other.hasPayeeBuilder()) { - this.payeeBuilder = io.skodjob.datagenerator.models.paymentfiat.Payee.newBuilder(other.getPayeeBuilder()); - } - } - - /** - * Creates a Builder by copying an existing PaymentFiat instance - * @param other The existing instance to copy. - */ - private Builder(io.skodjob.datagenerator.models.paymentfiat.PaymentFiat other) { - super(SCHEMA$, MODEL$); - if (isValidValue(fields()[0], other.paymentDetails)) { - this.paymentDetails = data().deepCopy(fields()[0].schema(), other.paymentDetails); - fieldSetFlags()[0] = true; - } - this.paymentDetailsBuilder = null; - if (isValidValue(fields()[1], other.payer)) { - this.payer = data().deepCopy(fields()[1].schema(), other.payer); - fieldSetFlags()[1] = true; - } - this.payerBuilder = null; - if (isValidValue(fields()[2], other.payee)) { - this.payee = data().deepCopy(fields()[2].schema(), other.payee); - fieldSetFlags()[2] = true; - } - this.payeeBuilder = null; - } - - /** - * Gets the value of the 'paymentDetails' field. - * @return The value. - */ - public io.skodjob.datagenerator.models.paymentfiat.PaymentDetails getPaymentDetails() { - return paymentDetails; - } - - - /** - * Sets the value of the 'paymentDetails' field. - * @param value The value of 'paymentDetails'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.paymentfiat.PaymentFiat.Builder setPaymentDetails(io.skodjob.datagenerator.models.paymentfiat.PaymentDetails value) { - validate(fields()[0], value); - this.paymentDetailsBuilder = null; - this.paymentDetails = value; - fieldSetFlags()[0] = true; - return this; - } - - /** - * Checks whether the 'paymentDetails' field has been set. - * @return True if the 'paymentDetails' field has been set, false otherwise. - */ - public boolean hasPaymentDetails() { - return fieldSetFlags()[0]; - } - - /** - * Gets the Builder instance for the 'paymentDetails' field and creates one if it doesn't exist yet. - * @return This builder. - */ - public io.skodjob.datagenerator.models.paymentfiat.PaymentDetails.Builder getPaymentDetailsBuilder() { - if (paymentDetailsBuilder == null) { - if (hasPaymentDetails()) { - setPaymentDetailsBuilder(io.skodjob.datagenerator.models.paymentfiat.PaymentDetails.newBuilder(paymentDetails)); - } else { - setPaymentDetailsBuilder(io.skodjob.datagenerator.models.paymentfiat.PaymentDetails.newBuilder()); - } - } - return paymentDetailsBuilder; - } - - /** - * Sets the Builder instance for the 'paymentDetails' field - * @param value The builder instance that must be set. - * @return This builder. - */ - - public io.skodjob.datagenerator.models.paymentfiat.PaymentFiat.Builder setPaymentDetailsBuilder(io.skodjob.datagenerator.models.paymentfiat.PaymentDetails.Builder value) { - clearPaymentDetails(); - paymentDetailsBuilder = value; - return this; - } - - /** - * Checks whether the 'paymentDetails' field has an active Builder instance - * @return True if the 'paymentDetails' field has an active Builder instance - */ - public boolean hasPaymentDetailsBuilder() { - return paymentDetailsBuilder != null; - } - - /** - * Clears the value of the 'paymentDetails' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.paymentfiat.PaymentFiat.Builder clearPaymentDetails() { - paymentDetails = null; - paymentDetailsBuilder = null; - fieldSetFlags()[0] = false; - return this; - } - - /** - * Gets the value of the 'payer' field. - * @return The value. - */ - public io.skodjob.datagenerator.models.paymentfiat.Payer getPayer() { - return payer; - } - - - /** - * Sets the value of the 'payer' field. - * @param value The value of 'payer'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.paymentfiat.PaymentFiat.Builder setPayer(io.skodjob.datagenerator.models.paymentfiat.Payer value) { - validate(fields()[1], value); - this.payerBuilder = null; - this.payer = value; - fieldSetFlags()[1] = true; - return this; - } - - /** - * Checks whether the 'payer' field has been set. - * @return True if the 'payer' field has been set, false otherwise. - */ - public boolean hasPayer() { - return fieldSetFlags()[1]; - } - - /** - * Gets the Builder instance for the 'payer' field and creates one if it doesn't exist yet. - * @return This builder. - */ - public io.skodjob.datagenerator.models.paymentfiat.Payer.Builder getPayerBuilder() { - if (payerBuilder == null) { - if (hasPayer()) { - setPayerBuilder(io.skodjob.datagenerator.models.paymentfiat.Payer.newBuilder(payer)); - } else { - setPayerBuilder(io.skodjob.datagenerator.models.paymentfiat.Payer.newBuilder()); - } - } - return payerBuilder; - } - - /** - * Sets the Builder instance for the 'payer' field - * @param value The builder instance that must be set. - * @return This builder. - */ - - public io.skodjob.datagenerator.models.paymentfiat.PaymentFiat.Builder setPayerBuilder(io.skodjob.datagenerator.models.paymentfiat.Payer.Builder value) { - clearPayer(); - payerBuilder = value; - return this; - } - - /** - * Checks whether the 'payer' field has an active Builder instance - * @return True if the 'payer' field has an active Builder instance - */ - public boolean hasPayerBuilder() { - return payerBuilder != null; - } - - /** - * Clears the value of the 'payer' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.paymentfiat.PaymentFiat.Builder clearPayer() { - payer = null; - payerBuilder = null; - fieldSetFlags()[1] = false; - return this; - } - - /** - * Gets the value of the 'payee' field. - * @return The value. - */ - public io.skodjob.datagenerator.models.paymentfiat.Payee getPayee() { - return payee; - } - - - /** - * Sets the value of the 'payee' field. - * @param value The value of 'payee'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.paymentfiat.PaymentFiat.Builder setPayee(io.skodjob.datagenerator.models.paymentfiat.Payee value) { - validate(fields()[2], value); - this.payeeBuilder = null; - this.payee = value; - fieldSetFlags()[2] = true; - return this; - } - - /** - * Checks whether the 'payee' field has been set. - * @return True if the 'payee' field has been set, false otherwise. - */ - public boolean hasPayee() { - return fieldSetFlags()[2]; - } - - /** - * Gets the Builder instance for the 'payee' field and creates one if it doesn't exist yet. - * @return This builder. - */ - public io.skodjob.datagenerator.models.paymentfiat.Payee.Builder getPayeeBuilder() { - if (payeeBuilder == null) { - if (hasPayee()) { - setPayeeBuilder(io.skodjob.datagenerator.models.paymentfiat.Payee.newBuilder(payee)); - } else { - setPayeeBuilder(io.skodjob.datagenerator.models.paymentfiat.Payee.newBuilder()); - } - } - return payeeBuilder; - } - - /** - * Sets the Builder instance for the 'payee' field - * @param value The builder instance that must be set. - * @return This builder. - */ - - public io.skodjob.datagenerator.models.paymentfiat.PaymentFiat.Builder setPayeeBuilder(io.skodjob.datagenerator.models.paymentfiat.Payee.Builder value) { - clearPayee(); - payeeBuilder = value; - return this; - } - - /** - * Checks whether the 'payee' field has an active Builder instance - * @return True if the 'payee' field has an active Builder instance - */ - public boolean hasPayeeBuilder() { - return payeeBuilder != null; - } - - /** - * Clears the value of the 'payee' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.paymentfiat.PaymentFiat.Builder clearPayee() { - payee = null; - payeeBuilder = null; - fieldSetFlags()[2] = false; - return this; - } - - @Override - @SuppressWarnings("unchecked") - public PaymentFiat build() { - try { - PaymentFiat record = new PaymentFiat(); - if (paymentDetailsBuilder != null) { - try { - record.paymentDetails = this.paymentDetailsBuilder.build(); - } catch (org.apache.avro.AvroMissingFieldException e) { - e.addParentField(record.getSchema().getField("paymentDetails")); - throw e; - } - } else { - record.paymentDetails = fieldSetFlags()[0] ? this.paymentDetails : (io.skodjob.datagenerator.models.paymentfiat.PaymentDetails) defaultValue(fields()[0]); - } - if (payerBuilder != null) { - try { - record.payer = this.payerBuilder.build(); - } catch (org.apache.avro.AvroMissingFieldException e) { - e.addParentField(record.getSchema().getField("payer")); - throw e; - } - } else { - record.payer = fieldSetFlags()[1] ? this.payer : (io.skodjob.datagenerator.models.paymentfiat.Payer) defaultValue(fields()[1]); - } - if (payeeBuilder != null) { - try { - record.payee = this.payeeBuilder.build(); - } catch (org.apache.avro.AvroMissingFieldException e) { - e.addParentField(record.getSchema().getField("payee")); - throw e; - } - } else { - record.payee = fieldSetFlags()[2] ? this.payee : (io.skodjob.datagenerator.models.paymentfiat.Payee) defaultValue(fields()[2]); - } - return record; - } catch (org.apache.avro.AvroMissingFieldException e) { - throw e; - } catch (java.lang.Exception e) { - throw new org.apache.avro.AvroRuntimeException(e); - } - } - } - - @SuppressWarnings("unchecked") - private static final org.apache.avro.io.DatumWriter - WRITER$ = (org.apache.avro.io.DatumWriter)MODEL$.createDatumWriter(SCHEMA$); - - @Override public void writeExternal(java.io.ObjectOutput out) - throws java.io.IOException { - WRITER$.write(this, SpecificData.getEncoder(out)); - } - - @SuppressWarnings("unchecked") - private static final org.apache.avro.io.DatumReader - READER$ = (org.apache.avro.io.DatumReader)MODEL$.createDatumReader(SCHEMA$); - - @Override public void readExternal(java.io.ObjectInput in) - throws java.io.IOException { - READER$.read(this, SpecificData.getDecoder(in)); - } - - @Override protected boolean hasCustomCoders() { return true; } - - @Override public void customEncode(org.apache.avro.io.Encoder out) - throws java.io.IOException - { - this.paymentDetails.customEncode(out); - - this.payer.customEncode(out); - - this.payee.customEncode(out); - - } - - @Override public void customDecode(org.apache.avro.io.ResolvingDecoder in) - throws java.io.IOException - { - org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff(); - if (fieldOrder == null) { - if (this.paymentDetails == null) { - this.paymentDetails = new io.skodjob.datagenerator.models.paymentfiat.PaymentDetails(); - } - this.paymentDetails.customDecode(in); - - if (this.payer == null) { - this.payer = new io.skodjob.datagenerator.models.paymentfiat.Payer(); - } - this.payer.customDecode(in); - - if (this.payee == null) { - this.payee = new io.skodjob.datagenerator.models.paymentfiat.Payee(); - } - this.payee.customDecode(in); - - } else { - for (int i = 0; i < 3; i++) { - switch (fieldOrder[i].pos()) { - case 0: - if (this.paymentDetails == null) { - this.paymentDetails = new io.skodjob.datagenerator.models.paymentfiat.PaymentDetails(); - } - this.paymentDetails.customDecode(in); - break; - - case 1: - if (this.payer == null) { - this.payer = new io.skodjob.datagenerator.models.paymentfiat.Payer(); - } - this.payer.customDecode(in); - break; - - case 2: - if (this.payee == null) { - this.payee = new io.skodjob.datagenerator.models.paymentfiat.Payee(); - } - this.payee.customDecode(in); - break; - - default: - throw new java.io.IOException("Corrupt ResolvingDecoder."); - } - } - } - } -} - - - - - - - - - - diff --git a/src/main/java/io/skodjob/datagenerator/models/payroll/Employee.java b/src/main/java/io/skodjob/datagenerator/models/payroll/Employee.java deleted file mode 100644 index e713ecd..0000000 --- a/src/main/java/io/skodjob/datagenerator/models/payroll/Employee.java +++ /dev/null @@ -1,957 +0,0 @@ -/** - * Autogenerated by Avro - * - * DO NOT EDIT DIRECTLY - */ -package io.skodjob.datagenerator.models.payroll; - -import org.apache.avro.generic.GenericArray; -import org.apache.avro.specific.SpecificData; -import org.apache.avro.util.Utf8; -import org.apache.avro.message.BinaryMessageEncoder; -import org.apache.avro.message.BinaryMessageDecoder; -import org.apache.avro.message.SchemaStore; - -@org.apache.avro.specific.AvroGenerated -public class Employee extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord { - private static final long serialVersionUID = 2495808458502106084L; - - - public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"Employee\",\"namespace\":\"io.skodjob.datagenerator.models.payroll\",\"fields\":[{\"name\":\"employeeId\",\"type\":\"string\"},{\"name\":\"firstName\",\"type\":\"string\"},{\"name\":\"lastName\",\"type\":\"string\"},{\"name\":\"age\",\"type\":\"int\"},{\"name\":\"ssn\",\"type\":\"string\"},{\"name\":\"hourlyRate\",\"type\":\"float\"},{\"name\":\"gender\",\"type\":\"string\"},{\"name\":\"email\",\"type\":\"string\"},{\"name\":\"company\",\"type\":\"string\"}]}"); - public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } - - private static final SpecificData MODEL$ = new SpecificData(); - - private static final BinaryMessageEncoder ENCODER = - new BinaryMessageEncoder<>(MODEL$, SCHEMA$); - - private static final BinaryMessageDecoder DECODER = - new BinaryMessageDecoder<>(MODEL$, SCHEMA$); - - /** - * Return the BinaryMessageEncoder instance used by this class. - * @return the message encoder used by this class - */ - public static BinaryMessageEncoder getEncoder() { - return ENCODER; - } - - /** - * Return the BinaryMessageDecoder instance used by this class. - * @return the message decoder used by this class - */ - public static BinaryMessageDecoder getDecoder() { - return DECODER; - } - - /** - * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}. - * @param resolver a {@link SchemaStore} used to find schemas by fingerprint - * @return a BinaryMessageDecoder instance for this class backed by the given SchemaStore - */ - public static BinaryMessageDecoder createDecoder(SchemaStore resolver) { - return new BinaryMessageDecoder<>(MODEL$, SCHEMA$, resolver); - } - - /** - * Serializes this Employee to a ByteBuffer. - * @return a buffer holding the serialized data for this instance - * @throws java.io.IOException if this instance could not be serialized - */ - public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException { - return ENCODER.encode(this); - } - - /** - * Deserializes a Employee from a ByteBuffer. - * @param b a byte buffer holding serialized data for an instance of this class - * @return a Employee instance decoded from the given buffer - * @throws java.io.IOException if the given bytes could not be deserialized into an instance of this class - */ - public static Employee fromByteBuffer( - java.nio.ByteBuffer b) throws java.io.IOException { - return DECODER.decode(b); - } - - private java.lang.CharSequence employeeId; - private java.lang.CharSequence firstName; - private java.lang.CharSequence lastName; - private int age; - private java.lang.CharSequence ssn; - private float hourlyRate; - private java.lang.CharSequence gender; - private java.lang.CharSequence email; - private java.lang.CharSequence company; - - /** - * Default constructor. Note that this does not initialize fields - * to their default values from the schema. If that is desired then - * one should use newBuilder(). - */ - public Employee() {} - - /** - * All-args constructor. - * @param employeeId The new value for employeeId - * @param firstName The new value for firstName - * @param lastName The new value for lastName - * @param age The new value for age - * @param ssn The new value for ssn - * @param hourlyRate The new value for hourlyRate - * @param gender The new value for gender - * @param email The new value for email - * @param company The new value for company - */ - public Employee(java.lang.CharSequence employeeId, java.lang.CharSequence firstName, java.lang.CharSequence lastName, java.lang.Integer age, java.lang.CharSequence ssn, java.lang.Float hourlyRate, java.lang.CharSequence gender, java.lang.CharSequence email, java.lang.CharSequence company) { - this.employeeId = employeeId; - this.firstName = firstName; - this.lastName = lastName; - this.age = age; - this.ssn = ssn; - this.hourlyRate = hourlyRate; - this.gender = gender; - this.email = email; - this.company = company; - } - - @Override - public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; } - - @Override - public org.apache.avro.Schema getSchema() { return SCHEMA$; } - - // Used by DatumWriter. Applications should not call. - @Override - public java.lang.Object get(int field$) { - switch (field$) { - case 0: return employeeId; - case 1: return firstName; - case 2: return lastName; - case 3: return age; - case 4: return ssn; - case 5: return hourlyRate; - case 6: return gender; - case 7: return email; - case 8: return company; - default: throw new IndexOutOfBoundsException("Invalid index: " + field$); - } - } - - // Used by DatumReader. Applications should not call. - @Override - @SuppressWarnings(value="unchecked") - public void put(int field$, java.lang.Object value$) { - switch (field$) { - case 0: employeeId = (java.lang.CharSequence)value$; break; - case 1: firstName = (java.lang.CharSequence)value$; break; - case 2: lastName = (java.lang.CharSequence)value$; break; - case 3: age = (java.lang.Integer)value$; break; - case 4: ssn = (java.lang.CharSequence)value$; break; - case 5: hourlyRate = (java.lang.Float)value$; break; - case 6: gender = (java.lang.CharSequence)value$; break; - case 7: email = (java.lang.CharSequence)value$; break; - case 8: company = (java.lang.CharSequence)value$; break; - default: throw new IndexOutOfBoundsException("Invalid index: " + field$); - } - } - - /** - * Gets the value of the 'employeeId' field. - * @return The value of the 'employeeId' field. - */ - public java.lang.CharSequence getEmployeeId() { - return employeeId; - } - - - /** - * Sets the value of the 'employeeId' field. - * @param value the value to set. - */ - public void setEmployeeId(java.lang.CharSequence value) { - this.employeeId = value; - } - - /** - * Gets the value of the 'firstName' field. - * @return The value of the 'firstName' field. - */ - public java.lang.CharSequence getFirstName() { - return firstName; - } - - - /** - * Sets the value of the 'firstName' field. - * @param value the value to set. - */ - public void setFirstName(java.lang.CharSequence value) { - this.firstName = value; - } - - /** - * Gets the value of the 'lastName' field. - * @return The value of the 'lastName' field. - */ - public java.lang.CharSequence getLastName() { - return lastName; - } - - - /** - * Sets the value of the 'lastName' field. - * @param value the value to set. - */ - public void setLastName(java.lang.CharSequence value) { - this.lastName = value; - } - - /** - * Gets the value of the 'age' field. - * @return The value of the 'age' field. - */ - public int getAge() { - return age; - } - - - /** - * Sets the value of the 'age' field. - * @param value the value to set. - */ - public void setAge(int value) { - this.age = value; - } - - /** - * Gets the value of the 'ssn' field. - * @return The value of the 'ssn' field. - */ - public java.lang.CharSequence getSsn() { - return ssn; - } - - - /** - * Sets the value of the 'ssn' field. - * @param value the value to set. - */ - public void setSsn(java.lang.CharSequence value) { - this.ssn = value; - } - - /** - * Gets the value of the 'hourlyRate' field. - * @return The value of the 'hourlyRate' field. - */ - public float getHourlyRate() { - return hourlyRate; - } - - - /** - * Sets the value of the 'hourlyRate' field. - * @param value the value to set. - */ - public void setHourlyRate(float value) { - this.hourlyRate = value; - } - - /** - * Gets the value of the 'gender' field. - * @return The value of the 'gender' field. - */ - public java.lang.CharSequence getGender() { - return gender; - } - - - /** - * Sets the value of the 'gender' field. - * @param value the value to set. - */ - public void setGender(java.lang.CharSequence value) { - this.gender = value; - } - - /** - * Gets the value of the 'email' field. - * @return The value of the 'email' field. - */ - public java.lang.CharSequence getEmail() { - return email; - } - - - /** - * Sets the value of the 'email' field. - * @param value the value to set. - */ - public void setEmail(java.lang.CharSequence value) { - this.email = value; - } - - /** - * Gets the value of the 'company' field. - * @return The value of the 'company' field. - */ - public java.lang.CharSequence getCompany() { - return company; - } - - - /** - * Sets the value of the 'company' field. - * @param value the value to set. - */ - public void setCompany(java.lang.CharSequence value) { - this.company = value; - } - - /** - * Creates a new Employee RecordBuilder. - * @return A new Employee RecordBuilder - */ - public static io.skodjob.datagenerator.models.payroll.Employee.Builder newBuilder() { - return new io.skodjob.datagenerator.models.payroll.Employee.Builder(); - } - - /** - * Creates a new Employee RecordBuilder by copying an existing Builder. - * @param other The existing builder to copy. - * @return A new Employee RecordBuilder - */ - public static io.skodjob.datagenerator.models.payroll.Employee.Builder newBuilder(io.skodjob.datagenerator.models.payroll.Employee.Builder other) { - if (other == null) { - return new io.skodjob.datagenerator.models.payroll.Employee.Builder(); - } else { - return new io.skodjob.datagenerator.models.payroll.Employee.Builder(other); - } - } - - /** - * Creates a new Employee RecordBuilder by copying an existing Employee instance. - * @param other The existing instance to copy. - * @return A new Employee RecordBuilder - */ - public static io.skodjob.datagenerator.models.payroll.Employee.Builder newBuilder(io.skodjob.datagenerator.models.payroll.Employee other) { - if (other == null) { - return new io.skodjob.datagenerator.models.payroll.Employee.Builder(); - } else { - return new io.skodjob.datagenerator.models.payroll.Employee.Builder(other); - } - } - - /** - * RecordBuilder for Employee instances. - */ - @org.apache.avro.specific.AvroGenerated - public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase - implements org.apache.avro.data.RecordBuilder { - - private java.lang.CharSequence employeeId; - private java.lang.CharSequence firstName; - private java.lang.CharSequence lastName; - private int age; - private java.lang.CharSequence ssn; - private float hourlyRate; - private java.lang.CharSequence gender; - private java.lang.CharSequence email; - private java.lang.CharSequence company; - - /** Creates a new Builder */ - private Builder() { - super(SCHEMA$, MODEL$); - } - - /** - * Creates a Builder by copying an existing Builder. - * @param other The existing Builder to copy. - */ - private Builder(io.skodjob.datagenerator.models.payroll.Employee.Builder other) { - super(other); - if (isValidValue(fields()[0], other.employeeId)) { - this.employeeId = data().deepCopy(fields()[0].schema(), other.employeeId); - fieldSetFlags()[0] = other.fieldSetFlags()[0]; - } - if (isValidValue(fields()[1], other.firstName)) { - this.firstName = data().deepCopy(fields()[1].schema(), other.firstName); - fieldSetFlags()[1] = other.fieldSetFlags()[1]; - } - if (isValidValue(fields()[2], other.lastName)) { - this.lastName = data().deepCopy(fields()[2].schema(), other.lastName); - fieldSetFlags()[2] = other.fieldSetFlags()[2]; - } - if (isValidValue(fields()[3], other.age)) { - this.age = data().deepCopy(fields()[3].schema(), other.age); - fieldSetFlags()[3] = other.fieldSetFlags()[3]; - } - if (isValidValue(fields()[4], other.ssn)) { - this.ssn = data().deepCopy(fields()[4].schema(), other.ssn); - fieldSetFlags()[4] = other.fieldSetFlags()[4]; - } - if (isValidValue(fields()[5], other.hourlyRate)) { - this.hourlyRate = data().deepCopy(fields()[5].schema(), other.hourlyRate); - fieldSetFlags()[5] = other.fieldSetFlags()[5]; - } - if (isValidValue(fields()[6], other.gender)) { - this.gender = data().deepCopy(fields()[6].schema(), other.gender); - fieldSetFlags()[6] = other.fieldSetFlags()[6]; - } - if (isValidValue(fields()[7], other.email)) { - this.email = data().deepCopy(fields()[7].schema(), other.email); - fieldSetFlags()[7] = other.fieldSetFlags()[7]; - } - if (isValidValue(fields()[8], other.company)) { - this.company = data().deepCopy(fields()[8].schema(), other.company); - fieldSetFlags()[8] = other.fieldSetFlags()[8]; - } - } - - /** - * Creates a Builder by copying an existing Employee instance - * @param other The existing instance to copy. - */ - private Builder(io.skodjob.datagenerator.models.payroll.Employee other) { - super(SCHEMA$, MODEL$); - if (isValidValue(fields()[0], other.employeeId)) { - this.employeeId = data().deepCopy(fields()[0].schema(), other.employeeId); - fieldSetFlags()[0] = true; - } - if (isValidValue(fields()[1], other.firstName)) { - this.firstName = data().deepCopy(fields()[1].schema(), other.firstName); - fieldSetFlags()[1] = true; - } - if (isValidValue(fields()[2], other.lastName)) { - this.lastName = data().deepCopy(fields()[2].schema(), other.lastName); - fieldSetFlags()[2] = true; - } - if (isValidValue(fields()[3], other.age)) { - this.age = data().deepCopy(fields()[3].schema(), other.age); - fieldSetFlags()[3] = true; - } - if (isValidValue(fields()[4], other.ssn)) { - this.ssn = data().deepCopy(fields()[4].schema(), other.ssn); - fieldSetFlags()[4] = true; - } - if (isValidValue(fields()[5], other.hourlyRate)) { - this.hourlyRate = data().deepCopy(fields()[5].schema(), other.hourlyRate); - fieldSetFlags()[5] = true; - } - if (isValidValue(fields()[6], other.gender)) { - this.gender = data().deepCopy(fields()[6].schema(), other.gender); - fieldSetFlags()[6] = true; - } - if (isValidValue(fields()[7], other.email)) { - this.email = data().deepCopy(fields()[7].schema(), other.email); - fieldSetFlags()[7] = true; - } - if (isValidValue(fields()[8], other.company)) { - this.company = data().deepCopy(fields()[8].schema(), other.company); - fieldSetFlags()[8] = true; - } - } - - /** - * Gets the value of the 'employeeId' field. - * @return The value. - */ - public java.lang.CharSequence getEmployeeId() { - return employeeId; - } - - - /** - * Sets the value of the 'employeeId' field. - * @param value The value of 'employeeId'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.payroll.Employee.Builder setEmployeeId(java.lang.CharSequence value) { - validate(fields()[0], value); - this.employeeId = value; - fieldSetFlags()[0] = true; - return this; - } - - /** - * Checks whether the 'employeeId' field has been set. - * @return True if the 'employeeId' field has been set, false otherwise. - */ - public boolean hasEmployeeId() { - return fieldSetFlags()[0]; - } - - - /** - * Clears the value of the 'employeeId' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.payroll.Employee.Builder clearEmployeeId() { - employeeId = null; - fieldSetFlags()[0] = false; - return this; - } - - /** - * Gets the value of the 'firstName' field. - * @return The value. - */ - public java.lang.CharSequence getFirstName() { - return firstName; - } - - - /** - * Sets the value of the 'firstName' field. - * @param value The value of 'firstName'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.payroll.Employee.Builder setFirstName(java.lang.CharSequence value) { - validate(fields()[1], value); - this.firstName = value; - fieldSetFlags()[1] = true; - return this; - } - - /** - * Checks whether the 'firstName' field has been set. - * @return True if the 'firstName' field has been set, false otherwise. - */ - public boolean hasFirstName() { - return fieldSetFlags()[1]; - } - - - /** - * Clears the value of the 'firstName' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.payroll.Employee.Builder clearFirstName() { - firstName = null; - fieldSetFlags()[1] = false; - return this; - } - - /** - * Gets the value of the 'lastName' field. - * @return The value. - */ - public java.lang.CharSequence getLastName() { - return lastName; - } - - - /** - * Sets the value of the 'lastName' field. - * @param value The value of 'lastName'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.payroll.Employee.Builder setLastName(java.lang.CharSequence value) { - validate(fields()[2], value); - this.lastName = value; - fieldSetFlags()[2] = true; - return this; - } - - /** - * Checks whether the 'lastName' field has been set. - * @return True if the 'lastName' field has been set, false otherwise. - */ - public boolean hasLastName() { - return fieldSetFlags()[2]; - } - - - /** - * Clears the value of the 'lastName' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.payroll.Employee.Builder clearLastName() { - lastName = null; - fieldSetFlags()[2] = false; - return this; - } - - /** - * Gets the value of the 'age' field. - * @return The value. - */ - public int getAge() { - return age; - } - - - /** - * Sets the value of the 'age' field. - * @param value The value of 'age'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.payroll.Employee.Builder setAge(int value) { - validate(fields()[3], value); - this.age = value; - fieldSetFlags()[3] = true; - return this; - } - - /** - * Checks whether the 'age' field has been set. - * @return True if the 'age' field has been set, false otherwise. - */ - public boolean hasAge() { - return fieldSetFlags()[3]; - } - - - /** - * Clears the value of the 'age' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.payroll.Employee.Builder clearAge() { - fieldSetFlags()[3] = false; - return this; - } - - /** - * Gets the value of the 'ssn' field. - * @return The value. - */ - public java.lang.CharSequence getSsn() { - return ssn; - } - - - /** - * Sets the value of the 'ssn' field. - * @param value The value of 'ssn'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.payroll.Employee.Builder setSsn(java.lang.CharSequence value) { - validate(fields()[4], value); - this.ssn = value; - fieldSetFlags()[4] = true; - return this; - } - - /** - * Checks whether the 'ssn' field has been set. - * @return True if the 'ssn' field has been set, false otherwise. - */ - public boolean hasSsn() { - return fieldSetFlags()[4]; - } - - - /** - * Clears the value of the 'ssn' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.payroll.Employee.Builder clearSsn() { - ssn = null; - fieldSetFlags()[4] = false; - return this; - } - - /** - * Gets the value of the 'hourlyRate' field. - * @return The value. - */ - public float getHourlyRate() { - return hourlyRate; - } - - - /** - * Sets the value of the 'hourlyRate' field. - * @param value The value of 'hourlyRate'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.payroll.Employee.Builder setHourlyRate(float value) { - validate(fields()[5], value); - this.hourlyRate = value; - fieldSetFlags()[5] = true; - return this; - } - - /** - * Checks whether the 'hourlyRate' field has been set. - * @return True if the 'hourlyRate' field has been set, false otherwise. - */ - public boolean hasHourlyRate() { - return fieldSetFlags()[5]; - } - - - /** - * Clears the value of the 'hourlyRate' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.payroll.Employee.Builder clearHourlyRate() { - fieldSetFlags()[5] = false; - return this; - } - - /** - * Gets the value of the 'gender' field. - * @return The value. - */ - public java.lang.CharSequence getGender() { - return gender; - } - - - /** - * Sets the value of the 'gender' field. - * @param value The value of 'gender'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.payroll.Employee.Builder setGender(java.lang.CharSequence value) { - validate(fields()[6], value); - this.gender = value; - fieldSetFlags()[6] = true; - return this; - } - - /** - * Checks whether the 'gender' field has been set. - * @return True if the 'gender' field has been set, false otherwise. - */ - public boolean hasGender() { - return fieldSetFlags()[6]; - } - - - /** - * Clears the value of the 'gender' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.payroll.Employee.Builder clearGender() { - gender = null; - fieldSetFlags()[6] = false; - return this; - } - - /** - * Gets the value of the 'email' field. - * @return The value. - */ - public java.lang.CharSequence getEmail() { - return email; - } - - - /** - * Sets the value of the 'email' field. - * @param value The value of 'email'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.payroll.Employee.Builder setEmail(java.lang.CharSequence value) { - validate(fields()[7], value); - this.email = value; - fieldSetFlags()[7] = true; - return this; - } - - /** - * Checks whether the 'email' field has been set. - * @return True if the 'email' field has been set, false otherwise. - */ - public boolean hasEmail() { - return fieldSetFlags()[7]; - } - - - /** - * Clears the value of the 'email' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.payroll.Employee.Builder clearEmail() { - email = null; - fieldSetFlags()[7] = false; - return this; - } - - /** - * Gets the value of the 'company' field. - * @return The value. - */ - public java.lang.CharSequence getCompany() { - return company; - } - - - /** - * Sets the value of the 'company' field. - * @param value The value of 'company'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.payroll.Employee.Builder setCompany(java.lang.CharSequence value) { - validate(fields()[8], value); - this.company = value; - fieldSetFlags()[8] = true; - return this; - } - - /** - * Checks whether the 'company' field has been set. - * @return True if the 'company' field has been set, false otherwise. - */ - public boolean hasCompany() { - return fieldSetFlags()[8]; - } - - - /** - * Clears the value of the 'company' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.payroll.Employee.Builder clearCompany() { - company = null; - fieldSetFlags()[8] = false; - return this; - } - - @Override - @SuppressWarnings("unchecked") - public Employee build() { - try { - Employee record = new Employee(); - record.employeeId = fieldSetFlags()[0] ? this.employeeId : (java.lang.CharSequence) defaultValue(fields()[0]); - record.firstName = fieldSetFlags()[1] ? this.firstName : (java.lang.CharSequence) defaultValue(fields()[1]); - record.lastName = fieldSetFlags()[2] ? this.lastName : (java.lang.CharSequence) defaultValue(fields()[2]); - record.age = fieldSetFlags()[3] ? this.age : (java.lang.Integer) defaultValue(fields()[3]); - record.ssn = fieldSetFlags()[4] ? this.ssn : (java.lang.CharSequence) defaultValue(fields()[4]); - record.hourlyRate = fieldSetFlags()[5] ? this.hourlyRate : (java.lang.Float) defaultValue(fields()[5]); - record.gender = fieldSetFlags()[6] ? this.gender : (java.lang.CharSequence) defaultValue(fields()[6]); - record.email = fieldSetFlags()[7] ? this.email : (java.lang.CharSequence) defaultValue(fields()[7]); - record.company = fieldSetFlags()[8] ? this.company : (java.lang.CharSequence) defaultValue(fields()[8]); - return record; - } catch (org.apache.avro.AvroMissingFieldException e) { - throw e; - } catch (java.lang.Exception e) { - throw new org.apache.avro.AvroRuntimeException(e); - } - } - } - - @SuppressWarnings("unchecked") - private static final org.apache.avro.io.DatumWriter - WRITER$ = (org.apache.avro.io.DatumWriter)MODEL$.createDatumWriter(SCHEMA$); - - @Override public void writeExternal(java.io.ObjectOutput out) - throws java.io.IOException { - WRITER$.write(this, SpecificData.getEncoder(out)); - } - - @SuppressWarnings("unchecked") - private static final org.apache.avro.io.DatumReader - READER$ = (org.apache.avro.io.DatumReader)MODEL$.createDatumReader(SCHEMA$); - - @Override public void readExternal(java.io.ObjectInput in) - throws java.io.IOException { - READER$.read(this, SpecificData.getDecoder(in)); - } - - @Override protected boolean hasCustomCoders() { return true; } - - @Override public void customEncode(org.apache.avro.io.Encoder out) - throws java.io.IOException - { - out.writeString(this.employeeId); - - out.writeString(this.firstName); - - out.writeString(this.lastName); - - out.writeInt(this.age); - - out.writeString(this.ssn); - - out.writeFloat(this.hourlyRate); - - out.writeString(this.gender); - - out.writeString(this.email); - - out.writeString(this.company); - - } - - @Override public void customDecode(org.apache.avro.io.ResolvingDecoder in) - throws java.io.IOException - { - org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff(); - if (fieldOrder == null) { - this.employeeId = in.readString(this.employeeId instanceof Utf8 ? (Utf8)this.employeeId : null); - - this.firstName = in.readString(this.firstName instanceof Utf8 ? (Utf8)this.firstName : null); - - this.lastName = in.readString(this.lastName instanceof Utf8 ? (Utf8)this.lastName : null); - - this.age = in.readInt(); - - this.ssn = in.readString(this.ssn instanceof Utf8 ? (Utf8)this.ssn : null); - - this.hourlyRate = in.readFloat(); - - this.gender = in.readString(this.gender instanceof Utf8 ? (Utf8)this.gender : null); - - this.email = in.readString(this.email instanceof Utf8 ? (Utf8)this.email : null); - - this.company = in.readString(this.company instanceof Utf8 ? (Utf8)this.company : null); - - } else { - for (int i = 0; i < 9; i++) { - switch (fieldOrder[i].pos()) { - case 0: - this.employeeId = in.readString(this.employeeId instanceof Utf8 ? (Utf8)this.employeeId : null); - break; - - case 1: - this.firstName = in.readString(this.firstName instanceof Utf8 ? (Utf8)this.firstName : null); - break; - - case 2: - this.lastName = in.readString(this.lastName instanceof Utf8 ? (Utf8)this.lastName : null); - break; - - case 3: - this.age = in.readInt(); - break; - - case 4: - this.ssn = in.readString(this.ssn instanceof Utf8 ? (Utf8)this.ssn : null); - break; - - case 5: - this.hourlyRate = in.readFloat(); - break; - - case 6: - this.gender = in.readString(this.gender instanceof Utf8 ? (Utf8)this.gender : null); - break; - - case 7: - this.email = in.readString(this.email instanceof Utf8 ? (Utf8)this.email : null); - break; - - case 8: - this.company = in.readString(this.company instanceof Utf8 ? (Utf8)this.company : null); - break; - - default: - throw new java.io.IOException("Corrupt ResolvingDecoder."); - } - } - } - } -} - - - - - - - - - - diff --git a/src/main/java/io/skodjob/datagenerator/models/stargate/StarGate.java b/src/main/java/io/skodjob/datagenerator/models/stargate/StarGate.java deleted file mode 100644 index 0bbb0a1..0000000 --- a/src/main/java/io/skodjob/datagenerator/models/stargate/StarGate.java +++ /dev/null @@ -1,877 +0,0 @@ -/** - * Autogenerated by Avro - * - * DO NOT EDIT DIRECTLY - */ -package io.skodjob.datagenerator.models.stargate; - -import org.apache.avro.generic.GenericArray; -import org.apache.avro.specific.SpecificData; -import org.apache.avro.util.Utf8; -import org.apache.avro.message.BinaryMessageEncoder; -import org.apache.avro.message.BinaryMessageDecoder; -import org.apache.avro.message.SchemaStore; - -@org.apache.avro.specific.AvroGenerated -public class StarGate extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord { - private static final long serialVersionUID = -443295484777882232L; - - - public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"StarGate\",\"namespace\":\"io.skodjob.datagenerator.models.stargate\",\"fields\":[{\"name\":\"character_name\",\"type\":\"string\"},{\"name\":\"source_planet\",\"type\":\"string\"},{\"name\":\"target_planet\",\"type\":\"string\"},{\"name\":\"quote\",\"type\":\"string\"},{\"name\":\"duration\",\"type\":\"int\"},{\"name\":\"duration_unit\",\"type\":\"string\"},{\"name\":\"distance\",\"type\":\"int\"},{\"name\":\"distance_unit\",\"type\":\"string\"}]}"); - public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } - - private static final SpecificData MODEL$ = new SpecificData(); - - private static final BinaryMessageEncoder ENCODER = - new BinaryMessageEncoder<>(MODEL$, SCHEMA$); - - private static final BinaryMessageDecoder DECODER = - new BinaryMessageDecoder<>(MODEL$, SCHEMA$); - - /** - * Return the BinaryMessageEncoder instance used by this class. - * @return the message encoder used by this class - */ - public static BinaryMessageEncoder getEncoder() { - return ENCODER; - } - - /** - * Return the BinaryMessageDecoder instance used by this class. - * @return the message decoder used by this class - */ - public static BinaryMessageDecoder getDecoder() { - return DECODER; - } - - /** - * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}. - * @param resolver a {@link SchemaStore} used to find schemas by fingerprint - * @return a BinaryMessageDecoder instance for this class backed by the given SchemaStore - */ - public static BinaryMessageDecoder createDecoder(SchemaStore resolver) { - return new BinaryMessageDecoder<>(MODEL$, SCHEMA$, resolver); - } - - /** - * Serializes this StarGate to a ByteBuffer. - * @return a buffer holding the serialized data for this instance - * @throws java.io.IOException if this instance could not be serialized - */ - public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException { - return ENCODER.encode(this); - } - - /** - * Deserializes a StarGate from a ByteBuffer. - * @param b a byte buffer holding serialized data for an instance of this class - * @return a StarGate instance decoded from the given buffer - * @throws java.io.IOException if the given bytes could not be deserialized into an instance of this class - */ - public static StarGate fromByteBuffer( - java.nio.ByteBuffer b) throws java.io.IOException { - return DECODER.decode(b); - } - - private java.lang.CharSequence character_name; - private java.lang.CharSequence source_planet; - private java.lang.CharSequence target_planet; - private java.lang.CharSequence quote; - private int duration; - private java.lang.CharSequence duration_unit; - private int distance; - private java.lang.CharSequence distance_unit; - - /** - * Default constructor. Note that this does not initialize fields - * to their default values from the schema. If that is desired then - * one should use newBuilder(). - */ - public StarGate() {} - - /** - * All-args constructor. - * @param character_name The new value for character_name - * @param source_planet The new value for source_planet - * @param target_planet The new value for target_planet - * @param quote The new value for quote - * @param duration The new value for duration - * @param duration_unit The new value for duration_unit - * @param distance The new value for distance - * @param distance_unit The new value for distance_unit - */ - public StarGate(java.lang.CharSequence character_name, java.lang.CharSequence source_planet, java.lang.CharSequence target_planet, java.lang.CharSequence quote, java.lang.Integer duration, java.lang.CharSequence duration_unit, java.lang.Integer distance, java.lang.CharSequence distance_unit) { - this.character_name = character_name; - this.source_planet = source_planet; - this.target_planet = target_planet; - this.quote = quote; - this.duration = duration; - this.duration_unit = duration_unit; - this.distance = distance; - this.distance_unit = distance_unit; - } - - @Override - public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; } - - @Override - public org.apache.avro.Schema getSchema() { return SCHEMA$; } - - // Used by DatumWriter. Applications should not call. - @Override - public java.lang.Object get(int field$) { - switch (field$) { - case 0: return character_name; - case 1: return source_planet; - case 2: return target_planet; - case 3: return quote; - case 4: return duration; - case 5: return duration_unit; - case 6: return distance; - case 7: return distance_unit; - default: throw new IndexOutOfBoundsException("Invalid index: " + field$); - } - } - - // Used by DatumReader. Applications should not call. - @Override - @SuppressWarnings(value="unchecked") - public void put(int field$, java.lang.Object value$) { - switch (field$) { - case 0: character_name = (java.lang.CharSequence)value$; break; - case 1: source_planet = (java.lang.CharSequence)value$; break; - case 2: target_planet = (java.lang.CharSequence)value$; break; - case 3: quote = (java.lang.CharSequence)value$; break; - case 4: duration = (java.lang.Integer)value$; break; - case 5: duration_unit = (java.lang.CharSequence)value$; break; - case 6: distance = (java.lang.Integer)value$; break; - case 7: distance_unit = (java.lang.CharSequence)value$; break; - default: throw new IndexOutOfBoundsException("Invalid index: " + field$); - } - } - - /** - * Gets the value of the 'character_name' field. - * @return The value of the 'character_name' field. - */ - public java.lang.CharSequence getCharacterName() { - return character_name; - } - - - /** - * Sets the value of the 'character_name' field. - * @param value the value to set. - */ - public void setCharacterName(java.lang.CharSequence value) { - this.character_name = value; - } - - /** - * Gets the value of the 'source_planet' field. - * @return The value of the 'source_planet' field. - */ - public java.lang.CharSequence getSourcePlanet() { - return source_planet; - } - - - /** - * Sets the value of the 'source_planet' field. - * @param value the value to set. - */ - public void setSourcePlanet(java.lang.CharSequence value) { - this.source_planet = value; - } - - /** - * Gets the value of the 'target_planet' field. - * @return The value of the 'target_planet' field. - */ - public java.lang.CharSequence getTargetPlanet() { - return target_planet; - } - - - /** - * Sets the value of the 'target_planet' field. - * @param value the value to set. - */ - public void setTargetPlanet(java.lang.CharSequence value) { - this.target_planet = value; - } - - /** - * Gets the value of the 'quote' field. - * @return The value of the 'quote' field. - */ - public java.lang.CharSequence getQuote() { - return quote; - } - - - /** - * Sets the value of the 'quote' field. - * @param value the value to set. - */ - public void setQuote(java.lang.CharSequence value) { - this.quote = value; - } - - /** - * Gets the value of the 'duration' field. - * @return The value of the 'duration' field. - */ - public int getDuration() { - return duration; - } - - - /** - * Sets the value of the 'duration' field. - * @param value the value to set. - */ - public void setDuration(int value) { - this.duration = value; - } - - /** - * Gets the value of the 'duration_unit' field. - * @return The value of the 'duration_unit' field. - */ - public java.lang.CharSequence getDurationUnit() { - return duration_unit; - } - - - /** - * Sets the value of the 'duration_unit' field. - * @param value the value to set. - */ - public void setDurationUnit(java.lang.CharSequence value) { - this.duration_unit = value; - } - - /** - * Gets the value of the 'distance' field. - * @return The value of the 'distance' field. - */ - public int getDistance() { - return distance; - } - - - /** - * Sets the value of the 'distance' field. - * @param value the value to set. - */ - public void setDistance(int value) { - this.distance = value; - } - - /** - * Gets the value of the 'distance_unit' field. - * @return The value of the 'distance_unit' field. - */ - public java.lang.CharSequence getDistanceUnit() { - return distance_unit; - } - - - /** - * Sets the value of the 'distance_unit' field. - * @param value the value to set. - */ - public void setDistanceUnit(java.lang.CharSequence value) { - this.distance_unit = value; - } - - /** - * Creates a new StarGate RecordBuilder. - * @return A new StarGate RecordBuilder - */ - public static io.skodjob.datagenerator.models.stargate.StarGate.Builder newBuilder() { - return new io.skodjob.datagenerator.models.stargate.StarGate.Builder(); - } - - /** - * Creates a new StarGate RecordBuilder by copying an existing Builder. - * @param other The existing builder to copy. - * @return A new StarGate RecordBuilder - */ - public static io.skodjob.datagenerator.models.stargate.StarGate.Builder newBuilder(io.skodjob.datagenerator.models.stargate.StarGate.Builder other) { - if (other == null) { - return new io.skodjob.datagenerator.models.stargate.StarGate.Builder(); - } else { - return new io.skodjob.datagenerator.models.stargate.StarGate.Builder(other); - } - } - - /** - * Creates a new StarGate RecordBuilder by copying an existing StarGate instance. - * @param other The existing instance to copy. - * @return A new StarGate RecordBuilder - */ - public static io.skodjob.datagenerator.models.stargate.StarGate.Builder newBuilder(io.skodjob.datagenerator.models.stargate.StarGate other) { - if (other == null) { - return new io.skodjob.datagenerator.models.stargate.StarGate.Builder(); - } else { - return new io.skodjob.datagenerator.models.stargate.StarGate.Builder(other); - } - } - - /** - * RecordBuilder for StarGate instances. - */ - @org.apache.avro.specific.AvroGenerated - public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase - implements org.apache.avro.data.RecordBuilder { - - private java.lang.CharSequence character_name; - private java.lang.CharSequence source_planet; - private java.lang.CharSequence target_planet; - private java.lang.CharSequence quote; - private int duration; - private java.lang.CharSequence duration_unit; - private int distance; - private java.lang.CharSequence distance_unit; - - /** Creates a new Builder */ - private Builder() { - super(SCHEMA$, MODEL$); - } - - /** - * Creates a Builder by copying an existing Builder. - * @param other The existing Builder to copy. - */ - private Builder(io.skodjob.datagenerator.models.stargate.StarGate.Builder other) { - super(other); - if (isValidValue(fields()[0], other.character_name)) { - this.character_name = data().deepCopy(fields()[0].schema(), other.character_name); - fieldSetFlags()[0] = other.fieldSetFlags()[0]; - } - if (isValidValue(fields()[1], other.source_planet)) { - this.source_planet = data().deepCopy(fields()[1].schema(), other.source_planet); - fieldSetFlags()[1] = other.fieldSetFlags()[1]; - } - if (isValidValue(fields()[2], other.target_planet)) { - this.target_planet = data().deepCopy(fields()[2].schema(), other.target_planet); - fieldSetFlags()[2] = other.fieldSetFlags()[2]; - } - if (isValidValue(fields()[3], other.quote)) { - this.quote = data().deepCopy(fields()[3].schema(), other.quote); - fieldSetFlags()[3] = other.fieldSetFlags()[3]; - } - if (isValidValue(fields()[4], other.duration)) { - this.duration = data().deepCopy(fields()[4].schema(), other.duration); - fieldSetFlags()[4] = other.fieldSetFlags()[4]; - } - if (isValidValue(fields()[5], other.duration_unit)) { - this.duration_unit = data().deepCopy(fields()[5].schema(), other.duration_unit); - fieldSetFlags()[5] = other.fieldSetFlags()[5]; - } - if (isValidValue(fields()[6], other.distance)) { - this.distance = data().deepCopy(fields()[6].schema(), other.distance); - fieldSetFlags()[6] = other.fieldSetFlags()[6]; - } - if (isValidValue(fields()[7], other.distance_unit)) { - this.distance_unit = data().deepCopy(fields()[7].schema(), other.distance_unit); - fieldSetFlags()[7] = other.fieldSetFlags()[7]; - } - } - - /** - * Creates a Builder by copying an existing StarGate instance - * @param other The existing instance to copy. - */ - private Builder(io.skodjob.datagenerator.models.stargate.StarGate other) { - super(SCHEMA$, MODEL$); - if (isValidValue(fields()[0], other.character_name)) { - this.character_name = data().deepCopy(fields()[0].schema(), other.character_name); - fieldSetFlags()[0] = true; - } - if (isValidValue(fields()[1], other.source_planet)) { - this.source_planet = data().deepCopy(fields()[1].schema(), other.source_planet); - fieldSetFlags()[1] = true; - } - if (isValidValue(fields()[2], other.target_planet)) { - this.target_planet = data().deepCopy(fields()[2].schema(), other.target_planet); - fieldSetFlags()[2] = true; - } - if (isValidValue(fields()[3], other.quote)) { - this.quote = data().deepCopy(fields()[3].schema(), other.quote); - fieldSetFlags()[3] = true; - } - if (isValidValue(fields()[4], other.duration)) { - this.duration = data().deepCopy(fields()[4].schema(), other.duration); - fieldSetFlags()[4] = true; - } - if (isValidValue(fields()[5], other.duration_unit)) { - this.duration_unit = data().deepCopy(fields()[5].schema(), other.duration_unit); - fieldSetFlags()[5] = true; - } - if (isValidValue(fields()[6], other.distance)) { - this.distance = data().deepCopy(fields()[6].schema(), other.distance); - fieldSetFlags()[6] = true; - } - if (isValidValue(fields()[7], other.distance_unit)) { - this.distance_unit = data().deepCopy(fields()[7].schema(), other.distance_unit); - fieldSetFlags()[7] = true; - } - } - - /** - * Gets the value of the 'character_name' field. - * @return The value. - */ - public java.lang.CharSequence getCharacterName() { - return character_name; - } - - - /** - * Sets the value of the 'character_name' field. - * @param value The value of 'character_name'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.stargate.StarGate.Builder setCharacterName(java.lang.CharSequence value) { - validate(fields()[0], value); - this.character_name = value; - fieldSetFlags()[0] = true; - return this; - } - - /** - * Checks whether the 'character_name' field has been set. - * @return True if the 'character_name' field has been set, false otherwise. - */ - public boolean hasCharacterName() { - return fieldSetFlags()[0]; - } - - - /** - * Clears the value of the 'character_name' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.stargate.StarGate.Builder clearCharacterName() { - character_name = null; - fieldSetFlags()[0] = false; - return this; - } - - /** - * Gets the value of the 'source_planet' field. - * @return The value. - */ - public java.lang.CharSequence getSourcePlanet() { - return source_planet; - } - - - /** - * Sets the value of the 'source_planet' field. - * @param value The value of 'source_planet'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.stargate.StarGate.Builder setSourcePlanet(java.lang.CharSequence value) { - validate(fields()[1], value); - this.source_planet = value; - fieldSetFlags()[1] = true; - return this; - } - - /** - * Checks whether the 'source_planet' field has been set. - * @return True if the 'source_planet' field has been set, false otherwise. - */ - public boolean hasSourcePlanet() { - return fieldSetFlags()[1]; - } - - - /** - * Clears the value of the 'source_planet' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.stargate.StarGate.Builder clearSourcePlanet() { - source_planet = null; - fieldSetFlags()[1] = false; - return this; - } - - /** - * Gets the value of the 'target_planet' field. - * @return The value. - */ - public java.lang.CharSequence getTargetPlanet() { - return target_planet; - } - - - /** - * Sets the value of the 'target_planet' field. - * @param value The value of 'target_planet'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.stargate.StarGate.Builder setTargetPlanet(java.lang.CharSequence value) { - validate(fields()[2], value); - this.target_planet = value; - fieldSetFlags()[2] = true; - return this; - } - - /** - * Checks whether the 'target_planet' field has been set. - * @return True if the 'target_planet' field has been set, false otherwise. - */ - public boolean hasTargetPlanet() { - return fieldSetFlags()[2]; - } - - - /** - * Clears the value of the 'target_planet' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.stargate.StarGate.Builder clearTargetPlanet() { - target_planet = null; - fieldSetFlags()[2] = false; - return this; - } - - /** - * Gets the value of the 'quote' field. - * @return The value. - */ - public java.lang.CharSequence getQuote() { - return quote; - } - - - /** - * Sets the value of the 'quote' field. - * @param value The value of 'quote'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.stargate.StarGate.Builder setQuote(java.lang.CharSequence value) { - validate(fields()[3], value); - this.quote = value; - fieldSetFlags()[3] = true; - return this; - } - - /** - * Checks whether the 'quote' field has been set. - * @return True if the 'quote' field has been set, false otherwise. - */ - public boolean hasQuote() { - return fieldSetFlags()[3]; - } - - - /** - * Clears the value of the 'quote' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.stargate.StarGate.Builder clearQuote() { - quote = null; - fieldSetFlags()[3] = false; - return this; - } - - /** - * Gets the value of the 'duration' field. - * @return The value. - */ - public int getDuration() { - return duration; - } - - - /** - * Sets the value of the 'duration' field. - * @param value The value of 'duration'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.stargate.StarGate.Builder setDuration(int value) { - validate(fields()[4], value); - this.duration = value; - fieldSetFlags()[4] = true; - return this; - } - - /** - * Checks whether the 'duration' field has been set. - * @return True if the 'duration' field has been set, false otherwise. - */ - public boolean hasDuration() { - return fieldSetFlags()[4]; - } - - - /** - * Clears the value of the 'duration' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.stargate.StarGate.Builder clearDuration() { - fieldSetFlags()[4] = false; - return this; - } - - /** - * Gets the value of the 'duration_unit' field. - * @return The value. - */ - public java.lang.CharSequence getDurationUnit() { - return duration_unit; - } - - - /** - * Sets the value of the 'duration_unit' field. - * @param value The value of 'duration_unit'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.stargate.StarGate.Builder setDurationUnit(java.lang.CharSequence value) { - validate(fields()[5], value); - this.duration_unit = value; - fieldSetFlags()[5] = true; - return this; - } - - /** - * Checks whether the 'duration_unit' field has been set. - * @return True if the 'duration_unit' field has been set, false otherwise. - */ - public boolean hasDurationUnit() { - return fieldSetFlags()[5]; - } - - - /** - * Clears the value of the 'duration_unit' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.stargate.StarGate.Builder clearDurationUnit() { - duration_unit = null; - fieldSetFlags()[5] = false; - return this; - } - - /** - * Gets the value of the 'distance' field. - * @return The value. - */ - public int getDistance() { - return distance; - } - - - /** - * Sets the value of the 'distance' field. - * @param value The value of 'distance'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.stargate.StarGate.Builder setDistance(int value) { - validate(fields()[6], value); - this.distance = value; - fieldSetFlags()[6] = true; - return this; - } - - /** - * Checks whether the 'distance' field has been set. - * @return True if the 'distance' field has been set, false otherwise. - */ - public boolean hasDistance() { - return fieldSetFlags()[6]; - } - - - /** - * Clears the value of the 'distance' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.stargate.StarGate.Builder clearDistance() { - fieldSetFlags()[6] = false; - return this; - } - - /** - * Gets the value of the 'distance_unit' field. - * @return The value. - */ - public java.lang.CharSequence getDistanceUnit() { - return distance_unit; - } - - - /** - * Sets the value of the 'distance_unit' field. - * @param value The value of 'distance_unit'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.stargate.StarGate.Builder setDistanceUnit(java.lang.CharSequence value) { - validate(fields()[7], value); - this.distance_unit = value; - fieldSetFlags()[7] = true; - return this; - } - - /** - * Checks whether the 'distance_unit' field has been set. - * @return True if the 'distance_unit' field has been set, false otherwise. - */ - public boolean hasDistanceUnit() { - return fieldSetFlags()[7]; - } - - - /** - * Clears the value of the 'distance_unit' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.stargate.StarGate.Builder clearDistanceUnit() { - distance_unit = null; - fieldSetFlags()[7] = false; - return this; - } - - @Override - @SuppressWarnings("unchecked") - public StarGate build() { - try { - StarGate record = new StarGate(); - record.character_name = fieldSetFlags()[0] ? this.character_name : (java.lang.CharSequence) defaultValue(fields()[0]); - record.source_planet = fieldSetFlags()[1] ? this.source_planet : (java.lang.CharSequence) defaultValue(fields()[1]); - record.target_planet = fieldSetFlags()[2] ? this.target_planet : (java.lang.CharSequence) defaultValue(fields()[2]); - record.quote = fieldSetFlags()[3] ? this.quote : (java.lang.CharSequence) defaultValue(fields()[3]); - record.duration = fieldSetFlags()[4] ? this.duration : (java.lang.Integer) defaultValue(fields()[4]); - record.duration_unit = fieldSetFlags()[5] ? this.duration_unit : (java.lang.CharSequence) defaultValue(fields()[5]); - record.distance = fieldSetFlags()[6] ? this.distance : (java.lang.Integer) defaultValue(fields()[6]); - record.distance_unit = fieldSetFlags()[7] ? this.distance_unit : (java.lang.CharSequence) defaultValue(fields()[7]); - return record; - } catch (org.apache.avro.AvroMissingFieldException e) { - throw e; - } catch (java.lang.Exception e) { - throw new org.apache.avro.AvroRuntimeException(e); - } - } - } - - @SuppressWarnings("unchecked") - private static final org.apache.avro.io.DatumWriter - WRITER$ = (org.apache.avro.io.DatumWriter)MODEL$.createDatumWriter(SCHEMA$); - - @Override public void writeExternal(java.io.ObjectOutput out) - throws java.io.IOException { - WRITER$.write(this, SpecificData.getEncoder(out)); - } - - @SuppressWarnings("unchecked") - private static final org.apache.avro.io.DatumReader - READER$ = (org.apache.avro.io.DatumReader)MODEL$.createDatumReader(SCHEMA$); - - @Override public void readExternal(java.io.ObjectInput in) - throws java.io.IOException { - READER$.read(this, SpecificData.getDecoder(in)); - } - - @Override protected boolean hasCustomCoders() { return true; } - - @Override public void customEncode(org.apache.avro.io.Encoder out) - throws java.io.IOException - { - out.writeString(this.character_name); - - out.writeString(this.source_planet); - - out.writeString(this.target_planet); - - out.writeString(this.quote); - - out.writeInt(this.duration); - - out.writeString(this.duration_unit); - - out.writeInt(this.distance); - - out.writeString(this.distance_unit); - - } - - @Override public void customDecode(org.apache.avro.io.ResolvingDecoder in) - throws java.io.IOException - { - org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff(); - if (fieldOrder == null) { - this.character_name = in.readString(this.character_name instanceof Utf8 ? (Utf8)this.character_name : null); - - this.source_planet = in.readString(this.source_planet instanceof Utf8 ? (Utf8)this.source_planet : null); - - this.target_planet = in.readString(this.target_planet instanceof Utf8 ? (Utf8)this.target_planet : null); - - this.quote = in.readString(this.quote instanceof Utf8 ? (Utf8)this.quote : null); - - this.duration = in.readInt(); - - this.duration_unit = in.readString(this.duration_unit instanceof Utf8 ? (Utf8)this.duration_unit : null); - - this.distance = in.readInt(); - - this.distance_unit = in.readString(this.distance_unit instanceof Utf8 ? (Utf8)this.distance_unit : null); - - } else { - for (int i = 0; i < 8; i++) { - switch (fieldOrder[i].pos()) { - case 0: - this.character_name = in.readString(this.character_name instanceof Utf8 ? (Utf8)this.character_name : null); - break; - - case 1: - this.source_planet = in.readString(this.source_planet instanceof Utf8 ? (Utf8)this.source_planet : null); - break; - - case 2: - this.target_planet = in.readString(this.target_planet instanceof Utf8 ? (Utf8)this.target_planet : null); - break; - - case 3: - this.quote = in.readString(this.quote instanceof Utf8 ? (Utf8)this.quote : null); - break; - - case 4: - this.duration = in.readInt(); - break; - - case 5: - this.duration_unit = in.readString(this.duration_unit instanceof Utf8 ? (Utf8)this.duration_unit : null); - break; - - case 6: - this.distance = in.readInt(); - break; - - case 7: - this.distance_unit = in.readString(this.distance_unit instanceof Utf8 ? (Utf8)this.distance_unit : null); - break; - - default: - throw new java.io.IOException("Corrupt ResolvingDecoder."); - } - } - } - } -} - - - - - - - - - - diff --git a/src/main/java/io/skodjob/datagenerator/models/starwars/StarWars.java b/src/main/java/io/skodjob/datagenerator/models/starwars/StarWars.java deleted file mode 100644 index 89a4564..0000000 --- a/src/main/java/io/skodjob/datagenerator/models/starwars/StarWars.java +++ /dev/null @@ -1,959 +0,0 @@ -/** - * Autogenerated by Avro - * - * DO NOT EDIT DIRECTLY - */ -package io.skodjob.datagenerator.models.starwars; - -import org.apache.avro.generic.GenericArray; -import org.apache.avro.specific.SpecificData; -import org.apache.avro.util.Utf8; -import org.apache.avro.message.BinaryMessageEncoder; -import org.apache.avro.message.BinaryMessageDecoder; -import org.apache.avro.message.SchemaStore; - -@org.apache.avro.specific.AvroGenerated -public class StarWars extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord { - private static final long serialVersionUID = -1351044176025905925L; - - - public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"StarWars\",\"namespace\":\"io.skodjob.datagenerator.models.starwars\",\"fields\":[{\"name\":\"character_name\",\"type\":\"string\"},{\"name\":\"source_planet\",\"type\":\"string\"},{\"name\":\"target_planet\",\"type\":\"string\"},{\"name\":\"quote\",\"type\":\"string\"},{\"name\":\"callSign\",\"type\":\"string\"},{\"name\":\"species\",\"type\":\"string\"},{\"name\":\"vehicle\",\"type\":\"string\"},{\"name\":\"wookieWords\",\"type\":\"string\"},{\"name\":\"alternateCharacterSpelling\",\"type\":\"string\"}]}"); - public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } - - private static final SpecificData MODEL$ = new SpecificData(); - - private static final BinaryMessageEncoder ENCODER = - new BinaryMessageEncoder<>(MODEL$, SCHEMA$); - - private static final BinaryMessageDecoder DECODER = - new BinaryMessageDecoder<>(MODEL$, SCHEMA$); - - /** - * Return the BinaryMessageEncoder instance used by this class. - * @return the message encoder used by this class - */ - public static BinaryMessageEncoder getEncoder() { - return ENCODER; - } - - /** - * Return the BinaryMessageDecoder instance used by this class. - * @return the message decoder used by this class - */ - public static BinaryMessageDecoder getDecoder() { - return DECODER; - } - - /** - * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}. - * @param resolver a {@link SchemaStore} used to find schemas by fingerprint - * @return a BinaryMessageDecoder instance for this class backed by the given SchemaStore - */ - public static BinaryMessageDecoder createDecoder(SchemaStore resolver) { - return new BinaryMessageDecoder<>(MODEL$, SCHEMA$, resolver); - } - - /** - * Serializes this StarWars to a ByteBuffer. - * @return a buffer holding the serialized data for this instance - * @throws java.io.IOException if this instance could not be serialized - */ - public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException { - return ENCODER.encode(this); - } - - /** - * Deserializes a StarWars from a ByteBuffer. - * @param b a byte buffer holding serialized data for an instance of this class - * @return a StarWars instance decoded from the given buffer - * @throws java.io.IOException if the given bytes could not be deserialized into an instance of this class - */ - public static StarWars fromByteBuffer( - java.nio.ByteBuffer b) throws java.io.IOException { - return DECODER.decode(b); - } - - private java.lang.CharSequence character_name; - private java.lang.CharSequence source_planet; - private java.lang.CharSequence target_planet; - private java.lang.CharSequence quote; - private java.lang.CharSequence callSign; - private java.lang.CharSequence species; - private java.lang.CharSequence vehicle; - private java.lang.CharSequence wookieWords; - private java.lang.CharSequence alternateCharacterSpelling; - - /** - * Default constructor. Note that this does not initialize fields - * to their default values from the schema. If that is desired then - * one should use newBuilder(). - */ - public StarWars() {} - - /** - * All-args constructor. - * @param character_name The new value for character_name - * @param source_planet The new value for source_planet - * @param target_planet The new value for target_planet - * @param quote The new value for quote - * @param callSign The new value for callSign - * @param species The new value for species - * @param vehicle The new value for vehicle - * @param wookieWords The new value for wookieWords - * @param alternateCharacterSpelling The new value for alternateCharacterSpelling - */ - public StarWars(java.lang.CharSequence character_name, java.lang.CharSequence source_planet, java.lang.CharSequence target_planet, java.lang.CharSequence quote, java.lang.CharSequence callSign, java.lang.CharSequence species, java.lang.CharSequence vehicle, java.lang.CharSequence wookieWords, java.lang.CharSequence alternateCharacterSpelling) { - this.character_name = character_name; - this.source_planet = source_planet; - this.target_planet = target_planet; - this.quote = quote; - this.callSign = callSign; - this.species = species; - this.vehicle = vehicle; - this.wookieWords = wookieWords; - this.alternateCharacterSpelling = alternateCharacterSpelling; - } - - @Override - public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; } - - @Override - public org.apache.avro.Schema getSchema() { return SCHEMA$; } - - // Used by DatumWriter. Applications should not call. - @Override - public java.lang.Object get(int field$) { - switch (field$) { - case 0: return character_name; - case 1: return source_planet; - case 2: return target_planet; - case 3: return quote; - case 4: return callSign; - case 5: return species; - case 6: return vehicle; - case 7: return wookieWords; - case 8: return alternateCharacterSpelling; - default: throw new IndexOutOfBoundsException("Invalid index: " + field$); - } - } - - // Used by DatumReader. Applications should not call. - @Override - @SuppressWarnings(value="unchecked") - public void put(int field$, java.lang.Object value$) { - switch (field$) { - case 0: character_name = (java.lang.CharSequence)value$; break; - case 1: source_planet = (java.lang.CharSequence)value$; break; - case 2: target_planet = (java.lang.CharSequence)value$; break; - case 3: quote = (java.lang.CharSequence)value$; break; - case 4: callSign = (java.lang.CharSequence)value$; break; - case 5: species = (java.lang.CharSequence)value$; break; - case 6: vehicle = (java.lang.CharSequence)value$; break; - case 7: wookieWords = (java.lang.CharSequence)value$; break; - case 8: alternateCharacterSpelling = (java.lang.CharSequence)value$; break; - default: throw new IndexOutOfBoundsException("Invalid index: " + field$); - } - } - - /** - * Gets the value of the 'character_name' field. - * @return The value of the 'character_name' field. - */ - public java.lang.CharSequence getCharacterName() { - return character_name; - } - - - /** - * Sets the value of the 'character_name' field. - * @param value the value to set. - */ - public void setCharacterName(java.lang.CharSequence value) { - this.character_name = value; - } - - /** - * Gets the value of the 'source_planet' field. - * @return The value of the 'source_planet' field. - */ - public java.lang.CharSequence getSourcePlanet() { - return source_planet; - } - - - /** - * Sets the value of the 'source_planet' field. - * @param value the value to set. - */ - public void setSourcePlanet(java.lang.CharSequence value) { - this.source_planet = value; - } - - /** - * Gets the value of the 'target_planet' field. - * @return The value of the 'target_planet' field. - */ - public java.lang.CharSequence getTargetPlanet() { - return target_planet; - } - - - /** - * Sets the value of the 'target_planet' field. - * @param value the value to set. - */ - public void setTargetPlanet(java.lang.CharSequence value) { - this.target_planet = value; - } - - /** - * Gets the value of the 'quote' field. - * @return The value of the 'quote' field. - */ - public java.lang.CharSequence getQuote() { - return quote; - } - - - /** - * Sets the value of the 'quote' field. - * @param value the value to set. - */ - public void setQuote(java.lang.CharSequence value) { - this.quote = value; - } - - /** - * Gets the value of the 'callSign' field. - * @return The value of the 'callSign' field. - */ - public java.lang.CharSequence getCallSign() { - return callSign; - } - - - /** - * Sets the value of the 'callSign' field. - * @param value the value to set. - */ - public void setCallSign(java.lang.CharSequence value) { - this.callSign = value; - } - - /** - * Gets the value of the 'species' field. - * @return The value of the 'species' field. - */ - public java.lang.CharSequence getSpecies() { - return species; - } - - - /** - * Sets the value of the 'species' field. - * @param value the value to set. - */ - public void setSpecies(java.lang.CharSequence value) { - this.species = value; - } - - /** - * Gets the value of the 'vehicle' field. - * @return The value of the 'vehicle' field. - */ - public java.lang.CharSequence getVehicle() { - return vehicle; - } - - - /** - * Sets the value of the 'vehicle' field. - * @param value the value to set. - */ - public void setVehicle(java.lang.CharSequence value) { - this.vehicle = value; - } - - /** - * Gets the value of the 'wookieWords' field. - * @return The value of the 'wookieWords' field. - */ - public java.lang.CharSequence getWookieWords() { - return wookieWords; - } - - - /** - * Sets the value of the 'wookieWords' field. - * @param value the value to set. - */ - public void setWookieWords(java.lang.CharSequence value) { - this.wookieWords = value; - } - - /** - * Gets the value of the 'alternateCharacterSpelling' field. - * @return The value of the 'alternateCharacterSpelling' field. - */ - public java.lang.CharSequence getAlternateCharacterSpelling() { - return alternateCharacterSpelling; - } - - - /** - * Sets the value of the 'alternateCharacterSpelling' field. - * @param value the value to set. - */ - public void setAlternateCharacterSpelling(java.lang.CharSequence value) { - this.alternateCharacterSpelling = value; - } - - /** - * Creates a new StarWars RecordBuilder. - * @return A new StarWars RecordBuilder - */ - public static io.skodjob.datagenerator.models.starwars.StarWars.Builder newBuilder() { - return new io.skodjob.datagenerator.models.starwars.StarWars.Builder(); - } - - /** - * Creates a new StarWars RecordBuilder by copying an existing Builder. - * @param other The existing builder to copy. - * @return A new StarWars RecordBuilder - */ - public static io.skodjob.datagenerator.models.starwars.StarWars.Builder newBuilder(io.skodjob.datagenerator.models.starwars.StarWars.Builder other) { - if (other == null) { - return new io.skodjob.datagenerator.models.starwars.StarWars.Builder(); - } else { - return new io.skodjob.datagenerator.models.starwars.StarWars.Builder(other); - } - } - - /** - * Creates a new StarWars RecordBuilder by copying an existing StarWars instance. - * @param other The existing instance to copy. - * @return A new StarWars RecordBuilder - */ - public static io.skodjob.datagenerator.models.starwars.StarWars.Builder newBuilder(io.skodjob.datagenerator.models.starwars.StarWars other) { - if (other == null) { - return new io.skodjob.datagenerator.models.starwars.StarWars.Builder(); - } else { - return new io.skodjob.datagenerator.models.starwars.StarWars.Builder(other); - } - } - - /** - * RecordBuilder for StarWars instances. - */ - @org.apache.avro.specific.AvroGenerated - public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase - implements org.apache.avro.data.RecordBuilder { - - private java.lang.CharSequence character_name; - private java.lang.CharSequence source_planet; - private java.lang.CharSequence target_planet; - private java.lang.CharSequence quote; - private java.lang.CharSequence callSign; - private java.lang.CharSequence species; - private java.lang.CharSequence vehicle; - private java.lang.CharSequence wookieWords; - private java.lang.CharSequence alternateCharacterSpelling; - - /** Creates a new Builder */ - private Builder() { - super(SCHEMA$, MODEL$); - } - - /** - * Creates a Builder by copying an existing Builder. - * @param other The existing Builder to copy. - */ - private Builder(io.skodjob.datagenerator.models.starwars.StarWars.Builder other) { - super(other); - if (isValidValue(fields()[0], other.character_name)) { - this.character_name = data().deepCopy(fields()[0].schema(), other.character_name); - fieldSetFlags()[0] = other.fieldSetFlags()[0]; - } - if (isValidValue(fields()[1], other.source_planet)) { - this.source_planet = data().deepCopy(fields()[1].schema(), other.source_planet); - fieldSetFlags()[1] = other.fieldSetFlags()[1]; - } - if (isValidValue(fields()[2], other.target_planet)) { - this.target_planet = data().deepCopy(fields()[2].schema(), other.target_planet); - fieldSetFlags()[2] = other.fieldSetFlags()[2]; - } - if (isValidValue(fields()[3], other.quote)) { - this.quote = data().deepCopy(fields()[3].schema(), other.quote); - fieldSetFlags()[3] = other.fieldSetFlags()[3]; - } - if (isValidValue(fields()[4], other.callSign)) { - this.callSign = data().deepCopy(fields()[4].schema(), other.callSign); - fieldSetFlags()[4] = other.fieldSetFlags()[4]; - } - if (isValidValue(fields()[5], other.species)) { - this.species = data().deepCopy(fields()[5].schema(), other.species); - fieldSetFlags()[5] = other.fieldSetFlags()[5]; - } - if (isValidValue(fields()[6], other.vehicle)) { - this.vehicle = data().deepCopy(fields()[6].schema(), other.vehicle); - fieldSetFlags()[6] = other.fieldSetFlags()[6]; - } - if (isValidValue(fields()[7], other.wookieWords)) { - this.wookieWords = data().deepCopy(fields()[7].schema(), other.wookieWords); - fieldSetFlags()[7] = other.fieldSetFlags()[7]; - } - if (isValidValue(fields()[8], other.alternateCharacterSpelling)) { - this.alternateCharacterSpelling = data().deepCopy(fields()[8].schema(), other.alternateCharacterSpelling); - fieldSetFlags()[8] = other.fieldSetFlags()[8]; - } - } - - /** - * Creates a Builder by copying an existing StarWars instance - * @param other The existing instance to copy. - */ - private Builder(io.skodjob.datagenerator.models.starwars.StarWars other) { - super(SCHEMA$, MODEL$); - if (isValidValue(fields()[0], other.character_name)) { - this.character_name = data().deepCopy(fields()[0].schema(), other.character_name); - fieldSetFlags()[0] = true; - } - if (isValidValue(fields()[1], other.source_planet)) { - this.source_planet = data().deepCopy(fields()[1].schema(), other.source_planet); - fieldSetFlags()[1] = true; - } - if (isValidValue(fields()[2], other.target_planet)) { - this.target_planet = data().deepCopy(fields()[2].schema(), other.target_planet); - fieldSetFlags()[2] = true; - } - if (isValidValue(fields()[3], other.quote)) { - this.quote = data().deepCopy(fields()[3].schema(), other.quote); - fieldSetFlags()[3] = true; - } - if (isValidValue(fields()[4], other.callSign)) { - this.callSign = data().deepCopy(fields()[4].schema(), other.callSign); - fieldSetFlags()[4] = true; - } - if (isValidValue(fields()[5], other.species)) { - this.species = data().deepCopy(fields()[5].schema(), other.species); - fieldSetFlags()[5] = true; - } - if (isValidValue(fields()[6], other.vehicle)) { - this.vehicle = data().deepCopy(fields()[6].schema(), other.vehicle); - fieldSetFlags()[6] = true; - } - if (isValidValue(fields()[7], other.wookieWords)) { - this.wookieWords = data().deepCopy(fields()[7].schema(), other.wookieWords); - fieldSetFlags()[7] = true; - } - if (isValidValue(fields()[8], other.alternateCharacterSpelling)) { - this.alternateCharacterSpelling = data().deepCopy(fields()[8].schema(), other.alternateCharacterSpelling); - fieldSetFlags()[8] = true; - } - } - - /** - * Gets the value of the 'character_name' field. - * @return The value. - */ - public java.lang.CharSequence getCharacterName() { - return character_name; - } - - - /** - * Sets the value of the 'character_name' field. - * @param value The value of 'character_name'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.starwars.StarWars.Builder setCharacterName(java.lang.CharSequence value) { - validate(fields()[0], value); - this.character_name = value; - fieldSetFlags()[0] = true; - return this; - } - - /** - * Checks whether the 'character_name' field has been set. - * @return True if the 'character_name' field has been set, false otherwise. - */ - public boolean hasCharacterName() { - return fieldSetFlags()[0]; - } - - - /** - * Clears the value of the 'character_name' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.starwars.StarWars.Builder clearCharacterName() { - character_name = null; - fieldSetFlags()[0] = false; - return this; - } - - /** - * Gets the value of the 'source_planet' field. - * @return The value. - */ - public java.lang.CharSequence getSourcePlanet() { - return source_planet; - } - - - /** - * Sets the value of the 'source_planet' field. - * @param value The value of 'source_planet'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.starwars.StarWars.Builder setSourcePlanet(java.lang.CharSequence value) { - validate(fields()[1], value); - this.source_planet = value; - fieldSetFlags()[1] = true; - return this; - } - - /** - * Checks whether the 'source_planet' field has been set. - * @return True if the 'source_planet' field has been set, false otherwise. - */ - public boolean hasSourcePlanet() { - return fieldSetFlags()[1]; - } - - - /** - * Clears the value of the 'source_planet' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.starwars.StarWars.Builder clearSourcePlanet() { - source_planet = null; - fieldSetFlags()[1] = false; - return this; - } - - /** - * Gets the value of the 'target_planet' field. - * @return The value. - */ - public java.lang.CharSequence getTargetPlanet() { - return target_planet; - } - - - /** - * Sets the value of the 'target_planet' field. - * @param value The value of 'target_planet'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.starwars.StarWars.Builder setTargetPlanet(java.lang.CharSequence value) { - validate(fields()[2], value); - this.target_planet = value; - fieldSetFlags()[2] = true; - return this; - } - - /** - * Checks whether the 'target_planet' field has been set. - * @return True if the 'target_planet' field has been set, false otherwise. - */ - public boolean hasTargetPlanet() { - return fieldSetFlags()[2]; - } - - - /** - * Clears the value of the 'target_planet' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.starwars.StarWars.Builder clearTargetPlanet() { - target_planet = null; - fieldSetFlags()[2] = false; - return this; - } - - /** - * Gets the value of the 'quote' field. - * @return The value. - */ - public java.lang.CharSequence getQuote() { - return quote; - } - - - /** - * Sets the value of the 'quote' field. - * @param value The value of 'quote'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.starwars.StarWars.Builder setQuote(java.lang.CharSequence value) { - validate(fields()[3], value); - this.quote = value; - fieldSetFlags()[3] = true; - return this; - } - - /** - * Checks whether the 'quote' field has been set. - * @return True if the 'quote' field has been set, false otherwise. - */ - public boolean hasQuote() { - return fieldSetFlags()[3]; - } - - - /** - * Clears the value of the 'quote' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.starwars.StarWars.Builder clearQuote() { - quote = null; - fieldSetFlags()[3] = false; - return this; - } - - /** - * Gets the value of the 'callSign' field. - * @return The value. - */ - public java.lang.CharSequence getCallSign() { - return callSign; - } - - - /** - * Sets the value of the 'callSign' field. - * @param value The value of 'callSign'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.starwars.StarWars.Builder setCallSign(java.lang.CharSequence value) { - validate(fields()[4], value); - this.callSign = value; - fieldSetFlags()[4] = true; - return this; - } - - /** - * Checks whether the 'callSign' field has been set. - * @return True if the 'callSign' field has been set, false otherwise. - */ - public boolean hasCallSign() { - return fieldSetFlags()[4]; - } - - - /** - * Clears the value of the 'callSign' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.starwars.StarWars.Builder clearCallSign() { - callSign = null; - fieldSetFlags()[4] = false; - return this; - } - - /** - * Gets the value of the 'species' field. - * @return The value. - */ - public java.lang.CharSequence getSpecies() { - return species; - } - - - /** - * Sets the value of the 'species' field. - * @param value The value of 'species'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.starwars.StarWars.Builder setSpecies(java.lang.CharSequence value) { - validate(fields()[5], value); - this.species = value; - fieldSetFlags()[5] = true; - return this; - } - - /** - * Checks whether the 'species' field has been set. - * @return True if the 'species' field has been set, false otherwise. - */ - public boolean hasSpecies() { - return fieldSetFlags()[5]; - } - - - /** - * Clears the value of the 'species' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.starwars.StarWars.Builder clearSpecies() { - species = null; - fieldSetFlags()[5] = false; - return this; - } - - /** - * Gets the value of the 'vehicle' field. - * @return The value. - */ - public java.lang.CharSequence getVehicle() { - return vehicle; - } - - - /** - * Sets the value of the 'vehicle' field. - * @param value The value of 'vehicle'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.starwars.StarWars.Builder setVehicle(java.lang.CharSequence value) { - validate(fields()[6], value); - this.vehicle = value; - fieldSetFlags()[6] = true; - return this; - } - - /** - * Checks whether the 'vehicle' field has been set. - * @return True if the 'vehicle' field has been set, false otherwise. - */ - public boolean hasVehicle() { - return fieldSetFlags()[6]; - } - - - /** - * Clears the value of the 'vehicle' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.starwars.StarWars.Builder clearVehicle() { - vehicle = null; - fieldSetFlags()[6] = false; - return this; - } - - /** - * Gets the value of the 'wookieWords' field. - * @return The value. - */ - public java.lang.CharSequence getWookieWords() { - return wookieWords; - } - - - /** - * Sets the value of the 'wookieWords' field. - * @param value The value of 'wookieWords'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.starwars.StarWars.Builder setWookieWords(java.lang.CharSequence value) { - validate(fields()[7], value); - this.wookieWords = value; - fieldSetFlags()[7] = true; - return this; - } - - /** - * Checks whether the 'wookieWords' field has been set. - * @return True if the 'wookieWords' field has been set, false otherwise. - */ - public boolean hasWookieWords() { - return fieldSetFlags()[7]; - } - - - /** - * Clears the value of the 'wookieWords' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.starwars.StarWars.Builder clearWookieWords() { - wookieWords = null; - fieldSetFlags()[7] = false; - return this; - } - - /** - * Gets the value of the 'alternateCharacterSpelling' field. - * @return The value. - */ - public java.lang.CharSequence getAlternateCharacterSpelling() { - return alternateCharacterSpelling; - } - - - /** - * Sets the value of the 'alternateCharacterSpelling' field. - * @param value The value of 'alternateCharacterSpelling'. - * @return This builder. - */ - public io.skodjob.datagenerator.models.starwars.StarWars.Builder setAlternateCharacterSpelling(java.lang.CharSequence value) { - validate(fields()[8], value); - this.alternateCharacterSpelling = value; - fieldSetFlags()[8] = true; - return this; - } - - /** - * Checks whether the 'alternateCharacterSpelling' field has been set. - * @return True if the 'alternateCharacterSpelling' field has been set, false otherwise. - */ - public boolean hasAlternateCharacterSpelling() { - return fieldSetFlags()[8]; - } - - - /** - * Clears the value of the 'alternateCharacterSpelling' field. - * @return This builder. - */ - public io.skodjob.datagenerator.models.starwars.StarWars.Builder clearAlternateCharacterSpelling() { - alternateCharacterSpelling = null; - fieldSetFlags()[8] = false; - return this; - } - - @Override - @SuppressWarnings("unchecked") - public StarWars build() { - try { - StarWars record = new StarWars(); - record.character_name = fieldSetFlags()[0] ? this.character_name : (java.lang.CharSequence) defaultValue(fields()[0]); - record.source_planet = fieldSetFlags()[1] ? this.source_planet : (java.lang.CharSequence) defaultValue(fields()[1]); - record.target_planet = fieldSetFlags()[2] ? this.target_planet : (java.lang.CharSequence) defaultValue(fields()[2]); - record.quote = fieldSetFlags()[3] ? this.quote : (java.lang.CharSequence) defaultValue(fields()[3]); - record.callSign = fieldSetFlags()[4] ? this.callSign : (java.lang.CharSequence) defaultValue(fields()[4]); - record.species = fieldSetFlags()[5] ? this.species : (java.lang.CharSequence) defaultValue(fields()[5]); - record.vehicle = fieldSetFlags()[6] ? this.vehicle : (java.lang.CharSequence) defaultValue(fields()[6]); - record.wookieWords = fieldSetFlags()[7] ? this.wookieWords : (java.lang.CharSequence) defaultValue(fields()[7]); - record.alternateCharacterSpelling = fieldSetFlags()[8] ? this.alternateCharacterSpelling : (java.lang.CharSequence) defaultValue(fields()[8]); - return record; - } catch (org.apache.avro.AvroMissingFieldException e) { - throw e; - } catch (java.lang.Exception e) { - throw new org.apache.avro.AvroRuntimeException(e); - } - } - } - - @SuppressWarnings("unchecked") - private static final org.apache.avro.io.DatumWriter - WRITER$ = (org.apache.avro.io.DatumWriter)MODEL$.createDatumWriter(SCHEMA$); - - @Override public void writeExternal(java.io.ObjectOutput out) - throws java.io.IOException { - WRITER$.write(this, SpecificData.getEncoder(out)); - } - - @SuppressWarnings("unchecked") - private static final org.apache.avro.io.DatumReader - READER$ = (org.apache.avro.io.DatumReader)MODEL$.createDatumReader(SCHEMA$); - - @Override public void readExternal(java.io.ObjectInput in) - throws java.io.IOException { - READER$.read(this, SpecificData.getDecoder(in)); - } - - @Override protected boolean hasCustomCoders() { return true; } - - @Override public void customEncode(org.apache.avro.io.Encoder out) - throws java.io.IOException - { - out.writeString(this.character_name); - - out.writeString(this.source_planet); - - out.writeString(this.target_planet); - - out.writeString(this.quote); - - out.writeString(this.callSign); - - out.writeString(this.species); - - out.writeString(this.vehicle); - - out.writeString(this.wookieWords); - - out.writeString(this.alternateCharacterSpelling); - - } - - @Override public void customDecode(org.apache.avro.io.ResolvingDecoder in) - throws java.io.IOException - { - org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff(); - if (fieldOrder == null) { - this.character_name = in.readString(this.character_name instanceof Utf8 ? (Utf8)this.character_name : null); - - this.source_planet = in.readString(this.source_planet instanceof Utf8 ? (Utf8)this.source_planet : null); - - this.target_planet = in.readString(this.target_planet instanceof Utf8 ? (Utf8)this.target_planet : null); - - this.quote = in.readString(this.quote instanceof Utf8 ? (Utf8)this.quote : null); - - this.callSign = in.readString(this.callSign instanceof Utf8 ? (Utf8)this.callSign : null); - - this.species = in.readString(this.species instanceof Utf8 ? (Utf8)this.species : null); - - this.vehicle = in.readString(this.vehicle instanceof Utf8 ? (Utf8)this.vehicle : null); - - this.wookieWords = in.readString(this.wookieWords instanceof Utf8 ? (Utf8)this.wookieWords : null); - - this.alternateCharacterSpelling = in.readString(this.alternateCharacterSpelling instanceof Utf8 ? (Utf8)this.alternateCharacterSpelling : null); - - } else { - for (int i = 0; i < 9; i++) { - switch (fieldOrder[i].pos()) { - case 0: - this.character_name = in.readString(this.character_name instanceof Utf8 ? (Utf8)this.character_name : null); - break; - - case 1: - this.source_planet = in.readString(this.source_planet instanceof Utf8 ? (Utf8)this.source_planet : null); - break; - - case 2: - this.target_planet = in.readString(this.target_planet instanceof Utf8 ? (Utf8)this.target_planet : null); - break; - - case 3: - this.quote = in.readString(this.quote instanceof Utf8 ? (Utf8)this.quote : null); - break; - - case 4: - this.callSign = in.readString(this.callSign instanceof Utf8 ? (Utf8)this.callSign : null); - break; - - case 5: - this.species = in.readString(this.species instanceof Utf8 ? (Utf8)this.species : null); - break; - - case 6: - this.vehicle = in.readString(this.vehicle instanceof Utf8 ? (Utf8)this.vehicle : null); - break; - - case 7: - this.wookieWords = in.readString(this.wookieWords instanceof Utf8 ? (Utf8)this.wookieWords : null); - break; - - case 8: - this.alternateCharacterSpelling = in.readString(this.alternateCharacterSpelling instanceof Utf8 ? (Utf8)this.alternateCharacterSpelling : null); - break; - - default: - throw new java.io.IOException("Corrupt ResolvingDecoder."); - } - } - } - } -} - - - - - - - - - -