View Javadoc
1   package org.apache.maven.doxia.sink.impl;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import org.apache.commons.lang3.builder.ToStringBuilder;
23  
24  /**
25   * A single sink event, used for testing purposes in order to check
26   * the order and effect of some parser events.
27   *
28   * @author ltheussl
29   * @since 1.1
30   */
31  public class SinkEventElement
32  {
33      /** The name of the sink event, ie the sink method name. */
34      private final String methodName;
35  
36      /** The array of arguments to the sink method. */
37      private final Object[] args;
38  
39      /**
40       * A SinkEventElement is characterized by the method name and associated array of arguments.
41       *
42       * @param name The name of the sink event, ie the sink method name.
43       * @param arguments The array of arguments to the sink method.
44       *      For a no-arg element this may be null or an empty array.
45       */
46      public SinkEventElement( String name, Object[] arguments )
47      {
48          if ( name == null )
49          {
50              throw new NullPointerException( "Element name can't be null!" );
51          }
52  
53          this.methodName = name;
54          this.args = arguments;
55      }
56  
57      /**
58       * Return the name of the this event.
59       *
60       * @return The name of the sink event.
61       */
62      public String getName()
63      {
64          return this.methodName;
65      }
66  
67      /**
68       * Return the array of arguments to the sink method.
69       *
70       * @return the array of arguments to the sink method.
71       */
72      public Object[] getArgs()
73      {
74          return this.args;
75      }
76  
77      /**
78       * {@inheritDoc}
79       * @since 1.1.1
80       */
81      @Override
82      public String toString()
83      {
84          return ToStringBuilder.reflectionToString( this );
85      }
86  }