View Javadoc

1   package org.apache.onami.autobind.install.bindjob;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one or more
5    * contributor license agreements.  See the NOTICE file distributed with
6    * this work for additional information regarding copyright ownership.
7    * The ASF licenses this file to You under the Apache License, Version 2.0
8    * (the "License"); you may not use this file except in compliance with
9    * the License.  You may obtain a copy of the License at
10   *
11   *  http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing, software
14   * distributed under the License is distributed on an "AS IS" BASIS,
15   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   * See the License for the specific language governing permissions and
17   * limitations under the License.
18   */
19  
20  import static com.google.common.base.Objects.equal;
21  import static com.google.common.base.Objects.toStringHelper;
22  
23  import java.lang.annotation.Annotation;
24  
25  import javax.inject.Provider;
26  
27  @SuppressWarnings( "rawtypes" )
28  public class BindingJob
29  {
30  
31      public final Class<? extends Annotation> scoped;
32  
33      public final Class<? extends Provider> provided;
34  
35      public final Annotation annotated;
36  
37      public final String className;
38  
39      public final String interfaceName;
40  
41      public BindingJob( Class<? extends Annotation> scoped, Class<? extends Provider> provided, Annotation annotated,
42                         String className, String interfaceName )
43      {
44          this.scoped = scoped;
45          this.provided = provided;
46          this.annotated = annotated;
47          this.className = className;
48          this.interfaceName = interfaceName;
49      }
50  
51      @Override
52      public int hashCode()
53      {
54          return hashCode( annotated, className, interfaceName, provided, scoped );
55      }
56  
57      @Override
58      public boolean equals( Object obj )
59      {
60          if ( this == obj )
61          {
62              return true;
63          }
64          if ( obj == null || getClass() != obj.getClass() )
65          {
66              return false;
67          }
68          BindingJob other = (BindingJob) obj;
69  
70          return equal( annotated, other.annotated )
71              && equal( interfaceName, other.interfaceName )
72              && equal( className, other.className )
73              && equal( provided, other.provided )
74              && equal( scoped, other.scoped );
75      }
76  
77      protected static int hashCode( Object...args )
78      {
79          final int prime = 31;
80          int result = 1;
81  
82          for ( Object arg : args )
83          {
84              result = prime * result + ( ( arg == null ) ? 0 : arg.hashCode() );
85          }
86  
87          return result;
88      }
89  
90      @Override
91      public String toString()
92      {
93          return toStringHelper( getClass() )
94                 .add( "annotated", annotated )
95                 .add( "className", className )
96                 .add( "interfaceName", interfaceName )
97                 .add( "provided", provided )
98                 .add( "scoped", scoped )
99                 .toString();
100     }
101 
102 }