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 java.util.Arrays; 23 import java.util.Objects; 24 25 /** 26 * A single sink event, used for testing purposes in order to check 27 * the order and effect of some parser events. 28 * 29 * @author ltheussl 30 * @since 1.1 31 */ 32 public class SinkEventElement 33 { 34 /** The name of the sink event, ie the sink method name. */ 35 private final String methodName; 36 37 /** The array of arguments to the sink method. */ 38 private final Object[] args; 39 40 /** 41 * A SinkEventElement is characterized by the method name and associated array of arguments. 42 * 43 * @param name The name of the sink event, ie the sink method name. 44 * @param arguments The array of arguments to the sink method. 45 * For a no-arg element this may be null or an empty array. 46 */ 47 public SinkEventElement( String name, Object[] arguments ) 48 { 49 Objects.requireNonNull( name, "name cannot be null" ); 50 51 this.methodName = name; 52 this.args = arguments; 53 } 54 55 /** 56 * Return the name of the this event. 57 * 58 * @return The name of the sink event. 59 */ 60 public String getName() 61 { 62 return this.methodName; 63 } 64 65 /** 66 * Return the array of arguments to the sink method. 67 * 68 * @return the array of arguments to the sink method. 69 */ 70 public Object[] getArgs() 71 { 72 return this.args; 73 } 74 75 /** 76 * {@inheritDoc} 77 * @since 1.1.1 78 */ 79 @Override 80 public String toString() 81 { 82 StringBuilder builder = new StringBuilder(); 83 builder.append( this.getClass().getSimpleName() ).append( '[' ); 84 builder.append( "methodName: " ).append( methodName ).append( ", " ); 85 builder.append( "args: " ).append( Arrays.toString( args ) ); 86 builder.append( ']' ); 87 return builder.toString(); 88 } 89 }