package org.allmyinfo.operation.nodes.core;

import org.allmyinfo.nodes.database.NodesTransaction;
import org.allmyinfo.operation.PathElement;
import org.allmyinfo.operation.nodes.NodesExecutionContext;
import org.allmyinfo.operation.nodes.NodesOperation;
import org.eclipse.jdt.annotation.NonNull;

public final class GetContextTransaction extends NodesOperation {
	public static final @NonNull String OPERATION = "getTransaction";

	public GetContextTransaction() {
	}

	@Override
	public @NonNull Class<?> returns() {
		return NodesTransaction.class;
	}

	@Override
	public boolean canReturnNull() {
		return false;
	}

	@Override
	protected @NonNull Object execute(final @NonNull PathElement parentPathElement,
			final @NonNull NodesExecutionContext context) {
		return context.getTxn();
	}

	@Override
	public @NonNull String getName() {
		return OPERATION;
	}
}
