Add UnqualifiedQName.tryCreate()
[yangtools.git] / yang / yang-common / src / main / java / org / opendaylight / yangtools / yang / common / OperationFailedException.java
index e1f0b710f766e67e5d8d39e99350d4ca3606275f..190b5a9303d88ab48deef5a365c13bf4e950bb43 100644 (file)
@@ -8,17 +8,14 @@
 
 package org.opendaylight.yangtools.yang.common;
 
+import static java.util.Objects.requireNonNull;
+
+import com.google.common.base.MoreObjects;
+import com.google.common.collect.ImmutableList;
 import java.util.Arrays;
 import java.util.List;
-
-import org.opendaylight.yangtools.yang.common.RpcError;
-import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
 import org.opendaylight.yangtools.yang.common.RpcError.ErrorType;
 
-import com.google.common.base.Objects;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.ImmutableList;
-
 /**
  * A general base exception for an operation failure.
  *
@@ -28,7 +25,7 @@ public class OperationFailedException extends Exception {
 
     private static final long serialVersionUID = 1L;
 
-    private final List<RpcError> errorList;
+    private final ImmutableList<RpcError> errorList;
 
     /**
      * Constructs a new instance with the specified detail message and errors.
@@ -51,12 +48,11 @@ public class OperationFailedException extends Exception {
      */
     public OperationFailedException(final String message, final Throwable cause,
                                     final RpcError... errors) {
-        super(Preconditions.checkNotNull(message), cause);
+        super(requireNonNull(message), cause);
 
-        if( errors != null && errors.length > 0 ) {
-            errorList = ImmutableList.<RpcError>copyOf( Arrays.asList( errors ) );
-        }
-        else {
+        if (errors != null && errors.length > 0) {
+            errorList = ImmutableList.copyOf(Arrays.asList(errors));
+        } else {
             // Add a default RpcError.
             errorList = ImmutableList.of(RpcResultBuilder.newError(ErrorType.APPLICATION, null,
                     getMessage(), null, null, getCause()));
@@ -74,7 +70,7 @@ public class OperationFailedException extends Exception {
 
     @Override
     public String toString() {
-        return Objects.toStringHelper( this ).add( "message", getMessage() )
-                .add( "errorList", errorList ).toString();
+        return MoreObjects.toStringHelper(this).add("message", getMessage())
+                .add("errorList", errorList).toString();
     }
 }