Interface HasMetadata

    • Method Detail

      • getKind

        static String getKind​(Class<?> clazz)
        Retrieves the kind associated with the specified HasMetadata implementation. If the implementation is annotated with Kind, the annotation value will be used, otherwise the value will be derived from the class name.
        Parameters:
        clazz - the HasMetadata implementation whose Kind we want to retrieve
        Returns:
        the kind associated with the specified HasMetadata
      • getApiVersion

        static String getApiVersion​(Class<?> clazz)
        Computes the apiVersion associated with this HasMetadata implementation. The value is derived from the Group and Version annotations.
        Parameters:
        clazz - the HasMetadata whose apiVersion we want to compute
        Returns:
        the computed apiVersion or null if neither Group or Version annotations are present
        Throws:
        IllegalArgumentException - if only one of Group or Version is provided
      • getGroup

        static String getGroup​(Class<?> clazz)
        Retrieves the group associated with the specified HasMetadata as defined by the Group annotation.
        Parameters:
        clazz - the HasMetadata whose group we want to retrieve
        Returns:
        the associated group or null if the HasMetadata is not annotated with Group
      • getVersion

        static String getVersion​(Class<?> clazz)
        Retrieves the version associated with the specified HasMetadata as defined by the Version annotation.
        Parameters:
        clazz - the HasMetadata whose version we want to retrieve
        Returns:
        the associated version or null if the HasMetadata is not annotated with Version
      • getPlural

        static String getPlural​(Class<?> clazz)
        Retrieves the plural form associated with the specified class if annotated with Plural or computes a default value using the value returned by getSingular(Class) as input to Pluralize.toPlural(String).
        Parameters:
        clazz - the CustomResource whose plural form we want to retrieve
        Returns:
        the plural form defined by the Plural annotation or a computed default value
      • getSingular

        static String getSingular​(Class<?> clazz)
        Retrieves the singular form associated with the specified class as defined by the Singular annotation or computes a default value (lower-cased version of the value returned by getKind(Class)) if the annotation is not present.
        Parameters:
        clazz - the class whose singular form we want to retrieve
        Returns:
        the singular form defined by the Singular annotation or a computed default value
      • getFullResourceName

        static String getFullResourceName​(Class<?> clazz)
      • getFullResourceName

        static String getFullResourceName​(String plural,
                                          String group)
      • validateFinalizer

        static boolean validateFinalizer​(String finalizer)
        Determines whether the specified finalizer is valid according to the finalizer specification.
        Parameters:
        finalizer - the identifier of the finalizer which validity we want to check
        Returns:
        true if the identifier is valid, false otherwise
      • setMetadata

        void setMetadata​(ObjectMeta metadata)
      • getKind

        default String getKind()
      • getApiVersion

        default String getApiVersion()
      • setApiVersion

        void setApiVersion​(String version)
      • getPlural

        default String getPlural()
      • getSingular

        default String getSingular()
      • getFullResourceName

        default String getFullResourceName()
      • isMarkedForDeletion

        default boolean isMarkedForDeletion()
        Determines whether this HasMetadata is marked for deletion or not.
        Returns:
        true if the cluster marked this HasMetadata for deletion, false otherwise
      • hasFinalizer

        default boolean hasFinalizer​(String finalizer)
        Determines whether this HasMetadata holds the specified finalizer.
        Parameters:
        finalizer - the identifier of the finalizer we want to check
        Returns:
        true if this HasMetadata holds the specified finalizer, false otherwise
      • getFinalizers

        default List<String> getFinalizers()
      • addFinalizer

        default boolean addFinalizer​(String finalizer)
        Adds the specified finalizer to this HasMetadata if it's valid. See isFinalizerValid(String).
        Parameters:
        finalizer - the identifier of the finalizer to add to this HasMetadata in <domain name>/<finalizer name> format.
        Returns:
        true if the finalizer was successfully added, false otherwise (in particular, if the object is marked for deletion)
        Throws:
        IllegalArgumentException - if the specified finalizer identifier is null or is invalid
      • isFinalizerValid

        default boolean isFinalizerValid​(String finalizer)
        Parameters:
        finalizer - the identifier of the finalizer which validity we want to check
        Returns:
        true if the identifier is valid, false otherwise
        See Also:
        validateFinalizer(String)
      • removeFinalizer

        default boolean removeFinalizer​(String finalizer)
        Removes the specified finalizer if it's held by this HasMetadata.
        Parameters:
        finalizer - the identifier of the finalizer we want to remove
        Returns:
        true if the finalizer was successfully removed, false otherwise
      • hasOwnerReferenceFor

        default boolean hasOwnerReferenceFor​(HasMetadata owner)
        Checks whether the provided HasMetadata is defined as an owner for this HasMetadata.
        Parameters:
        owner - the HasMetadata to check for potential ownership
        Returns:
        true if the provided HasMetadata is an owner of this instance
      • hasOwnerReferenceFor

        default boolean hasOwnerReferenceFor​(String ownerUid)
        Checks whether the provided UID identifies an owner for this HasMetadata.
        Parameters:
        ownerUid - the UID of a HasMetadata to check for potential ownership
        Returns:
        true if the provided HasMetadata is an owner of this instance
      • getOwnerReferenceFor

        default Optional<OwnerReference> getOwnerReferenceFor​(String ownerUid)
        Retrieves the OwnerReference associated with the owner identified by the specified UID if it's part of thisHasMetadata's owners.
        Parameters:
        ownerUid - the UID of the potential owner of which we want to retrieve the associated OwnerReference
        Returns:
        an Optional containing the OwnerReference associated with the owner identified by the specified UID if it exists or Optional.empty() otherwise.
      • removeOwnerReference

        default void removeOwnerReference​(String ownerUid)
        Removes the OwnerReference identified by the specified UID if it's part of this HasMetadata's owner references
        Parameters:
        ownerUid - the UID of the OwnerReference to remove
      • removeOwnerReference

        default void removeOwnerReference​(HasMetadata owner)
        Removes the OwnerReference associated with the specified owner if it's part of this HasMetadata's owner references
        Parameters:
        owner - the owner whose reference we want to remove
      • initNameAndNamespaceFrom

        default void initNameAndNamespaceFrom​(HasMetadata original)
        Initializes this ObjectMeta field with name and namespace (if this instance represents a namespaced resource) provided by the specified HasMetadata instance. This is a convenience method to avoid boilerplate, notably when using Server-Side Apply, when creating a new instance with only some fields of the original one. Calls setMetadata(ObjectMeta) when done, if you want to further configure this instance's metadata, please use initMetadataBuilderNameAndNamespaceFrom(HasMetadata) instead, which doesn't sets the metadata, leaving it up to the user once configuration is finished.
        Parameters:
        original - a HasMetadata instance from which to retrieve the name and namespace
      • initMetadataBuilderNameAndNamespaceFrom

        static ObjectMetaBuilder initMetadataBuilderNameAndNamespaceFrom​(HasMetadata original)
        Creates and initializes a new ObjectMetaBuilder with name and namespace (if the provided instance to initialize from represents a namespaced resource) provided by the specified HasMetadata instance. This is a convenience method to avoid boilerplate, notably when using Server-Side Apply, when creating a new instance with only some fields of the original one. This method assumes that further configuration will occur on the newly created ObjectMetaBuilder.
        Parameters:
        original - an HasMetadata instance from which to retrieve the name and namespace
        Returns:
        a new ObjectMetaBuilder instance initialized with the name and namespace (if needed) of the specified HasMetadata