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