package jetbrains.mps.ide.findusages.model.holders;

/*Generated by MPS */

import jetbrains.mps.annotations.GeneratedClass;
import org.jetbrains.annotations.NotNull;
import org.jdom.Element;
import jetbrains.mps.project.Project;
import jetbrains.mps.ide.findusages.CantLoadSomethingException;
import jetbrains.mps.ide.findusages.CantSaveSomethingException;

/**
 * IHolder generic enough to hold any object. It's up to IFinder implementation to deal with actual value.
 * @author Artem Tikhomirov
 */
@GeneratedClass(node = "r:6d26b589-14c5-496e-9d2b-5c71b3a15e5d(jetbrains.mps.ide.findusages.model.holders)/8568892084424440209", model = "r:6d26b589-14c5-496e-9d2b-5c71b3a15e5d(jetbrains.mps.ide.findusages.model.holders)")
public class GenericHolder<T> implements IHolder<T> {
  private final T myValue;
  private final String myCaption;
  public GenericHolder(@NotNull T value) {
    this(value, value.toString());
  }
  public GenericHolder(@NotNull T value, @NotNull String caption) {
    myValue = value;
    myCaption = caption;
  }
  @Override
  public T getObject() {
    return myValue;
  }
  @NotNull
  @Override
  public String getCaption() {
    return myCaption;
  }
  @Override
  public void read(Element element, Project project) throws CantLoadSomethingException {
    throw new CantLoadSomethingException("No idea how an object might be serialized");
  }
  @Override
  public void write(Element element, Project project) throws CantSaveSomethingException {
    throw new CantSaveSomethingException("No idea how an object might be serialized");
  }
}
