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 write 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 ChannelWriteRecipe {
16      private final String channelName;
17      private final ChannelHandlerWriteSubscription writeSubscription;
18  
19      /**
20       * Creates a new write recipe for the given channel.
21       * 
22       * @param channelName the name of the channel to connect to
23       * @param writeSubscription the subscription parameters for the write
24       */
25      public ChannelWriteRecipe(String channelName, ChannelHandlerWriteSubscription writeSubscription) {
26          this.channelName = channelName;
27          this.writeSubscription = writeSubscription;
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 write subscription parameters.
41       *
42       * @return the write subscription parameters
43       */
44      public ChannelHandlerWriteSubscription getWriteSubscription() {
45          return writeSubscription;
46      }
47  
48      @Override
49      public int hashCode() {
50          int hash = 5;
51          hash = 71 * hash + (this.channelName != null ? this.channelName.hashCode() : 0);
52          hash = 71 * hash + (this.writeSubscription != null ? this.writeSubscription.hashCode() : 0);
53          return hash;
54      }
55  
56      @Override
57      public boolean equals(Object obj) {
58          if (obj == null) {
59              return false;
60          }
61          if (getClass() != obj.getClass()) {
62              return false;
63          }
64          final ChannelWriteRecipe other = (ChannelWriteRecipe) obj;
65          if ((this.channelName == null) ? (other.channelName != null) : !this.channelName.equals(other.channelName)) {
66              return false;
67          }
68          if (this.writeSubscription != other.writeSubscription && (this.writeSubscription == null || !this.writeSubscription.equals(other.writeSubscription))) {
69              return false;
70          }
71          return true;
72      }
73      
74  }