Revision: 1644 http://svn.sourceforge.net/spring-rich-c/?rev=1644&view=rev Author: kevinstembridge Date: 2007-01-11 11:29:41 -0800 (Thu, 11 Jan 2007)
Log Message: ----------- Moved from support module to core Added Paths: ----------- trunk/spring-richclient/core/src/main/java/org/springframework/richclient/util/Assert.java Added: trunk/spring-richclient/core/src/main/java/org/springframework/richclient/util/Assert.java =================================================================== --- trunk/spring-richclient/core/src/main/java/org/springframework/richclient/util/Assert.java (rev 0) +++ trunk/spring-richclient/core/src/main/java/org/springframework/richclient/util/Assert.java 2007-01-11 19:29:41 UTC (rev 1644) @@ -0,0 +1,65 @@ +/* + * Copyright 2002-2004 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package org.springframework.richclient.util; + +/** + * + * A convenience extension to Spring's [EMAIL PROTECTED] org.springframework.util.Assert} class. This + * is mainly for use within the framework. + * + * @author Oliver Hutchinson + * @author Kevin Stembridge + * + */ +public class Assert extends org.springframework.util.Assert { + + /** + * Assert that an object required; that is, it is not null. + * <pre> + * required(clazz, "class");</pre> + * @param object the object to check + * @param name the name of the object being checked + * @throws IllegalArgumentException if the object is <code>null</code> + */ + public static void required(Object object, String name) { + if (object == null) { + throw new IllegalArgumentException(name + " is required; it cannot be null"); + } + } + + /** + * Confirms that the given array is not null and that all of its elements are not null also. + * + * @param array The array whose elements, if any, must all be non-null. + * @param arrayName The property name of the array, only used for display purposes. May be null. + * + * @throws IllegalArgumentException if the given array is null or if any of its elements are null. + */ + public static void noElementsNull(Object[] array, String arrayName) { + + if (arrayName == null) { + arrayName = "array"; + } + + required(array, arrayName); + + for (int i = 0; i < array.length; i++) { + required(array[i], arrayName + "[" + i + "]"); + } + + } + +} Property changes on: trunk/spring-richclient/core/src/main/java/org/springframework/richclient/util/Assert.java ___________________________________________________________________ Name: svn:keywords + Author Id Revision Date HeadURL Name: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ spring-rich-c-cvs mailing list spring-rich-c-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/spring-rich-c-cvs