State state = null; State[] allStates = state.values();
/** * Construct a new immutable {@code EventResponse} instance. * @param events The value for the {@code events} attribute * @param index The value for the {@code index} attribute * @return An immutable EventResponse instance */ public static ImmutableEventResponse of(List<Event> events, BigInteger index) { return of((Iterable<? extends Event>) events, index); }
/** * Construct a new immutable {@code EventResponse} instance. * @param events The value for the {@code events} attribute * @param index The value for the {@code index} attribute * @return An immutable EventResponse instance */ public static ImmutableEventResponse of(Iterable<? extends Event> events, BigInteger index) { return new ImmutableEventResponse(events, index); }
@Override public void onComplete(ConsulResponse<List<Value>> consulResponse) { callback.onComplete( new ConsulResponse<>(getSingleValue(consulResponse.getResponse()), consulResponse.getLastContact(), consulResponse.isKnownLeader(), consulResponse.getIndex())); }
@Override public void onComplete(ConsulResponse<List<Event>> response) { callback.onComplete(ImmutableEventResponse.of(response.getResponse(), response.getIndex())); }
@Override public void onComplete(ConsulResponse<T> consulResponse) { if (isRunAllowed()) { onResponse(consulResponse.getResponse()); setIndex(consulResponse.getIndex()); watch(); } }
@Override public Collection<ServiceHealth> discover(final Consul consul) { return consul.healthClient().getHealthyServiceInstances(service).getResponse(); } }
/** * Fill a builder with attribute values from the provided {@code EventResponse} instance. * Regular attribute values will be replaced with those from the given instance. * Absent optional values will not replace present values. * Collection elements and entries will be added, not replaced. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Builder from(EventResponse instance) { Preconditions.checkNotNull(instance, "instance"); addAllEvents(instance.getEvents()); index(instance.getIndex()); return this; }
/** * @param json A JSON-bindable data structure * @return An immutable value type * @deprecated Do not use this method directly, it exists only for the <em>Jackson</em>-binding infrastructure */ @Deprecated @JsonCreator static ImmutableEventResponse fromJson(Json json) { ImmutableEventResponse.Builder builder = ImmutableEventResponse.builder(); if (json.events != null) { builder.addAllEvents(json.events); } if (json.index != null) { builder.index(json.index); } return builder.build(); }
/** * Creates an immutable copy of a {@link EventResponse} 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 EventResponse instance */ public static ImmutableEventResponse copyOf(EventResponse instance) { if (instance instanceof ImmutableEventResponse) { return (ImmutableEventResponse) instance; } return ImmutableEventResponse.builder() .from(instance) .build(); }
/** * Builds a new {@link ImmutableEventResponse ImmutableEventResponse}. * @return An immutable instance of EventResponse * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableEventResponse build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ImmutableEventResponse(null, eventsBuilder.build(), index); }
/** * Creates a builder for {@link ImmutableEventResponse ImmutableEventResponse}. * @return A new ImmutableEventResponse builder */ public static ImmutableEventResponse.Builder builder() { return new ImmutableEventResponse.Builder(); }
/** * This instance is equal to all instances of {@code ImmutableEventResponse} 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 ImmutableEventResponse && equalTo((ImmutableEventResponse) another); }
/** * Sets or replaces all elements for {@link EventResponse#getEvents() events} list. * @param elements An iterable of events elements * @return {@code this} builder for use in a chained invocation */ public final Builder events(Iterable<? extends Event> elements) { eventsBuilder = ImmutableList.builder(); return addAllEvents(elements); }
protected <T> void processConsulResponse(Message message, ConsulResponse<T> response) throws Exception { message.setHeader(ConsulConstants.CONSUL_INDEX, response.getIndex()); message.setHeader(ConsulConstants.CONSUL_LAST_CONTACT, response.getLastContact()); message.setHeader(ConsulConstants.CONSUL_KNOWN_LEADER, response.isKnownLeader()); setBodyAndResult(message, response.getResponse()); }
/** * Lists events for the Consul agent. * * GET /v1/event/list?name={name} * * @param name Event name to filter. * @param queryOptions The query options to use. * @return A {@link com.orbitz.consul.model.ConsulResponse} object containing * a list of {@link com.orbitz.consul.model.event.Event} objects. */ public EventResponse listEvents(String name, QueryOptions queryOptions) { Map<String, String> query = StringUtils.isNotEmpty(name) ? ImmutableMap.of("name", name) : Collections.emptyMap(); ConsulResponse<List<Event>> response = http.extractConsulResponse(api.listEvents(query)); return ImmutableEventResponse.of(response.getResponse(), response.getIndex()); }
/** * Copy the current immutable object by setting a value for the {@link EventResponse#getIndex() index} attribute. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for index * @return A modified copy of the {@code this} object */ public final ImmutableEventResponse withIndex(BigInteger value) { if (this.index == value) return this; return new ImmutableEventResponse(this, this.events, Preconditions.checkNotNull(value, "index")); }
/** * Copy the current immutable object with elements that replace the content of {@link EventResponse#getEvents() events}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final ImmutableEventResponse withEvents(Event... elements) { ImmutableList<Event> newValue = ImmutableList.copyOf(elements); return new ImmutableEventResponse(this, newValue, this.index); }
/** * Copy the current immutable object with elements that replace the content of {@link EventResponse#getEvents() events}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of events elements to set * @return A modified copy of {@code this} object */ public final ImmutableEventResponse withEvents(Iterable<? extends Event> elements) { if (this.events == elements) return this; ImmutableList<Event> newValue = ImmutableList.copyOf(elements); return new ImmutableEventResponse(this, newValue, this.index); }