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          if ( ldapOperation == null
56              || actionTime == null
57              || spSpecs == null )
58          {
59              throw new NullArgumentException( I18n.err( I18n.ERR_04331 ) );
60          }
61          if ( spSpecs.size() == 0 )
62          {
63              throw new IllegalArgumentException( I18n.err( I18n.ERR_04332 ) );
64          }
65          this.ldapOperation = ldapOperation;
66          this.actionTime = actionTime;
67          this.spSpecs = spSpecs;
68      }
69  
70  
71      /**
72       * Gets the action time.
73       *
74       * @return the action time
75       */
76      public ActionTime getActionTime()
77      {
78          return actionTime;
79      }
80  
81  
82      /**
83       * Gets the LDAP operation.
84       *
85       * @return the LDAP operation
86       */
87      public LdapOperation getLdapOperation()
88      {
89          return ldapOperation;
90      }
91  
92  
93      /**
94       * Gets the stored procedure specs.
95       *
96       * @return the stored procedure specs
97       */
98      public List<SPSpec> getSPSpecs()
99      {
100         return spSpecs;
101     }
102 
103     /**
104      * The stored procedure spec bean.
105      */
106     public static class SPSpec
107     {
108         private String name;
109 
110         private List<StoredProcedureOption> options;
111 
112         private List<StoredProcedureParameter> parameters;
113 
114 
115         /**
116          * Instantiates a new stored procedure spec.
117          *
118          * @param name the name
119          * @param options the options
120          * @param parameters the parameters
121          */
122         public SPSpec( String name, List<StoredProcedureOption> options, List<StoredProcedureParameter> parameters )
123         {
124             super();
125             this.name = name;
126             this.options = options;
127             this.parameters = parameters;
128         }
129 
130 
131         /**
132          * Gets the name.
133          *
134          * @return the name
135          */
136         public String getName()
137         {
138             return name;
139         }
140 
141 
142         /**
143          * Gets the options.
144          *
145          * @return the options
146          */
147         public List<StoredProcedureOption> getOptions()
148         {
149             return options;
150         }
151 
152 
153         /**
154          * Gets the parameters.
155          *
156          * @return the parameters
157          */
158         public List<StoredProcedureParameter> getParameters()
159         {
160             return parameters;
161         }
162 
163 
164         /**
165          * {@inheritDoc}
166          */
167         @Override
168         public int hashCode()
169         {
170             int h = 37;
171 
172             h = h * 17 + ( ( name == null ) ? 0 : name.hashCode() );
173             h = h * 17 + ( ( options == null ) ? 0 : options.hashCode() );
174             h = h * 17 + ( ( parameters == null ) ? 0 : parameters.hashCode() );
175             return h;
176         }
177 
178 
179         /**
180          * {@inheritDoc}
181          */
182         @Override
183         public boolean equals( Object obj )
184         {
185             if ( this == obj )
186             {
187                 return true;
188             }
189             if ( obj == null )
190             {
191                 return false;
192             }
193             if ( getClass() != obj.getClass() )
194             {
195                 return false;
196             }
197             final SPSpec other = ( SPSpec ) obj;
198             if ( name == null )
199             {
200                 if ( other.name != null )
201                 {
202                     return false;
203                 }
204             }
205             else if ( !name.equals( other.name ) )
206             {
207                 return false;
208             }
209             if ( options == null )
210             {
211                 if ( other.options != null )
212                 {
213                     return false;
214                 }
215             }
216             else if ( !options.equals( other.options ) )
217             {
218                 return false;
219             }
220             if ( parameters == null )
221             {
222                 if ( other.parameters != null )
223                 {
224                     return false;
225                 }
226             }
227             else if ( !parameters.equals( other.parameters ) )
228             {
229                 return false;
230             }
231             return true;
232         }
233 
234     }
235 
236 }