private Optional<com.homeaway.streamplatform.streamregistry.model.Producer> registerProducer(AvroStream avroStream, String producerName, String region) { if (!regionDao.getSupportedRegions(avroStream.getTags().getHint()).contains(region)) throw new UnknownRegionException(region); List<com.homeaway.digitalplatform.streamregistry.Producer> listProducers = avroStream.getProducers(); if (listProducers == null) { listProducers = new ArrayList<>(); } com.homeaway.digitalplatform.streamregistry.Producer producer = com.homeaway.digitalplatform.streamregistry.Producer.newBuilder() .setActor(Actor.newBuilder() .setName(producerName) .build()) .build(); String streamHint = avroStream.getTags().getHint(); String hint = (streamHint == null || streamHint.trim().matches("(?i:string)?")) ? AbstractDao.PRIMARY_HINT : streamHint.trim().toLowerCase(); Actor actor = populateActorStreamConfig(avroStream.getName(), region, producer.getActor(), OPERATION.CREATE.name(), topicPostFixes, hint, ACTOR_TYPE, avroStream.getTopicConfig()); Producer newProducer = com.homeaway.digitalplatform.streamregistry.Producer.newBuilder() .setActor(actor) .build(); listProducers.add(newProducer); avroStream.setProducers(listProducers); updateAvroStream(avroStream); return Optional.of(AvroToJsonDTO.getJsonProducer(newProducer)); }
/** * Creates a Builder by copying an existing Builder. * @param other The existing Builder to copy. */ private Builder(com.homeaway.digitalplatform.streamregistry.Producer.Builder other) { super(other); if (isValidValue(fields()[0], other.actor)) { this.actor = data().deepCopy(fields()[0].schema(), other.actor); fieldSetFlags()[0] = true; } if (other.hasActorBuilder()) { this.actorBuilder = com.homeaway.digitalplatform.streamregistry.Actor.newBuilder(other.getActorBuilder()); } }
@Override @SuppressWarnings("unchecked") public Producer build() { try { Producer record = new Producer(); if (actorBuilder != null) { record.actor = this.actorBuilder.build(); } else { record.actor = fieldSetFlags()[0] ? this.actor : (com.homeaway.digitalplatform.streamregistry.Actor) defaultValue(fields()[0]); } return record; } catch (java.lang.Exception e) { throw new org.apache.avro.AvroRuntimeException(e); } } }
/** * Gets the Builder instance for the 'actor' field and creates one if it doesn't exist yet. * * Actor configuration for the producer * @return This builder. */ public com.homeaway.digitalplatform.streamregistry.Actor.Builder getActorBuilder() { if (actorBuilder == null) { if (hasActor()) { setActorBuilder(com.homeaway.digitalplatform.streamregistry.Actor.newBuilder(actor)); } else { setActorBuilder(com.homeaway.digitalplatform.streamregistry.Actor.newBuilder()); } } return actorBuilder; }
/** * Sets the value of the 'actor' field. * * Actor configuration for the producer * @param value The value of 'actor'. * @return This builder. */ public com.homeaway.digitalplatform.streamregistry.Producer.Builder setActor(com.homeaway.digitalplatform.streamregistry.Actor value) { validate(fields()[0], value); this.actorBuilder = null; this.actor = value; fieldSetFlags()[0] = true; return this; }
/** * Checks whether the 'actor' field has been set. * * Actor configuration for the producer * @return True if the 'actor' field has been set, false otherwise. */ public boolean hasActor() { return fieldSetFlags()[0]; }
/** * Creates a new Producer RecordBuilder by copying an existing Builder. * @param other The existing builder to copy. * @return A new Producer RecordBuilder */ public static com.homeaway.digitalplatform.streamregistry.Producer.Builder newBuilder(com.homeaway.digitalplatform.streamregistry.Producer.Builder other) { return new com.homeaway.digitalplatform.streamregistry.Producer.Builder(other); }
/** * Creates a new Producer RecordBuilder. * @return A new Producer RecordBuilder */ public static com.homeaway.digitalplatform.streamregistry.Producer.Builder newBuilder() { return new com.homeaway.digitalplatform.streamregistry.Producer.Builder(); }
/** * Clears the value of the 'actor' field. * * Actor configuration for the producer * @return This builder. */ public com.homeaway.digitalplatform.streamregistry.Producer.Builder clearActor() { actor = null; actorBuilder = null; fieldSetFlags()[0] = false; return this; }
/** * Sets the Builder instance for the 'actor' field * * Actor configuration for the producer * @param value The builder instance that must be set. * @return This builder. */ public com.homeaway.digitalplatform.streamregistry.Producer.Builder setActorBuilder(com.homeaway.digitalplatform.streamregistry.Actor.Builder value) { clearActor(); actorBuilder = value; return this; }
/** * Creates a new Producer RecordBuilder by copying an existing Producer instance. * @param other The existing instance to copy. * @return A new Producer RecordBuilder */ public static com.homeaway.digitalplatform.streamregistry.Producer.Builder newBuilder(com.homeaway.digitalplatform.streamregistry.Producer other) { return new com.homeaway.digitalplatform.streamregistry.Producer.Builder(other); }
/** * Creates a Builder by copying an existing Producer instance * @param other The existing instance to copy. */ private Builder(com.homeaway.digitalplatform.streamregistry.Producer other) { super(SCHEMA$); if (isValidValue(fields()[0], other.actor)) { this.actor = data().deepCopy(fields()[0].schema(), other.actor); fieldSetFlags()[0] = true; } this.actorBuilder = null; }