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 * http://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
021 package org.apache.directory.shared.ldap.trigger;
022
023 import java.util.List;
024
025 import org.apache.commons.lang.NullArgumentException;
026
027 /**
028 * The Trigger Specification Bean.
029 *
030 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
031 * @version $Rev:$, $Date:$
032 */
033 public class TriggerSpecification
034 {
035
036 private LdapOperation ldapOperation;
037
038 private ActionTime actionTime;
039
040 private List<SPSpec> spSpecs;
041
042
043 public TriggerSpecification( LdapOperation ldapOperation, ActionTime actionTime, List<SPSpec> spSpecs )
044 {
045 super();
046 if ( ldapOperation == null ||
047 actionTime == null ||
048 spSpecs == null )
049 {
050 throw new NullArgumentException( "TriggerSpecification cannot be initialized with any NULL argument." );
051 }
052 if ( spSpecs.size() == 0 )
053 {
054 throw new IllegalArgumentException( "TriggerSpecification cannot be initialized with emtpy SPSPec list." );
055 }
056 this.ldapOperation = ldapOperation;
057 this.actionTime = actionTime;
058 this.spSpecs = spSpecs;
059 }
060
061 public ActionTime getActionTime()
062 {
063 return actionTime;
064 }
065
066 public LdapOperation getLdapOperation()
067 {
068 return ldapOperation;
069 }
070
071 public List<SPSpec> getSPSpecs() {
072 return spSpecs;
073 }
074
075 public static class SPSpec
076 {
077 private String name;
078
079 private List<StoredProcedureOption> options;
080
081 private List<StoredProcedureParameter> parameters;
082
083 public SPSpec(String name, List<StoredProcedureOption> options, List<StoredProcedureParameter> parameters) {
084 super();
085 this.name = name;
086 this.options = options;
087 this.parameters = parameters;
088 }
089
090 public String getName() {
091 return name;
092 }
093
094 public List<StoredProcedureOption> getOptions() {
095 return options;
096 }
097
098 public List<StoredProcedureParameter> getParameters() {
099 return parameters;
100 }
101
102 @Override
103 /**
104 * Compute the instance's hash code
105 * @return the instance's hash code
106 */
107 public int hashCode() {
108 int h = 37;
109
110 h = h*17 + ((name == null) ? 0 : name.hashCode());
111 h = h*17 + ((options == null) ? 0 : options.hashCode());
112 h = h*17 + ((parameters == null) ? 0 : parameters.hashCode());
113 return h;
114 }
115
116 @Override
117 public boolean equals(Object obj) {
118 if (this == obj)
119 return true;
120 if (obj == null)
121 return false;
122 if (getClass() != obj.getClass())
123 return false;
124 final SPSpec other = (SPSpec) obj;
125 if (name == null) {
126 if (other.name != null)
127 return false;
128 } else if (!name.equals(other.name))
129 return false;
130 if (options == null) {
131 if (other.options != null)
132 return false;
133 } else if (!options.equals(other.options))
134 return false;
135 if (parameters == null) {
136 if (other.parameters != null)
137 return false;
138 } else if (!parameters.equals(other.parameters))
139 return false;
140 return true;
141 }
142
143 }
144
145 }