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

com.arangodb.entity.EdgeDefinitionsEntity Maven / Gradle / Ivy

There is a newer version: 7.15.0
Show newest version
package com.arangodb.entity;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import com.arangodb.ArangoException;

public class EdgeDefinitionsEntity {
  
  /**
   * The list of edgeDefinitions
   */
  private List edgeDefinitions;
  
  /**
   * A list of edge collections used in the edge definitions
   */
  private List edgeCollections; 
  

  public EdgeDefinitionsEntity(List edgeDefinitions) {
    this.edgeDefinitions = edgeDefinitions;
    this.edgeCollections = new ArrayList();
    this.evalEdgeCollections();
  }
  
  public EdgeDefinitionsEntity() {
    this.edgeDefinitions = new ArrayList();
    this.edgeCollections = new ArrayList();
  }
  
  /**
   * returns the number of edge definitions
   * 
   * @return number of edge definitions
   */
  public int getSize() {
    return this.edgeDefinitions.size();
  }

  /**
   * get all edge definitions
   * 
   * @return
   */
  public List getEdgeDefinitions() {
    return edgeDefinitions;
  }

  /**
   * set the edge definitions (overwrites existing edge definitions)
   * 
   * @param edgeDefinitions the edge definitions to be set
   */
  public void setEdgeDefinitions(List edgeDefinitions) {
    this.edgeDefinitions = edgeDefinitions;
    this.evalEdgeCollections();
  }

  /**
   * add a single edge definition
   * 
   * @param edgeDefinition the edge definition to be added
   * @throws ArangoException
   */
  public void addEdgeDefinition(EdgeDefinitionEntity edgeDefinition) {
    if(!this.edgeCollections.contains(edgeDefinition.getCollection())) {
      this.edgeDefinitions.add(edgeDefinition);
      this.edgeCollections.add(edgeDefinition.getCollection());
    }
  }
  
  /**
   * get a single edge definition identified by its edge collection name
   * 
   * @param collectionName the name of the edge collection 
   * @return the adjacent edgeDefinition or null, if no match
   */
  public EdgeDefinitionEntity getEdgeDefinition(String collectionName) {
    for (EdgeDefinitionEntity edgeDefintion : this.edgeDefinitions) {
      if (edgeDefintion.getCollection() == collectionName) {
        return edgeDefintion;
      }
    }
    return null;
  }
  
  /**
   * fills the list of edgeCollections
   */
  private void evalEdgeCollections() {
    this.edgeCollections.clear();
    for (EdgeDefinitionEntity edgeDefintion : this.edgeDefinitions) {
      this.edgeCollections.add(edgeDefintion.getCollection());
    }
  }
  
  
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy