View Javadoc
1   /*
2    *  Licensed to the Apache Software Foundation (ASF) under one
3    *  or more contributor license agreements.  See the NOTICE file
4    *  distributed with this work for additional information
5    *  regarding copyright ownership.  The ASF licenses this file
6    *  to you under the Apache License, Version 2.0 (the
7    *  "License"); you may not use this file except in compliance
8    *  with the License.  You may obtain a copy of the License at
9    *  
10   *    http://www.apache.org/licenses/LICENSE-2.0
11   *  
12   *  Unless required by applicable law or agreed to in writing,
13   *  software distributed under the License is distributed on an
14   *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   *  KIND, either express or implied.  See the License for the
16   *  specific language governing permissions and limitations
17   *  under the License. 
18   *  
19   */
20  
21  package org.apache.directory.api.ldap.trigger;
22  
23  
24  import java.util.List;
25  
26  import org.apache.commons.lang.NullArgumentException;
27  import org.apache.directory.api.i18n.I18n;
28  
29  
30  /**
31   * The Trigger Specification Bean.
32   * 
33   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
34   */
35  public class TriggerSpecification
36  {
37  
38      private LdapOperation ldapOperation;
39  
40      private ActionTime actionTime;
41  
42      private List<SPSpec> spSpecs;
43  
44  
45      /**
46       * Instantiates a new trigger specification.
47       *
48       * @param ldapOperation the LDAP operation
49       * @param actionTime the action time
50       * @param spSpecs the stored procedure specs
51       */
52      public TriggerSpecification( LdapOperation ldapOperation, ActionTime actionTime, List<SPSpec> spSpecs )
53      {
54          super();
55          
56          if ( ( ldapOperation == null ) || ( actionTime == null ) || ( spSpecs == null ) )
57          {
58              throw new NullArgumentException( I18n.err( I18n.ERR_04331 ) );
59          }
60          
61          if ( spSpecs.isEmpty() )
62          {
63              throw new IllegalArgumentException( I18n.err( I18n.ERR_04332 ) );
64          }
65          
66          this.ldapOperation = ldapOperation;
67          this.actionTime = actionTime;
68          this.spSpecs = spSpecs;
69      }
70  
71  
72      /**
73       * Gets the action time.
74       *
75       * @return the action time
76       */
77      public ActionTime getActionTime()
78      {
79          return actionTime;
80      }
81  
82  
83      /**
84       * Gets the LDAP operation.
85       *
86       * @return the LDAP operation
87       */
88      public LdapOperation getLdapOperation()
89      {
90          return ldapOperation;
91      }
92  
93  
94      /**
95       * Gets the stored procedure specs.
96       *
97       * @return the stored procedure specs
98       */
99      public List<SPSpec> getSPSpecs()
100     {
101         return spSpecs;
102     }
103 
104     /**
105      * The stored procedure spec bean.
106      */
107     public static class SPSpec
108     {
109         private String name;
110 
111         private List<StoredProcedureOption> options;
112 
113         private List<StoredProcedureParameter> parameters;
114 
115 
116         /**
117          * Instantiates a new stored procedure spec.
118          *
119          * @param name the name
120          * @param options the options
121          * @param parameters the parameters
122          */
123         public SPSpec( String name, List<StoredProcedureOption> options, List<StoredProcedureParameter> parameters )
124         {
125             super();
126             this.name = name;
127             this.options = options;
128             this.parameters = parameters;
129         }
130 
131 
132         /**
133          * Gets the name.
134          *
135          * @return the name
136          */
137         public String getName()
138         {
139             return name;
140         }
141 
142 
143         /**
144          * Gets the options.
145          *
146          * @return the options
147          */
148         public List<StoredProcedureOption> getOptions()
149         {
150             return options;
151         }
152 
153 
154         /**
155          * Gets the parameters.
156          *
157          * @return the parameters
158          */
159         public List<StoredProcedureParameter> getParameters()
160         {
161             return parameters;
162         }
163 
164 
165         /**
166          * {@inheritDoc}
167          */
168         @Override
169         public int hashCode()
170         {
171             int h = 37;
172 
173             h = h * 17 + ( ( name == null ) ? 0 : name.hashCode() );
174             h = h * 17 + ( ( options == null ) ? 0 : options.hashCode() );
175             h = h * 17 + ( ( parameters == null ) ? 0 : parameters.hashCode() );
176             return h;
177         }
178 
179 
180         /**
181          * {@inheritDoc}
182          */
183         @Override
184         public boolean equals( Object obj )
185         {
186             if ( this == obj )
187             {
188                 return true;
189             }
190             if ( obj == null )
191             {
192                 return false;
193             }
194             if ( getClass() != obj.getClass() )
195             {
196                 return false;
197             }
198             final SPSpec other = ( SPSpec ) obj;
199             if ( name == null )
200             {
201                 if ( other.name != null )
202                 {
203                     return false;
204                 }
205             }
206             else if ( !name.equals( other.name ) )
207             {
208                 return false;
209             }
210             if ( options == null )
211             {
212                 if ( other.options != null )
213                 {
214                     return false;
215                 }
216             }
217             else if ( !options.equals( other.options ) )
218             {
219                 return false;
220             }
221             if ( parameters == null )
222             {
223                 if ( other.parameters != null )
224                 {
225                     return false;
226                 }
227             }
228             else if ( !parameters.equals( other.parameters ) )
229             {
230                 return false;
231             }
232             return true;
233         }
234 
235     }
236 
237 }