jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1389864 - in /jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr: ItemDelegate.java PropertyImpl.java SessionDelegate.java
Date Tue, 25 Sep 2012 13:53:31 GMT
Author: mduerig
Date: Tue Sep 25 13:53:31 2012
New Revision: 1389864

URL: http://svn.apache.org/viewvc?rev=1389864&view=rev
Log:
OAK-341: Use Guava preconditions instead of asserts to enforce contract

Modified:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemDelegate.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionDelegate.java

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemDelegate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemDelegate.java?rev=1389864&r1=1389863&r2=1389864&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemDelegate.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemDelegate.java
Tue Sep 25 13:53:31 2012
@@ -25,6 +25,8 @@ import org.apache.jackrabbit.oak.api.Tre
 import org.apache.jackrabbit.oak.api.TreeLocation;
 import org.apache.jackrabbit.oak.commons.PathUtils;
 
+import static com.google.common.base.Preconditions.checkNotNull;
+
 /**
  * Abstract base class for {@link NodeDelegate} and {@link PropertyDelegate}
  */
@@ -36,11 +38,8 @@ public abstract class ItemDelegate {
     private TreeLocation location;
 
     ItemDelegate(SessionDelegate sessionDelegate, TreeLocation location) {
-        assert sessionDelegate != null;
-        assert location != null;
-
-        this.sessionDelegate = sessionDelegate;
-        this.location = location;
+        this.sessionDelegate = checkNotNull(sessionDelegate);
+        this.location = checkNotNull(location);
     }
 
     /**

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java?rev=1389864&r1=1389863&r2=1389864&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java
Tue Sep 25 13:53:31 2012
@@ -16,13 +16,12 @@
  */
 package org.apache.jackrabbit.oak.jcr;
 
-import static javax.jcr.PropertyType.UNDEFINED;
-
 import java.io.InputStream;
 import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.List;
+
 import javax.annotation.Nonnull;
 import javax.jcr.AccessDeniedException;
 import javax.jcr.Binary;
@@ -44,6 +43,9 @@ import org.apache.jackrabbit.value.Value
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import static com.google.common.base.Preconditions.checkArgument;
+import static javax.jcr.PropertyType.UNDEFINED;
+
 /**
  * {@code PropertyImpl}...
  */
@@ -663,7 +665,7 @@ public class PropertyImpl extends ItemIm
      * @throws RepositoryException
      */
     private void setValue(Value value, int requiredType) throws RepositoryException {
-        assert (requiredType != PropertyType.UNDEFINED);
+        checkArgument(requiredType != PropertyType.UNDEFINED);
 
         // TODO check again if definition validation should be respected here.
         if (isMultiple()) {
@@ -683,7 +685,7 @@ public class PropertyImpl extends ItemIm
      * @throws RepositoryException
      */
     private void setValues(Value[] values, int requiredType) throws RepositoryException {
-        assert (requiredType != PropertyType.UNDEFINED);
+        checkArgument(requiredType != PropertyType.UNDEFINED);
 
         // TODO check again if definition validation should be respected here.
         if (!isMultiple()) {

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionDelegate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionDelegate.java?rev=1389864&r1=1389863&r2=1389864&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionDelegate.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionDelegate.java
Tue Sep 25 13:53:31 2012
@@ -60,6 +60,8 @@ import org.apache.jackrabbit.oak.util.TO
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import static com.google.common.base.Preconditions.checkNotNull;
+
 public class SessionDelegate {
     static final Logger log = LoggerFactory.getLogger(SessionDelegate.class);
 
@@ -84,12 +86,10 @@ public class SessionDelegate {
             Repository repository, ScheduledExecutorService executor,
             ContentSession contentSession, boolean autoRefresh)
             throws RepositoryException {
-        assert repository != null;
-        assert contentSession != null;
 
-        this.repository = repository;
+        this.repository = checkNotNull(repository);
         this.executor = executor;
-        this.contentSession = contentSession;
+        this.contentSession = checkNotNull(contentSession);
         this.workspace = new WorkspaceImpl(this);
         this.session = new SessionImpl(this);
         this.root = contentSession.getLatestRoot();



Mime
View raw message