ImmutableRegistration.Builder registrationBuilder = ImmutableRegistration.builder() .name(registerConfig.getString("name")) .address(registerConfig.getString("host"))
/** * Copy the current immutable object with elements that replace the content of {@link Registration#getChecks() checks}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final ImmutableRegistration withChecks(Registration.RegCheck... elements) { ImmutableList<Registration.RegCheck> newValue = ImmutableList.copyOf(elements); return new ImmutableRegistration( this.name, this.id, this.address, this.port, this.check, newValue, this.tags, this.meta, this.enableTagOverride); }
/** * This instance is equal to all instances of {@code ImmutableRegistration} that have equal attribute values. * @return {@code true} if {@code this} is equal to {@code another} instance */ @Override public boolean equals(@Nullable Object another) { if (this == another) return true; return another instanceof ImmutableRegistration && equalTo((ImmutableRegistration) another); }
/** * Copy the current immutable object with elements that replace the content of {@link Registration#getTags() tags}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final ImmutableRegistration withTags(String... elements) { ImmutableList<String> newValue = ImmutableList.copyOf(elements); return new ImmutableRegistration( this.name, this.id, this.address, this.port, this.check, this.checks, newValue, this.meta, this.enableTagOverride); }
/** * Creates an immutable copy of a {@link Registration} value. * Uses accessors to get values to initialize the new immutable instance. * If an instance is already immutable, it is returned as is. * @param instance The instance to copy * @return A copied immutable Registration instance */ public static ImmutableRegistration copyOf(Registration instance) { if (instance instanceof ImmutableRegistration) { return (ImmutableRegistration) instance; } return ImmutableRegistration.builder() .from(instance) .build(); }
/** * Copy the current immutable object with elements that replace the content of {@link Registration#getTags() tags}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of tags elements to set * @return A modified copy of {@code this} object */ public final ImmutableRegistration withTags(Iterable<String> elements) { if (this.tags == elements) return this; ImmutableList<String> newValue = ImmutableList.copyOf(elements); return new ImmutableRegistration( this.name, this.id, this.address, this.port, this.check, this.checks, newValue, this.meta, this.enableTagOverride); }
ImmutableRegistration.Builder registrationBuilder = ImmutableRegistration.builder() .name(registerConfig.getString("name")) .address(registerConfig.getString("host"))
/** * Copy the current immutable object with elements that replace the content of {@link Registration#getChecks() checks}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of checks elements to set * @return A modified copy of {@code this} object */ public final ImmutableRegistration withChecks(Iterable<? extends Registration.RegCheck> elements) { if (this.checks == elements) return this; ImmutableList<Registration.RegCheck> newValue = ImmutableList.copyOf(elements); return new ImmutableRegistration( this.name, this.id, this.address, this.port, this.check, newValue, this.tags, this.meta, this.enableTagOverride); }
public void register(String name, int port) { log.info("Will register " + name + " with port " + port); AgentClient agentClient = client.agentClient(); Registration service = ImmutableRegistration.builder().id(name).name(name).port(port) .check(Registration.RegCheck.http("http://localhost:" + port + Constants.HEALTH_CONTEXT, 60, 5)).build(); agentClient.register(service); }
/** * Copy the current immutable object by replacing the {@link Registration#getMeta() meta} map with the specified map. * Nulls are not permitted as keys or values. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param entries The entries to be added to the meta map * @return A modified copy of {@code this} object */ public final ImmutableRegistration withMeta(Map<String, ? extends String> entries) { if (this.meta == entries) return this; ImmutableMap<String, String> value = ImmutableMap.copyOf(entries); return new ImmutableRegistration( this.name, this.id, this.address, this.port, this.check, this.checks, this.tags, value, this.enableTagOverride); }
ImmutableRegistration.Builder builder = ImmutableRegistration.builder() .name(this.consulServiceName) .id(myServiceId)
/** * Copy the current immutable object by setting a <i>present</i> value for the optional {@link Registration#getEnableTagOverride() enableTagOverride} attribute. * @param value The value for enableTagOverride * @return A modified copy of {@code this} object */ public final ImmutableRegistration withEnableTagOverride(boolean value) { @Nullable Boolean newValue = value; if (Objects.equals(this.enableTagOverride, newValue)) return this; return new ImmutableRegistration( this.name, this.id, this.address, this.port, this.check, this.checks, this.tags, this.meta, newValue); }
ImmutableRegistration.Builder builder = ImmutableRegistration.builder() .name(this.consulServiceName) .id(myServiceId)
/** * Copy the current immutable object by setting a <i>present</i> value for the optional {@link Registration#getCheck() check} attribute. * @param value The value for check * @return A modified copy of {@code this} object */ public final ImmutableRegistration withCheck(Registration.RegCheck value) { @Nullable Registration.RegCheck newValue = Preconditions.checkNotNull(value, "check"); if (this.check == newValue) return this; return new ImmutableRegistration( this.name, this.id, this.address, this.port, newValue, this.checks, this.tags, this.meta, this.enableTagOverride); }
Registration registration = ImmutableRegistration.builder() .address(computeServiceHost(definition)) .port(definition.getPort())
/** * Copy the current immutable object by setting a value for the {@link Registration#getName() name} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for name * @return A modified copy of the {@code this} object */ public final ImmutableRegistration withName(String value) { if (this.name.equals(value)) return this; return new ImmutableRegistration( Preconditions.checkNotNull(value, "name"), this.id, this.address, this.port, this.check, this.checks, this.tags, this.meta, this.enableTagOverride); }
/** * Registers the client as a service with Consul with an existing {@link com.orbitz.consul.model.agent.Registration.RegCheck} * * @param port The public facing port of the service to register with Consul. * @param check The health check to run periodically. Can be null. * @param name Service name to register. * @param id Service id to register. * @param tags Tags to register with. * @param meta Meta to register with. */ public void register(int port, Registration.RegCheck check, String name, String id, List<String> tags, Map<String, String> meta) { Registration registration = ImmutableRegistration .builder() .port(port) .check(Optional.ofNullable(check)) .name(name) .id(id) .tags(tags) .meta(meta) .build(); register(registration); }
/** * Copy the current immutable object by setting a value for the {@link Registration#getId() id} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for id * @return A modified copy of the {@code this} object */ public final ImmutableRegistration withId(String value) { if (this.id.equals(value)) return this; return new ImmutableRegistration( this.name, Preconditions.checkNotNull(value, "id"), this.address, this.port, this.check, this.checks, this.tags, this.meta, this.enableTagOverride); }
ImmutableRegistration.builder().port(servicePort.get()).check(check).id(serviceId);
/** * Copy the current immutable object by setting a <i>present</i> value for the optional {@link Registration#getPort() port} attribute. * @param value The value for port * @return A modified copy of {@code this} object */ public final ImmutableRegistration withPort(int value) { @Nullable Integer newValue = value; if (Objects.equals(this.port, newValue)) return this; return new ImmutableRegistration( this.name, this.id, this.address, newValue, this.check, this.checks, this.tags, this.meta, this.enableTagOverride); }