Here you can find the source of assertParameter(Class expectedClass, Object[] params, int index)
Parameter | Description |
---|---|
IllegalArgumentException | if parameter is not there is wrong class type |
public static final Object assertParameter(Class expectedClass, Object[] params, int index)
//package com.java2s; /*/* w w w .ja va 2s. co m*/ * * * Copyright (C) 2007 Pingtel Corp., certain elements licensed under a Contributor Agreement. * Contributors retain copyright to elements licensed under a Contributor Agreement. * Licensed to the User under the LGPL license. * * $ */ public class Main { /** * Utility method to provide more descriptive unchecked exceptions for unmarshalling object * from Tapestry service Parameters. * * Please note that in most cases it is better to use listeners parameters directly. * * @throws IllegalArgumentException if parameter is not there is wrong class type */ public static final Object assertParameter(Class expectedClass, Object[] params, int index) { if (params == null || params.length < index) { throw new IllegalArgumentException( "Missing parameter at position " + index); } if (params[index] != null) { Class actualClass = params[index].getClass(); if (!expectedClass.isAssignableFrom(actualClass)) { throw new IllegalArgumentException("Object of class type " + expectedClass.getName() + " was expected at position " + index + " but class type was " + actualClass.getName()); } } return params[index]; } }