Class ImmutableNode
java.lang.Object
org.kiwiproject.consul.model.health.Node
org.kiwiproject.consul.model.health.ImmutableNode
Immutable implementation of
Node.
Use the builder to create immutable instances:
ImmutableNode.builder().
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic ImmutableNode.Builderbuilder()Creates a builder forImmutableNode.static ImmutableNodeCreates an immutable copy of aNodevalue.booleanThis instance is equal to all instances ofImmutableNodethat have equal attribute values.getNode()inthashCode()Computes a hash code from attributes:node,address,datacenter,taggedAddresses,nodeMeta.toString()Prints the immutable valueNodewith attribute values.final ImmutableNodewithAddress(String value) Copy the current immutable object by setting a value for theaddressattribute.final ImmutableNodewithDatacenter(String value) Copy the current immutable object by setting a present value for the optionaldatacenterattribute.final ImmutableNodewithDatacenter(Optional<String> optional) Copy the current immutable object by setting an optional value for thedatacenterattribute.final ImmutableNodeCopy the current immutable object by setting a value for thenodeattribute.final ImmutableNodewithNodeMeta(Map<String, String> value) Copy the current immutable object by setting a present value for the optionalnodeMetaattribute.final ImmutableNodewithNodeMeta(Optional<? extends Map<String, String>> optional) Copy the current immutable object by setting an optional value for thenodeMetaattribute.final ImmutableNodewithTaggedAddresses(Optional<? extends TaggedAddresses> optional) Copy the current immutable object by setting an optional value for thetaggedAddressesattribute.final ImmutableNodeCopy the current immutable object by setting a present value for the optionaltaggedAddressesattribute.
-
Method Details
-
getNode
-
getAddress
- Specified by:
getAddressin classNode- Returns:
- The value of the
addressattribute
-
getDatacenter
- Specified by:
getDatacenterin classNode- Returns:
- The value of the
datacenterattribute
-
getTaggedAddresses
- Specified by:
getTaggedAddressesin classNode- Returns:
- The value of the
taggedAddressesattribute
-
getNodeMeta
- Specified by:
getNodeMetain classNode- Returns:
- The value of the
nodeMetaattribute
-
withNode
Copy the current immutable object by setting a value for thenodeattribute. An equals check used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for node- Returns:
- A modified copy of the
thisobject
-
withAddress
Copy the current immutable object by setting a value for theaddressattribute. An equals check used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for address- Returns:
- A modified copy of the
thisobject
-
withDatacenter
Copy the current immutable object by setting a present value for the optionaldatacenterattribute.- Parameters:
value- The value for datacenter- Returns:
- A modified copy of
thisobject
-
withDatacenter
Copy the current immutable object by setting an optional value for thedatacenterattribute. An equality check is used on inner nullable value to prevent copying of the same value by returningthis.- Parameters:
optional- A value for datacenter- Returns:
- A modified copy of
thisobject
-
withTaggedAddresses
Copy the current immutable object by setting a present value for the optionaltaggedAddressesattribute.- Parameters:
value- The value for taggedAddresses- Returns:
- A modified copy of
thisobject
-
withTaggedAddresses
Copy the current immutable object by setting an optional value for thetaggedAddressesattribute. A shallow reference equality check is used on unboxed optional value to prevent copying of the same value by returningthis.- Parameters:
optional- A value for taggedAddresses- Returns:
- A modified copy of
thisobject
-
withNodeMeta
Copy the current immutable object by setting a present value for the optionalnodeMetaattribute.- Parameters:
value- The value for nodeMeta- Returns:
- A modified copy of
thisobject
-
withNodeMeta
Copy the current immutable object by setting an optional value for thenodeMetaattribute. A shallow reference equality check is used on unboxed optional value to prevent copying of the same value by returningthis.- Parameters:
optional- A value for nodeMeta- Returns:
- A modified copy of
thisobject
-
equals
This instance is equal to all instances ofImmutableNodethat have equal attribute values. -
hashCode
public int hashCode()Computes a hash code from attributes:node,address,datacenter,taggedAddresses,nodeMeta. -
toString
Prints the immutable valueNodewith attribute values. -
copyOf
Creates an immutable copy of aNodevalue. Uses accessors to get values to initialize the new immutable instance. If an instance is already immutable, it is returned as is.- Parameters:
instance- The instance to copy- Returns:
- A copied immutable Node instance
-
builder
Creates a builder forImmutableNode.ImmutableNode.builder() .node(String) // requirednode.address(String) // requiredaddress.datacenter(String) // optionaldatacenter.taggedAddresses(org.kiwiproject.consul.model.catalog.TaggedAddresses) // optionaltaggedAddresses.nodeMeta(Map<String, String>) // optionalnodeMeta.build();- Returns:
- A new ImmutableNode builder
-