Class LazyField<T>

  • Type Parameters:
    T - field type
    All Implemented Interfaces:
    java.io.Serializable, Field<T>

    public final class LazyField<T>
    extends AbstractField<T>
    Lazy implementation of a Field.
    See Also:
    Serialized Form
    • Constructor Detail

      • LazyField

        public LazyField​(@Nonnull
                         Field<?> origin,
                         @Nonnull
                         java.util.function.Function<DeviceUID,​T> mapper)
        Parameters:
        origin - the field on which this lazy field is mapping
        mapper - the mapping function
    • Method Detail

      • iterable

        public java.lang.Iterable<? extends java.util.Map.Entry<DeviceUID,​T>> iterable()
        Returns:
        An iterator over the set of neighbor/value pairs
      • keys

        public java.lang.Iterable<DeviceUID> keys()
        Returns:
        An Iterable for the field keys
      • keyStream

        public java.util.stream.Stream<DeviceUID> keyStream()
        Returns:
        A Stream for the field keys
      • valueStream

        public java.util.stream.Stream<T> valueStream()
        Returns:
        A Stream over the set of values
      • values

        public java.lang.Iterable<T> values()
        Returns:
        An Iterable set of values
      • stream

        public java.util.stream.Stream<? extends java.util.Map.Entry<DeviceUID,​T>> stream()
        Returns:
        A Stream over the set of neighbor/value pairs
      • getIfPresent

        public java.util.Optional<T> getIfPresent​(@Nonnull
                                                  DeviceUID id)
        Parameters:
        id - the DeviceUID
        Returns:
        the associated value wrapped in an Optional, or an Optional.empty() if the device is not aligned.
      • getLocalDevice

        public DeviceUID getLocalDevice()
        Returns:
        the local Device
      • containsKey

        public boolean containsKey​(DeviceUID id)
        Description copied from interface: Field
        Verifies if some device has an entry in this field. Note to interface implementors: the default version of this method is not optimized for performance and should be overridden.
        Parameters:
        id - a device UID
        Returns:
        true if there is an entry in this field for the device
      • size

        public int size()
        Description copied from interface: Field
        The number of neighbors in this field. Hence, a field that only contains the local value has size 0. Note to Field implementors: the default implementation is inefficient and should be overridden.
        Returns:
        Number of neighbors with values in the field