
com.almworks.jira.structure.api2g.row.SimpleRow 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.api2g.row;
import com.almworks.jira.structure.api2g.item.ItemIdentity;
import com.almworks.jira.structure.api2g.item.ItemResolver;
import com.atlassian.annotations.Internal;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@Internal
public final class SimpleRow implements StructureRow {
private final long myRowId;
private final ItemIdentity myItemId;
private final long mySemantics;
private final ItemResolver myResolver;
private volatile boolean myItemLoaded;
private Object myItem;
public SimpleRow(long rowId, ItemIdentity itemId, long semantics, ItemResolver resolver) {
myRowId = rowId;
myItemId = itemId;
mySemantics = semantics;
myResolver = resolver;
}
@Override
public long getRowId() {
return myRowId;
}
@Nullable
@Override
public I getItem(@NotNull Class itemClass) {
if (!myItemLoaded) {
synchronized (this) {
if (!myItemLoaded) {
try {
myItem = myResolver.resolveItem(getItemId(), Object.class);
} finally {
myItemLoaded = true;
}
}
}
}
return itemClass.isInstance(myItem) ? itemClass.cast(myItem) : null;
}
@NotNull
@Override
public ItemIdentity getItemId() {
return myItemId;
}
@Override
public long getSemantics() {
return mySemantics;
}
@Override
public String toString() {
return "SimpleRow[" + myRowId + ":" + myItemId + ":" + mySemantics + "]";
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy