Code example for NotSerializableException

0
 
public class MonitorState extends AbstractSingleWrapperState implements AvoidanceReportingState { 
  /* Boilerplate code to avoid serializing this class */ 
  private static final long serialVersionUID = 0xDEADBEEF;
  private void writeObject(java.io.ObjectOutputStream out) throws IOException {
    throw new NotSerializableException();
  } 
 
  static enum TimeoutState implements AbstractState { 
    INSTANCE;
 
    @Override 
    public String toString() {
      return "Dummy element because computation timed out"; 
    } 
  } 
 
  private final long totalTimeOnPath;
 
  // stores what caused the element to go further (may be null) 
  private final Pair<PreventingHeuristic, Long> preventingCondition;