Class GridMetadataAwareAdapter

    • Constructor Detail

      • GridMetadataAwareAdapter

        public GridMetadataAwareAdapter()
    • Method Detail

      • copyMeta

        public void copyMeta​(GridMetadataAwareAdapter from)
        Copies all metadata from another instance.
        Parameters:
        from - Metadata aware instance to copy metadata from.
      • copyMeta

        public void copyMeta​(Object[] data)
        Copies all metadata from given map.
        Parameters:
        data - Map to copy metadata from.
      • addMeta

        @Nullable
        public <V> V addMeta​(int key,
                             V val)
        Adds a new metadata.
        Type Parameters:
        V - Type of the value.
        Parameters:
        key - Metadata key.
        val - Metadata value.
        Returns:
        Metadata previously associated with given name, or null if there was none.
      • meta

        @Nullable
        public <V> V meta​(int key)
        Gets metadata by name.
        Type Parameters:
        V - Type of the value.
        Parameters:
        key - Metadata key.
        Returns:
        Metadata value or null.
      • removeMeta

        @Nullable
        public <V> V removeMeta​(int key)
        Removes metadata by key.
        Type Parameters:
        V - Type of the value.
        Parameters:
        key - Name of the metadata to remove.
        Returns:
        Value of removed metadata or null.
      • removeMeta

        public <V> boolean removeMeta​(int key,
                                      V val)
        Removes metadata only if its current value is equal to val passed in.
        Type Parameters:
        V - Value type.
        Parameters:
        key - Name of metadata attribute.
        val - Value to compare.
        Returns:
        True if value was removed, false otherwise.
      • allMeta

        public <V> Object[] allMeta()
        Gets all metadata in this entry.
        Type Parameters:
        V - Type of the value.
        Returns:
        All metadata in this entry.
      • removeAllMeta

        public void removeAllMeta()
        Removes all meta.
      • hasMeta

        public boolean hasMeta​(int key)
        Tests whether or not given metadata is set.
        Parameters:
        key - key of the metadata to test.
        Returns:
        Whether or not given metadata is set.
      • hasMeta

        public <V> boolean hasMeta​(int key,
                                   V val)
        Tests whether or not given metadata is set.
        Parameters:
        key - Key of the metadata to test.
        Returns:
        Whether or not given metadata is set.
      • putMetaIfAbsent

        @Nullable
        public <V> V putMetaIfAbsent​(int key,
                                     V val)
        Adds given metadata value only if it was absent.
        Type Parameters:
        V - Type of the value.
        Parameters:
        key - Metadata key.
        val - Value to add if it's not attached already.
        Returns:
        null if new value was put, or current value if put didn't happen.
      • addMetaIfAbsent

        public <V> V addMetaIfAbsent​(int key,
                                     V val)
        Adds given metadata value only if it was absent. This method always returns the latest value and never previous one.
        Type Parameters:
        V - Type of the value.
        Parameters:
        key - Metadata key.
        val - Value to add if it's not attached already.
        Returns:
        The value of the metadata after execution of this method.
      • addMetaIfAbsent

        @Nullable
        public <V> V addMetaIfAbsent​(int key,
                                     @NotNull
                                     @NotNull Callable<V> c)
        Adds given metadata value only if it was absent.
        Type Parameters:
        V - Type of the value.
        Parameters:
        key - Metadata key.
        c - Factory closure to produce value to add if it's not attached already. Not that unlike addMeta(int, Object) method the factory closure will not be called unless the value is required and therefore value will only be created when it is actually needed. If null and metadata value is missing - null will be returned from this method.
        Returns:
        The value of the metadata after execution of this method.
      • replaceMeta

        public <V> boolean replaceMeta​(int key,
                                       V curVal,
                                       V newVal)
        Replaces given metadata with new newVal value only if its current value is equal to curVal. Otherwise, it is no-op.
        Parameters:
        key - Key of the metadata.
        curVal - Current value to check.
        newVal - New value.
        Returns:
        true if replacement occurred, false otherwise.