com.almworks.jira.structure.api.attribute.LoadedValue Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of structure-api Show documentation
Show all versions of structure-api Show documentation
Public API for the Structure Plugin for JIRA
package com.almworks.jira.structure.api.attribute;
import com.atlassian.annotations.PublicApi;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Represents a value loaded from the attribute system. Contains the {@link AttributeValue} and a boolean {@code outdated} flag.
*
* Note that the object is immutable with regards to the attribute value only. Outdated flag may change from {@code false} to {@code true}
* once during the lifespan of a loaded value.
*
* @param value type
*
* @see LoadedValues
* @see StructureAttributeService#getAttributeValues
*/
@PublicApi
public interface LoadedValue {
/**
* Returns the loaded attribute value.
*
* @return attribute value
*/
@NotNull
AttributeValue getValue();
/**
* Returns {@code true} if this value has been outdated. An outdated value will be recalculated next time it is requested.
*
* A value may be outdated right away, or it may become outdated later.
*
* @return true if the value is outdated
*/
boolean isOutdated();
/**
* Creates an instance of {@link LoadedValue} based on attribute value. This loaded value will never be outdated.
*
* @param attributeValue attribute value
* @param value type
* @return loaded value
*/
static LoadedValue of(@NotNull AttributeValue attributeValue) {
//noinspection ConstantConditions
if (attributeValue == null) {
throw new NullPointerException();
}
return new UpToDateLoadedValue<>(attributeValue);
}
/**
* Creates an instance of {@link LoadedValue} based on a value itself. This loaded value will never be outdated.
*
* @param value value
* @param value type
* @return loaded value
*/
static LoadedValue of(@Nullable T value) {
return new UpToDateLoadedValue<>(AttributeValue.ofNullable(value));
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy