@Override
  public void serialize(Dataset dataset, JsonGenerator gen, SerializerProvider serializers) throws IOException {
    gen.writeStartObject();

    // Use reflection to get all fields of the Dataset class
    Field[] fields = Dataset.class.getDeclaredFields();
    for (Field field : fields) {
      if (field.isAnnotationPresent(JsonProperty.class)) {
        try {
          field.setAccessible(true);
          Object value = field.get(dataset);
          if (value != null) {
            gen.writeObjectField(field.getAnnotation(JsonProperty.class).value(), value);
          }
        } catch (IllegalAccessException e) {
          throw new IOException("Error accessing field: " + field.getName(), e);
        }
      }
    }
    gen.writeEndObject();
  }
Checks if any required fields is missing for a {@link Dataset} or for any incompatible settings.
@param accountName The name of the account. Cannot be null.
@param containerName The name of the container. Cannot be null.
@param datasetName The name of the dataset. Cannot be null.
@param retentionPolicy The retention policy of the dataset, can be null.
ambry-api/src/main/java/com/github/ambry/account/Dataset.java