Class DeviceAnnotationConfig

  • All Implemented Interfaces:
    CodecContext

    public class DeviceAnnotationConfig
    extends BaseConfig<DeviceId>
    Configuration to add extra annotations to a device via netcfg subsystem.
    • Constructor Detail

      • DeviceAnnotationConfig

        public DeviceAnnotationConfig()
        Create a detached DeviceAnnotationConfig.

        Note: created instance needs to be initialized by #init(..) before using.

      • DeviceAnnotationConfig

        public DeviceAnnotationConfig​(DeviceId deviceId)
        Create a detached DeviceAnnotationConfig for specified device.

        Note: created instance is not bound to NetworkConfigService, thus cannot use Config.apply(). Must be passed to the service using NetworkConfigService#applyConfig

        Parameters:
        deviceId - Device id
    • Method Detail

      • isValid

        public boolean isValid()
        Description copied from class: Config
        Indicates whether or not the backing JSON node contains valid data.

        Default implementation returns true. Subclasses are expected to override this with their own validation. Implementations are free to throw a RuntimeException if data is invalid.

        Overrides:
        isValid in class Config<DeviceId>
        Returns:
        true if the data is valid; false otherwise
      • annotations

        public Map<String,​String> annotations()
        Returns annotations to add to a Device.
        Returns:
        annotations as a map. null value represent key removal request
      • annotations

        public DeviceAnnotationConfig annotations​(Map<String,​String> replace)
        Sets annotations to add to a Device.
        Parameters:
        replace - annotations to be added by this configuration. null value represent key removal request
        Returns:
        self
      • annotation

        public DeviceAnnotationConfig annotation​(String key,
                                                 String value)
        Add configuration to set or remove annotation entry.
        Parameters:
        key - annotations key
        value - annotations value. specifying null removes the entry.
        Returns:
        self
      • annotation

        public DeviceAnnotationConfig annotation​(String key)
        Remove configuration about specified key.
        Parameters:
        key - annotations key
        Returns:
        self