package jetbrains.mps.debugger.java.runtime.state.values;

/*Generated by MPS */

import jetbrains.mps.annotations.GeneratedClass;
import jetbrains.mps.debugger.java.api.state.proxy.JavaValue;
import jetbrains.mps.debug.api.programState.IValue;
import com.sun.jdi.Field;
import com.sun.jdi.ThreadReference;
import javax.swing.Icon;
import jetbrains.mps.debugger.java.runtime.ui.Icons;
import java.util.List;
import jetbrains.mps.debug.api.programState.IWatchable;
import java.util.ArrayList;
import jetbrains.mps.debugger.java.runtime.state.watchables.JavaWatchpointValueWatchable;

@GeneratedClass(node = "r:6dff38c0-3c4e-455b-9e65-d46014c8a7f5(jetbrains.mps.debugger.java.runtime.state.values)/3187167456722650426", model = "r:6dff38c0-3c4e-455b-9e65-d46014c8a7f5(jetbrains.mps.debugger.java.runtime.state.values)")
public class FieldWatchpointValue extends JavaValue implements IValue {
  private final Field myField;
  private final JavaValue myCurrentValue;
  private final JavaValue myNewValue;
  private final boolean myAccess;
  public FieldWatchpointValue(Field field, boolean access, JavaValue currentValue, JavaValue newValue, ThreadReference threadReference) {
    super(currentValue.getValue(), threadReference);
    myField = field;
    myCurrentValue = currentValue;
    myNewValue = newValue;
    myAccess = access;
  }
  @Override
  public String getValuePresentation() {
    return myField.name();
  }
  @Override
  public Icon getPresentationIcon() {
    return Icons.FIELD_BREAKPOINT;
  }
  @Override
  public boolean isStructure() {
    return true;
  }
  @Override
  public List<IWatchable> calculateSubvalues() {
    List<IWatchable> result = new ArrayList<IWatchable>();
    result.add(new JavaWatchpointValueWatchable(myCurrentValue, true, myThreadReference));
    if (!(myAccess)) {
      result.add(new JavaWatchpointValueWatchable(myNewValue, false, myThreadReference));
    }
    return result;
  }
}
