All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.intellij.vcs.log.graph.impl.facade.GraphChanges Maven / Gradle / Ivy

/*
 * Copyright 2000-2014 JetBrains s.r.o.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.intellij.vcs.log.graph.impl.facade;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.Collection;

public interface GraphChanges {

  @NotNull
  Collection> getChangedNodes();

  @NotNull
  Collection> getChangedEdges();

  interface Node {
    @NotNull
    NodeId getNodeId();

    boolean removed();
  }

  interface Edge {
    @Nullable
    NodeId upNodeId();

    @Nullable
    NodeId downNodeId();

    @Nullable
    NodeId targetId();

    boolean removed();
  }

  class NodeImpl implements Node {
    @NotNull private final NodeId myNodeId;
    private final boolean myRemoved;

    public NodeImpl(@NotNull NodeId nodeId, boolean removed) {
      myNodeId = nodeId;
      myRemoved = removed;
    }

    @NotNull
    @Override
    public NodeId getNodeId() {
      return myNodeId;
    }

    @Override
    public boolean removed() {
      return myRemoved;
    }
  }

  class EdgeImpl implements Edge {
    @Nullable private final NodeId myUpNodeId;
    @Nullable private final NodeId myDownNodeId;
    @Nullable private final NodeId myTargetId;
    private final boolean myRemoved;

    public EdgeImpl(@Nullable NodeId upNodeId, @Nullable NodeId downNodeId, @Nullable NodeId targetId, boolean removed) {
      myUpNodeId = upNodeId;
      myDownNodeId = downNodeId;
      myTargetId = targetId;
      myRemoved = removed;
    }

    @Nullable
    @Override
    public NodeId upNodeId() {
      return myUpNodeId;
    }

    @Nullable
    @Override
    public NodeId downNodeId() {
      return myDownNodeId;
    }

    @Nullable
    @Override
    public NodeId targetId() {
      return myTargetId;
    }

    @Override
    public boolean removed() {
      return myRemoved;
    }
  }

  class GraphChangesImpl implements GraphChanges {
    private final Collection> myChangedNodes;
    private final Collection> myChangedEdges;

    public GraphChangesImpl(Collection> changedNodes, Collection> changedEdges) {
      myChangedNodes = changedNodes;
      myChangedEdges = changedEdges;
    }

    @NotNull
    @Override
    public Collection> getChangedNodes() {
      return myChangedNodes;
    }

    @NotNull
    @Override
    public Collection> getChangedEdges() {
      return myChangedEdges;
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy