View Javadoc
1   /**
2    * Copyright (C) 2010-14 pvmanager developers. See COPYRIGHT.TXT
3    * All rights reserved. Use is subject to license terms. See LICENSE.TXT
4    */
5   package org.epics.pvmanager;
6   
7   /**
8    * The recipe for the read connection to a single channel.
9    * <p>
10   * The recipe is made up of two parts to make it easy to forward
11   * the request to a channel with a different name.
12   *
13   * @author carcassi
14   */
15  public class ChannelReadRecipe {
16      private final String channelName;
17      private final ChannelHandlerReadSubscription readSubscription;
18  
19      /**
20       * Creates a new read recipe for the given channel.
21       *
22       * @param channelName the name of the channel to connect to
23       * @param readSubscription the subscription parameters for the read
24       */
25      public ChannelReadRecipe(String channelName, ChannelHandlerReadSubscription readSubscription) {
26          this.channelName = channelName;
27          this.readSubscription = readSubscription;
28      }
29      
30      /**
31       * The name of the channel to read.
32       *
33       * @return the channel name
34       */
35      public String getChannelName() {
36          return channelName;
37      }
38  
39      /**
40       * The read subscription parameters.
41       *
42       * @return the read subscription parameters
43       */
44      public ChannelHandlerReadSubscription getReadSubscription() {
45          return readSubscription;
46      }
47  
48      @Override
49      public int hashCode() {
50          int hash = 5;
51          hash = 59 * hash + (this.channelName != null ? this.channelName.hashCode() : 0);
52          return hash;
53      }
54  
55      @Override
56      public boolean equals(Object obj) {
57          if (obj == null) {
58              return false;
59          }
60          if (getClass() != obj.getClass()) {
61              return false;
62          }
63          final ChannelReadRecipe other = (ChannelReadRecipe) obj;
64          if (this.readSubscription != other.readSubscription && (this.readSubscription == null || !this.readSubscription.equals(other.readSubscription))) {
65              return false;
66          }
67          return true;
68      }
69  
70      @Override
71      public String toString() {
72          return "[ChannelReadRecipe for " + channelName + ": " + readSubscription + "]";
73      }
74      
75  }