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

com.helger.graph.IBaseGraphNode Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (C) 2014-2024 Philip Helger (www.helger.com)
 * philip[at]helger[dot]com
 *
 * 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.helger.graph;

import java.util.function.Consumer;

import javax.annotation.Nonnegative;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;

import com.helger.commons.annotation.MustImplementEqualsAndHashcode;
import com.helger.commons.annotation.ReturnsMutableCopy;
import com.helger.commons.collection.impl.ICommonsOrderedSet;

/**
 * Base interface for a single graph node.
 *
 * @author Philip Helger
 * @param 
 *        Node class
 * @param 
 *        Relation class
 */
@MustImplementEqualsAndHashcode
public interface IBaseGraphNode , RELATIONTYPE extends IBaseGraphRelation >
                                extends
                                IBaseGraphObject
{
  /**
   * Check if this graph node is directly connected to the passed node, either
   * via an incoming or via an outgoing relation.
* This is the same as calling * isFromNode(aNode) || isToNode(aNode) * * @param aNode * The node to be checked. May be null. * @return true if is connected, false if not */ boolean isConnectedWith (@Nullable NODETYPE aNode); /** * Find the relation from this node to the passed node. * * @param aNode * The to node to use. May be null. * @return null if there exists no relation between this node and * the passed node. */ @Nullable RELATIONTYPE getRelation (@Nullable NODETYPE aNode); /** * Check if this node has any relations. * * @return true if this node has at least one incoming or * outgoing relation. */ boolean hasRelations (); /** * @return A non-negative amount of all incoming and outgoing relations. * Always ≥ 0. */ @Nonnegative int getRelationCount (); /** * @return A container with all incoming and outgoing relations. Never * null. */ @Nonnull @ReturnsMutableCopy ICommonsOrderedSet getAllRelations (); /** * @return A container with the IDs of all incoming and outgoing relations. * Never null. */ @Nonnull @ReturnsMutableCopy ICommonsOrderedSet getAllRelationIDs (); /** * Iterate each relation calling the provided consumer with the relation * object. * * @param aConsumer * The consumer to be invoked. May not be null. May only * perform reading operations! */ void forEachRelation (@Nonnull Consumer aConsumer); /** * @return A container with all nodes directly connected to this node's * relations. Never null. */ @Nonnull @ReturnsMutableCopy ICommonsOrderedSet getAllRelatedNodes (); /** * @return A container with the IDs of all nodes directly connected to this * node's relations. Never null. */ @Nonnull @ReturnsMutableCopy ICommonsOrderedSet getAllRelatedNodeIDs (); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy