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.aci.ProtectedItem;
024
025
026/**
027 * Restricts the maximum number of immediate subordinates of the superior
028 * entry to an entry being added or imported. It is examined if the
029 * protected item is an entry, the permission sought is add or import, and
030 * the immediate superior entry is in the same DSA as the entry being added
031 * or imported. Immediate subordinates of the superior entry are counted
032 * without regard to context or access control as though the entry addition
033 * or importing were successful. If the number of subordinates exceeds
034 * maxImmSub, the ACI item is treated as not granting add or import access.
035 */
036public class MaxImmSubItem extends ProtectedItem
037{
038    /** The maximum number of allowed subordinates */
039    private final int value;
040
041
042    /**
043     * Creates a new instance.
044     * 
045     * @param value The maximum number of immediate subordinates
046     */
047    public MaxImmSubItem( int value )
048    {
049        this.value = value;
050    }
051
052
053    /**
054     * Gets the maximum number of immediate subordinates.
055     *
056     * @return the maximum number of immediate subordinates
057     */
058    public int getValue()
059    {
060        return value;
061    }
062
063
064    /**
065     * {@inheritDoc}
066     */
067    @Override
068    public int hashCode()
069    {
070        int hash = 37;
071        hash = hash * 17 + value;
072        return hash;
073    }
074
075
076    /**
077     * {@inheritDoc}
078     */
079    @Override
080    public boolean equals( Object o )
081    {
082        if ( this == o )
083        {
084            return true;
085        }
086
087        if ( o instanceof MaxImmSubItem )
088        {
089            MaxImmSubItem that = ( MaxImmSubItem ) o;
090            return this.value == that.value;
091        }
092
093        return false;
094    }
095
096
097    /**
098     * {@inheritDoc}
099     */
100    @Override
101    public String toString()
102    {
103        return "maxImmSub " + value;
104    }
105}