cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject [2/6] cayenne git commit: replaced NullPointerException with IllegalArguementException (checkstyle warning) replaced RuntimeExcpetion with UnsupportedOperationException (checkstyle warning) modified JavaDoc for Exception handling checked instanceof for w
Date Sat, 02 Jan 2016 13:36:17 GMT
replaced NullPointerException with IllegalArguementException (checkstyle
warning)
replaced RuntimeExcpetion with UnsupportedOperationException (checkstyle
warning)
modified JavaDoc for Exception handling
checked instanceof for wrong variable in line 318

Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/349fcde6
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/349fcde6
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/349fcde6

Branch: refs/heads/master
Commit: 349fcde6ca971c7451af9979a9830e0a4a4ab111
Parents: 1358dad
Author: jotpe <jotpe@posteo.de>
Authored: Mon Dec 21 14:54:03 2015 +0100
Committer: jotpe <jotpe@posteo.de>
Committed: Mon Dec 21 14:54:03 2015 +0100

----------------------------------------------------------------------
 .../java/org/apache/cayenne/CayenneDataObject.java   | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/349fcde6/cayenne-server/src/main/java/org/apache/cayenne/CayenneDataObject.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/CayenneDataObject.java b/cayenne-server/src/main/java/org/apache/cayenne/CayenneDataObject.java
index b950257..8508692 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/CayenneDataObject.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/CayenneDataObject.java
@@ -291,29 +291,34 @@ public class CayenneDataObject extends PersistentObject implements DataObject,
V
 	 * @return <code>List&lt;? extends DataObject&gt;</code> of unrelated
 	 *         DataObjects. If no relationship was removed an empty List is
 	 *         returned.
-	 * @throws NullPointerException
+	 * @throws IllegalArgumentException
 	 *             if no relationship could be read by relName, or if the passed
 	 *             <code>Collection</code> is null. To clear all relationships
 	 *             use an empty <code>Collection</code>
+	 * @throws UnsupportedOperationException
+	 *             if the relation Collection Type is neither
+	 *             <code>java.util.Collection</code> nor
+	 *             <code>java.util.Map</code>
 	 * @since 4.0.M3
 	 */
+	@SuppressWarnings("unchecked")
 	public List<? extends DataObject> setToManyTarget(String relName, Collection<?
extends DataObject> values,
 			boolean setReverse) {
 		if (values == null) {
-			throw new NullPointerException();
+			throw new IllegalArgumentException("values Collection is null. To clear all relationships
use an empty Collection");
 		}
 
 		Object property = readProperty(relName);
 		if(property == null) {
-			throw new NullPointerException("unknown relName " + relName);
+			throw new IllegalArgumentException("unknown relName " + relName);
 		}
 		Collection<DataObject> old = null;
 		if (property instanceof Map) {
 			old = ((Map) property).values();
-		} else if (dataObjects instanceof Collection) {
+		} else if (property instanceof Collection) {
 			old = (Collection) property;
 		} else {
-			throw new RuntimeException("setToManyTarget only operates with Map and Collection types");
+			throw new UnsupportedOperationException("setToManyTarget operates only with Map or Collection
types");
 		}
 
 		// operate on a copy of passed collection


Mime
View raw message