/** * Sets or replaces all elements for {@link SessionInfo#getChecks() checks} list. * @param elements An iterable of checks elements * @return {@code this} builder for use in a chained invocation */ public final Builder checks(Iterable<String> elements) { checksBuilder = ImmutableList.builder(); return addAllChecks(elements); }
/** * Builds a new {@link ImmutableSessionInfo ImmutableSessionInfo}. * @return An immutable instance of SessionInfo * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableSessionInfo build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ImmutableSessionInfo(createIndex, lockDelay, name, node, checksBuilder.build(), behavior, ttl, id); }
ImmutableSessionInfo.Builder builder = ImmutableSessionInfo.builder(); if (json.createIndex != null) { builder.createIndex(json.createIndex); builder.lockDelay(json.lockDelay); builder.name(json.name); builder.node(json.node); builder.addAllChecks(json.checks); builder.behavior(json.behavior); builder.ttl(json.ttl); builder.id(json.id); return builder.build();
/** * Fill a builder with attribute values from the provided {@code SessionInfo} 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(SessionInfo instance) { Preconditions.checkNotNull(instance, "instance"); createIndex(instance.getCreateIndex()); lockDelay(instance.getLockDelay()); Optional<String> nameOptional = instance.getName(); if (nameOptional.isPresent()) { name(nameOptional); } node(instance.getNode()); addAllChecks(instance.getChecks()); behavior(instance.getBehavior()); Optional<String> ttlOptional = instance.getTtl(); if (ttlOptional.isPresent()) { ttl(ttlOptional); } id(instance.getId()); return this; }
/** * Creates an immutable copy of a {@link SessionInfo} 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 SessionInfo instance */ public static ImmutableSessionInfo copyOf(SessionInfo instance) { if (instance instanceof ImmutableSessionInfo) { return (ImmutableSessionInfo) instance; } return ImmutableSessionInfo.builder() .from(instance) .build(); }
/** * Creates a builder for {@link ImmutableSessionInfo ImmutableSessionInfo}. * @return A new ImmutableSessionInfo builder */ public static ImmutableSessionInfo.Builder builder() { return new ImmutableSessionInfo.Builder(); }