View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.transport;
8   
9   import java.io.ObjectStreamException;
10  import java.io.Serializable;
11  
12  /**
13   * <code>NullPayload</code> represents a null event payload
14   */
15  // @Immutable
16  public final class NullPayload implements Serializable
17  {
18      /**
19       * Serial version
20       */
21      private static final long serialVersionUID = 3530905899811505080L;
22  
23      private static class NullPayloadHolder
24      {
25          private static final NullPayload instance = new NullPayload();
26      }
27  
28      public static NullPayload getInstance()
29      {
30          return NullPayloadHolder.instance;
31      }
32  
33      private NullPayload()
34      {
35          super();
36      }
37  
38      private Object readResolve() throws ObjectStreamException
39      {
40          return NullPayloadHolder.instance;
41      }
42  
43      @Override
44      public boolean equals(Object obj)
45      {
46          return obj instanceof NullPayload;
47      }
48  
49      @Override
50      public int hashCode ()
51      {
52          return 1; // random, 0 is taken by VoidResult
53      }
54  
55      @Override
56      public String toString()
57      {
58          return "{NullPayload}";
59      }
60  
61  }