List of usage examples for org.apache.commons.lang Validate allElementsOfType
public static void allElementsOfType(Collection collection, Class clazz, String message)
Validate an argument, throwing IllegalArgumentException
if the argument collection is null
or has elements that are not of type clazz
or a subclass.
Validate.allElementsOfType(collection, String.class, "Collection has invalid elements");
From source file:com.prowidesoftware.swift.model.SwiftBlock4.java
/** * Constructor with tag initialization/*from ww w.ja v a2 s. c o m*/ * @param tags the list of tags to initialize * @throws IllegalArgumentException if parameter tags is <code>null</code> * @throws IllegalArgumentException if parameter tags is not composed of Strings * @since 5.0 */ public SwiftBlock4(List<Tag> tags) { // sanity check Validate.notNull(tags, "parameter 'tags' cannot be null"); Validate.allElementsOfType(tags, Tag.class, "parameter 'tags' may only have Tag elements"); this.addTags(tags); }
From source file:com.prowidesoftware.swift.model.SwiftBlock5.java
/** * Constructor with tag initialization//from www. j ava 2s.c o m * @param tags the list of tags to initialize * @throws IllegalArgumentException if parameter tags is <code>null</code> * @throws IllegalArgumentException if parameter tags is not composed of Strings * @since 5.0 */ public SwiftBlock5(final List<Tag> tags) { // sanity check Validate.notNull(tags, "parameter 'tags' cannot be null"); Validate.allElementsOfType(tags, Tag.class, "parameter 'tags' may only have Tag elements"); this.addTags(tags); }
From source file:com.prowidesoftware.swift.model.SwiftBlockUser.java
/** * Constructor for numbered user block with tag initialization * @param blockNumber the block number to initialize * @param tags the list of tags to initialize * @throws IllegalArgumentException if parameter blockNumber or tags are <code>null</code> * @throws IllegalArgumentException if parameter blockNumber is not a valid User Defined Block number (values 6..9) * @throws IllegalArgumentException if parameter tags is not composed of Strings * @since 5.0/*from w w w . j av a 2 s . c o m*/ */ public SwiftBlockUser(Integer blockNumber, List<Tag> tags) { // sanity check Validate.notNull(blockNumber, "parameter 'blockNumber' cannot be null"); Validate.isTrue(SwiftBlockUser.isValidName(blockNumber).booleanValue(), "'blockNumber' is not a valid User Defined Block number"); Validate.allElementsOfType(tags, Tag.class, "parameter 'tags' may only have Tag elements"); this.setBlockNumber(blockNumber); this.addTags(tags); }
From source file:com.prowidesoftware.swift.model.UnparsedTextList.java
/** * Constructor from a collection of texts * @param texts the list of unparsed texts to set * @throws IllegalArgumentException if parameter texts is <code>null</code> * @throws IllegalArgumentException if parameter texts has elements of class other than String *//*from w w w .j av a 2 s .c o m*/ public UnparsedTextList(final Collection<String> texts) { // sanity check Validate.notNull(texts, "parameter 'texts' cannot be null"); Validate.allElementsOfType(texts, String.class, "parameter 'texts' may only have String elements"); this.texts = new ArrayList<String>(texts); }
From source file:com.prowidesoftware.swift.model.SwiftBlockUser.java
/** * Constructor for named user block with tag initialization * @param blockName the block name to initialize * @param tags the list of tags to initialize * @throws IllegalArgumentException if parameter blockName or tags are <code>null</code> * @throws IllegalArgumentException if parameter blockName is not a valid User Defined Block name (single letter) * @throws IllegalArgumentException if parameter tags is not composed of Strings * @since 5.0//from ww w . j a v a 2 s . c o m */ public SwiftBlockUser(String blockName, List<Tag> tags) { // sanity check Validate.notNull(blockName, "parameter 'blockName' cannot be null"); Validate.isTrue(SwiftBlockUser.isValidName(blockName).booleanValue(), "'blockName' is not a valid User Defined Block name"); Validate.allElementsOfType(tags, Tag.class, "parameter 'tags' may only have Tag elements"); this.setBlockName(blockName); this.addTags(tags); }
From source file:com.prowidesoftware.swift.model.SwiftMessage.java
/** * Set the list of user defined blocks.<br> * This method is mainly needed for persistence services. * * @param userBlocks the new list of user defined blocks * @throws IllegalArgumentException if parameter userBlocks is <code>null</code> * @throws IllegalArgumentException if parameter userBlocks has elements of class other than SwiftBlockUser * @since 5.0/* w w w .j a v a 2 s. c om*/ * @see SwiftBlockUser */ protected void setUserBlocks(final List<SwiftBlockUser> userBlocks) { // sanity check Validate.notNull(userBlocks, "parameter 'userBlocks' cannot be null"); Validate.allElementsOfType(userBlocks, SwiftBlockUser.class, "parameter 'userBlocks' may only have SwiftBlockUser elements"); // setup the new list this.userBlocks = userBlocks; }
From source file:com.prowidesoftware.swift.model.SwiftTagListBlock.java
/** * Add all tags in the List argument to the current blocks. Current tags will not be removed. * @param tags the list of tags to add//ww w. j av a 2 s . c o m * @throws IllegalArgumentException if parameter name is <code>null</code> */ public void addTags(final List<Tag> tags) { // sanity check Validate.notNull(tags, "parameter 'tags' cannot not be null"); Validate.allElementsOfType(tags, Tag.class, "parameter 'tags' may only have Tag elements"); thisTagsNotNull().addAll(tags); }
From source file:com.prowidesoftware.swift.model.SwiftTagListBlock.java
/** * Set the list of tags of this block./* www . j ava2s . c o m*/ * NOTE that the order of the tags in the list is the order that really matters. * * @param tags the tags of the block, may be <code>null</code> to remove all the tags of the block * @throws IllegalArgumentException if parameter tags is not <code>null</code> and contains elements of class other than Tag */ public void setTags(final List<Tag> tags) { // sanity check if (tags != null) { Validate.allElementsOfType(tags, Tag.class, "parameter 'tags' may only have Tag elements"); } this.tags = tags; }