001package org.apache.maven.doxia.sink;
002
003/*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements.  See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership.  The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License.  You may obtain a copy of the License at
011 *
012 *   http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied.  See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022import org.apache.commons.lang.builder.ToStringBuilder;
023
024/**
025 * A single sink event, used for testing purposes in order to check
026 * the order and effect of some parser events.
027 *
028 * @author ltheussl
029 * @version $Id$
030 * @since 1.1
031 */
032public class SinkEventElement
033{
034    /** The name of the sink event, ie the sink method name. */
035    private final String methodName;
036
037    /** The array of arguments to the sink method. */
038    private final Object[] args;
039
040    /**
041     * A SinkEventElement is characterized by the method name and associated array of arguments.
042     *
043     * @param name The name of the sink event, ie the sink method name.
044     * @param arguments The array of arguments to the sink method.
045     *      For a no-arg element this may be null or an empty array.
046     */
047    public SinkEventElement( String name, Object[] arguments )
048    {
049        if ( name == null )
050        {
051            throw new NullPointerException( "Element name can't be null!" );
052        }
053
054        this.methodName = name;
055        this.args = arguments;
056    }
057
058    /**
059     * Return the name of the this event.
060     *
061     * @return The name of the sink event.
062     */
063    public String getName()
064    {
065        return this.methodName;
066    }
067
068    /**
069     * Return the array of arguments to the sink method.
070     *
071     * @return the array of arguments to the sink method.
072     */
073    public Object[] getArgs()
074    {
075        return this.args;
076    }
077
078    /**
079     * {@inheritDoc}
080     * @since 1.1.1
081     */
082    @Override
083    public String toString()
084    {
085        return ToStringBuilder.reflectionToString( this );
086    }
087}