Beispiel #1
0
    public Object clone() {
      State clone = new State();
      clone.attribute = (AttributeImpl) attribute.clone();

      if (next != null) {
        clone.next = (State) next.clone();
      }

      return clone;
    }
    @Override
    public State clone() {
      State clone = new State();
      clone.attribute = attribute.clone();

      if (next != null) {
        clone.next = next.clone();
      }

      return clone;
    }
 public StateEditor(State parent, Edge e) {
   child = parent.clone();
   child.backState = parent;
   child.backEdge = e;
   // We clear child.next here, since it could have already been set in the
   // parent
   child.next = null;
   if (e == null) {
     child.backState = null;
     child.hops = 0;
     child.vertex = parent.vertex;
     child.stateData = child.stateData.clone();
   } else {
     child.hops = parent.hops + 1;
     // be clever
     // Note that we use equals(), not ==, here to allow for dynamically
     // created vertices
     if (e.getFromVertex().equals(e.getToVertex()) && parent.vertex.equals(e.getFromVertex())) {
       // TODO LG: We disable this test: the assumption that
       // the from and to vertex of an edge are not the same
       // is not true anymore: bike rental on/off edges.
       traversingBackward = parent.getOptions().isArriveBy();
       child.vertex = e.getToVertex();
     } else if (parent.vertex.equals(e.getFromVertex())) {
       traversingBackward = false;
       child.vertex = e.getToVertex();
     } else if (parent.vertex.equals(e.getToVertex())) {
       traversingBackward = true;
       child.vertex = e.getFromVertex();
     } else {
       // Parent state is not at either end of edge.
       LOG.warn("Edge is not connected to parent state: {}", e);
       LOG.warn("   from   vertex: {}", e.getFromVertex());
       LOG.warn("   to     vertex: {}", e.getToVertex());
       LOG.warn("   parent vertex: {}", parent.vertex);
       defectiveTraversal = true;
     }
     if (traversingBackward != parent.getOptions().isArriveBy()) {
       LOG.error(
           "Actual traversal direction does not match traversal direction in TraverseOptions.");
       defectiveTraversal = true;
     }
     if (parent.stateData.noThruTrafficState == NoThruTrafficState.INIT
         && !(e instanceof FreeEdge)) {
       setNoThruTrafficState(NoThruTrafficState.BETWEEN_ISLANDS);
     }
   }
 }
 /**
  * Captures the state of all Attributes. The return value can be passed to {@link #restoreState}
  * to restore the state of this or another AttributeSource.
  */
 public final State captureState() {
   final State state = this.getCurrentState();
   return (state == null) ? null : state.clone();
 }