001/* $Id: AddressBook.java 1102402 2011-05-12 18:03:26Z simonetripodi $
002 *
003 * Licensed to the Apache Software Foundation (ASF) under one or more
004 * contributor license agreements.  See the NOTICE file distributed with
005 * this work for additional information regarding copyright ownership.
006 * The ASF licenses this file to You under the Apache License, Version 2.0
007 * (the "License"); you may not use this file except in compliance with
008 * 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, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018package org.apache.commons.digester3.annotations.addressbook;
019
020import java.util.ArrayList;
021import java.util.List;
022
023import org.apache.commons.digester3.annotations.rules.ObjectCreate;
024import org.apache.commons.digester3.annotations.rules.SetNext;
025
026/**
027 * @since 2.1
028 */
029@ObjectCreate( pattern = "address-book" )
030public class AddressBook
031{
032
033    private final List<Person> people = new ArrayList<Person>();
034
035    @SetNext
036    public void addPerson( Person p )
037    {
038        this.people.add( p );
039    }
040
041    @Override
042    public boolean equals( Object obj )
043    {
044        if ( this == obj )
045            return true;
046        if ( obj == null )
047            return false;
048        if ( getClass() != obj.getClass() )
049            return false;
050        AddressBook other = (AddressBook) obj;
051        if ( people == null )
052        {
053            if ( other.people != null )
054                return false;
055        }
056        else if ( !people.equals( other.people ) )
057            return false;
058        return true;
059    }
060
061    @Override
062    public String toString()
063    {
064        return "AddressBook [people=" + people + "]";
065    }
066
067}