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 */ 020package org.apache.directory.api.ldap.aci.protectedItem; 021 022 023import org.apache.directory.api.ldap.model.schema.AttributeType; 024 025 026/** 027 * An element of {@link MaxValueCount}. 028 */ 029public class MaxValueCountElem 030{ 031 /** The targeted AttributeType */ 032 private AttributeType attributeType; 033 034 /** The maximum number of accepted values for this attributeType */ 035 private int maxCount; 036 037 038 /** 039 * Creates a new instance. 040 * 041 * @param attributeType the attribute ID to limit the maximum count 042 * @param maxCount the maximum count of the attribute allowed 043 */ 044 045 public MaxValueCountElem( AttributeType attributeType, int maxCount ) 046 { 047 this.attributeType = attributeType; 048 this.maxCount = maxCount; 049 } 050 051 052 /** 053 * Gets the attribute to limit the maximum count. 054 * 055 * @return the attribute type 056 */ 057 public AttributeType getAttributeType() 058 { 059 return attributeType; 060 } 061 062 063 /** 064 * Gets the maximum count of the attribute allowed. 065 * 066 * @return the maximum count of the attribute allowed 067 */ 068 public int getMaxCount() 069 { 070 return maxCount; 071 } 072 073 074 /** 075 * {@inheritDoc} 076 */ 077 @Override 078 public int hashCode() 079 { 080 int hash = 37; 081 hash = hash * 17 + maxCount; 082 hash = hash * 17 + attributeType.hashCode(); 083 return hash; 084 } 085 086 087 /** 088 * {@inheritDoc} 089 */ 090 @Override 091 public boolean equals( Object o ) 092 { 093 if ( o == null ) 094 { 095 return false; 096 } 097 098 if ( this == o ) 099 { 100 return true; 101 } 102 103 if ( o instanceof MaxValueCountElem ) 104 { 105 MaxValueCountElem that = ( MaxValueCountElem ) o; 106 if ( this.maxCount == that.maxCount ) 107 { 108 if ( this.attributeType == null ) 109 { 110 return that.attributeType == null; 111 } 112 else 113 { 114 return this.attributeType.equals( that.attributeType ); 115 } 116 } 117 } 118 return false; 119 } 120 121 122 /** 123 * {@inheritDoc} 124 */ 125 @Override 126 public String toString() 127 { 128 return "{ type " + attributeType.getName() + ", maxCount " + maxCount + " }"; 129 } 130}