private Optional<com.homeaway.streamplatform.streamregistry.model.Consumer> createConsumer(AvroStream avroStream, String consumerName, String region) { log.info("==>>> getting into creating consumer. Initial Stream: {}", avroStream.toString()); if (!regionDao.getSupportedRegions(avroStream.getTags().getHint()).contains(region)) throw new UnknownRegionException(region); List<com.homeaway.digitalplatform.streamregistry.Consumer> listConsumers = avroStream.getConsumers(); if (listConsumers == null) { listConsumers = new ArrayList<>(); } com.homeaway.digitalplatform.streamregistry.Consumer consumer = com.homeaway.digitalplatform.streamregistry.Consumer .newBuilder() .setActor(Actor.newBuilder() .setName(consumerName) .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, consumer.getActor(), OPERATION.CREATE.name(), TOPIC_POST_FIXES, hint, ACTOR_TYPE, avroStream.getTopicConfig()); consumer = Consumer.newBuilder() .setActor(actor) .build(); listConsumers.add(consumer); avroStream.setConsumers(listConsumers); updateAvroStream(avroStream); return Optional.of(AvroToJsonDTO.getJsonConsumer(consumer)); }
/** * Creates a Builder by copying an existing Builder. * @param other The existing Builder to copy. */ private Builder(com.homeaway.digitalplatform.streamregistry.Consumer.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 Consumer build() { try { Consumer record = new Consumer(); 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 consumer * @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; }
/** * Clears the value of the 'actor' field. * * Actor configuration for the consumer * @return This builder. */ public com.homeaway.digitalplatform.streamregistry.Consumer.Builder clearActor() { actor = null; actorBuilder = null; fieldSetFlags()[0] = false; return this; }
/** * Sets the Builder instance for the 'actor' field * * Actor configuration for the consumer * @param value The builder instance that must be set. * @return This builder. */ public com.homeaway.digitalplatform.streamregistry.Consumer.Builder setActorBuilder(com.homeaway.digitalplatform.streamregistry.Actor.Builder value) { clearActor(); actorBuilder = value; return this; }
/** * Creates a Builder by copying an existing Consumer instance * @param other The existing instance to copy. */ private Builder(com.homeaway.digitalplatform.streamregistry.Consumer other) { super(SCHEMA$); if (isValidValue(fields()[0], other.actor)) { this.actor = data().deepCopy(fields()[0].schema(), other.actor); fieldSetFlags()[0] = true; } this.actorBuilder = null; }
/** * Creates a new Consumer RecordBuilder by copying an existing Builder. * @param other The existing builder to copy. * @return A new Consumer RecordBuilder */ public static com.homeaway.digitalplatform.streamregistry.Consumer.Builder newBuilder(com.homeaway.digitalplatform.streamregistry.Consumer.Builder other) { return new com.homeaway.digitalplatform.streamregistry.Consumer.Builder(other); }
/** * Creates a new Consumer RecordBuilder. * @return A new Consumer RecordBuilder */ public static com.homeaway.digitalplatform.streamregistry.Consumer.Builder newBuilder() { return new com.homeaway.digitalplatform.streamregistry.Consumer.Builder(); }
/** * Checks whether the 'actor' field has been set. * * Actor configuration for the consumer * @return True if the 'actor' field has been set, false otherwise. */ public boolean hasActor() { return fieldSetFlags()[0]; }
/** * Sets the value of the 'actor' field. * * Actor configuration for the consumer * @param value The value of 'actor'. * @return This builder. */ public com.homeaway.digitalplatform.streamregistry.Consumer.Builder setActor(com.homeaway.digitalplatform.streamregistry.Actor value) { validate(fields()[0], value); this.actorBuilder = null; this.actor = value; fieldSetFlags()[0] = true; return this; }
/** * Creates a new Consumer RecordBuilder by copying an existing Consumer instance. * @param other The existing instance to copy. * @return A new Consumer RecordBuilder */ public static com.homeaway.digitalplatform.streamregistry.Consumer.Builder newBuilder(com.homeaway.digitalplatform.streamregistry.Consumer other) { return new com.homeaway.digitalplatform.streamregistry.Consumer.Builder(other); }