View Javadoc

1   /*
2    * Copyright 2010 Fraunhofer Gesellschaft, Munich, Germany,
3    * for its Fraunhofer Institute for Computer Architecture and Software
4    * Technology (FIRST), Berlin, Germany. All rights reserved.
5    * http://www.first.fraunhofer.de/
6    */
7   
8   package net.kwfgrid.gwes.workflowanalyzer;
9   
10  /**
11   * @author Andreas Hoheisel
12   *         (<a href="http://www.andreas-hoheisel.de">www.andreas-hoheisel.de</a>)
13   * @version $Id: OperationResourcePair.java 1419 2010-11-01 14:12:17Z hoheisel $
14   */
15  public class OperationResourcePair {
16  
17      private final String operation;
18      private final String resource;
19      private int hashCode = 0;
20  
21      /**
22       * Create new operation/resource pair.
23       * @param operation
24       * @param resource
25       */
26      public OperationResourcePair(String operation, String resource) {
27          this.operation = operation;
28          this.resource = resource;
29      }
30      
31      public String getOperation() {
32          return operation;
33      }
34  
35      public String getResource() {
36          return resource;
37      }
38  
39      @Override
40      public boolean equals(Object o) {
41          if (this == o) return true;
42          if (o == null || getClass() != o.getClass()) return false;
43  
44          OperationResourcePair that = (OperationResourcePair) o;
45  
46          return !(operation != null ? !operation.equals(that.operation) : that.operation != null) && !(resource != null ? !resource.equals(that.resource) : that.resource != null);
47  
48      }
49  
50      @Override
51      public int hashCode() {
52          if (this.hashCode !=0) return this.hashCode;
53          int i = operation != null ? operation.hashCode() : 0;
54          i = 31 * i + (resource != null ? resource.hashCode() : 0);
55          hashCode = i;
56          return hashCode;
57      }
58  
59      @Override
60      public String toString() {
61          StringBuffer buffer = new StringBuffer();
62          buffer.append('{').append(operation).append('|').append(resource).append('}');
63          return buffer.toString();
64      }
65  }