View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.maven.repository;
20  
21  import java.util.ArrayList;
22  import java.util.List;
23  
24  /**
25   * MetadataGraph node - as it's a directed graph - holds adjacency lists for incident and exident nodes
26   *
27   *
28   */
29  @Deprecated
30  public class MetadataGraphNode {
31      /** node payload */
32      MavenArtifactMetadata metadata;
33  
34      /** nodes, incident to this (depend on me) */
35      List<MetadataGraphNode> inNodes;
36  
37      /** nodes, exident to this (I depend on) */
38      List<MetadataGraphNode> exNodes;
39  
40      public MetadataGraphNode() {
41          inNodes = new ArrayList<>(4);
42          exNodes = new ArrayList<>(8);
43      }
44  
45      public MetadataGraphNode(MavenArtifactMetadata metadata) {
46          this();
47          this.metadata = metadata;
48      }
49  
50      public MetadataGraphNode addIncident(MetadataGraphNode node) {
51          inNodes.add(node);
52          return this;
53      }
54  
55      public MetadataGraphNode addExident(MetadataGraphNode node) {
56          exNodes.add(node);
57          return this;
58      }
59  
60      @Override
61      public boolean equals(Object obj) {
62          if (obj == null) {
63              return false;
64          }
65  
66          if (MetadataGraphNode.class.isAssignableFrom(obj.getClass())) {
67              MetadataGraphNode node2 = (MetadataGraphNode) obj;
68  
69              if (node2.metadata == null) {
70                  return metadata == null;
71              }
72  
73              return metadata != null && metadata.toString().equals(node2.metadata.toString());
74          } else {
75              return super.equals(obj);
76          }
77      }
78  
79      @Override
80      public int hashCode() {
81          if (metadata == null) {
82              return super.hashCode();
83          }
84  
85          return metadata.toString().hashCode();
86      }
87  }