001/*
002 *  Licensed to the Apache Software Foundation (ASF) under one
003 *  or more contributor license agreements.  See the NOTICE file
004 *  distributed with this work for additional information
005 *  regarding copyright ownership.  The ASF licenses this file
006 *  to you under the Apache License, Version 2.0 (the
007 *  "License"); you may not use this file except in compliance
008 *  with the License.  You may obtain a copy of the License at
009 *
010 *    https://www.apache.org/licenses/LICENSE-2.0
011 *
012 *  Unless required by applicable law or agreed to in writing,
013 *  software distributed under the License is distributed on an
014 *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 *  KIND, either express or implied.  See the License for the
016 *  specific language governing permissions and limitations
017 *  under the License.
018 *
019 */
020
021package org.apache.directory.api.ldap.trigger;
022
023
024import java.util.List;
025
026import org.apache.directory.api.i18n.I18n;
027
028
029/**
030 * The Trigger Specification Bean.
031 *
032 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
033 */
034public class TriggerSpecification
035{
036
037    private LdapOperation ldapOperation;
038
039    private ActionTime actionTime;
040
041    private List<SPSpec> spSpecs;
042
043
044    /**
045     * Instantiates a new trigger specification.
046     *
047     * @param ldapOperation the LDAP operation
048     * @param actionTime the action time
049     * @param spSpecs the stored procedure specs
050     */
051    public TriggerSpecification( LdapOperation ldapOperation, ActionTime actionTime, List<SPSpec> spSpecs )
052    {
053        super();
054
055        if ( ( ldapOperation == null ) || ( actionTime == null ) || ( spSpecs == null ) )
056        {
057            throw new NullPointerException( I18n.err( I18n.ERR_11000_TRIGGER_SPECIFICATION_INIT_WITH_NULL ) );
058        }
059
060        if ( spSpecs.isEmpty() )
061        {
062            throw new IllegalArgumentException( I18n.err( I18n.ERR_11001_TRIGGER_SPECIFICATION_INIT_WITH_EPTY_SPEC_LIST ) );
063        }
064
065        this.ldapOperation = ldapOperation;
066        this.actionTime = actionTime;
067        this.spSpecs = spSpecs;
068    }
069
070
071    /**
072     * Gets the action time.
073     *
074     * @return the action time
075     */
076    public ActionTime getActionTime()
077    {
078        return actionTime;
079    }
080
081
082    /**
083     * Gets the LDAP operation.
084     *
085     * @return the LDAP operation
086     */
087    public LdapOperation getLdapOperation()
088    {
089        return ldapOperation;
090    }
091
092
093    /**
094     * Gets the stored procedure specs.
095     *
096     * @return the stored procedure specs
097     */
098    public List<SPSpec> getSPSpecs()
099    {
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
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
191            if ( obj == null )
192            {
193                return false;
194            }
195
196            if ( getClass() != obj.getClass() )
197            {
198                return false;
199            }
200
201            SPSpec other = ( SPSpec ) obj;
202
203            if ( name == null )
204            {
205                if ( other.name != null )
206                {
207                    return false;
208                }
209            }
210            else if ( !name.equals( other.name ) )
211            {
212                return false;
213            }
214
215            if ( options == null )
216            {
217                if ( other.options != null )
218                {
219                    return false;
220                }
221            }
222            else if ( !options.equals( other.options ) )
223            {
224                return false;
225            }
226
227            if ( parameters == null )
228            {
229                if ( other.parameters != null )
230                {
231                    return false;
232                }
233            }
234            else if ( !parameters.equals( other.parameters ) )
235            {
236                return false;
237            }
238
239            return true;
240        }
241    }
242}