cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r1053117 - /cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/utils/FBUtilities.java
Date Mon, 27 Dec 2010 17:51:33 GMT
Author: jbellis
Date: Mon Dec 27 17:51:33 2010
New Revision: 1053117

URL: http://svn.apache.org/viewvc?rev=1053117&view=rev
Log:
clean up FBUtilities
patch by Jon Hermes and jbellis

Modified:
    cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/utils/FBUtilities.java

Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/utils/FBUtilities.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/utils/FBUtilities.java?rev=1053117&r1=1053116&r2=1053117&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/utils/FBUtilities.java
(original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/utils/FBUtilities.java
Mon Dec 27 17:51:33 2010
@@ -19,7 +19,6 @@
 package org.apache.cassandra.utils;
 
 import java.io.*;
-import java.lang.reflect.Constructor;
 import java.lang.reflect.Field;
 import java.lang.reflect.InvocationTargetException;
 import java.math.BigInteger;
@@ -147,7 +146,7 @@ public class FBUtilities
             remainder = distance.testBit(0);
             midpoint = distance.shiftRight(1).add(left).mod(max);
         }
-        return new Pair(midpoint, remainder);
+        return new Pair<BigInteger, Boolean>(midpoint, remainder);
     }
 
     public static ByteBuffer toByteBuffer(int i)
@@ -489,9 +488,7 @@ public class FBUtilities
 
     public static String decodeToUTF8(ByteBuffer bytes) throws CharacterCodingException
     {
-        bytes = bytes.duplicate();
-        String decoded  =  Charsets.UTF_8.newDecoder().decode(bytes).toString();
-        return decoded;
+        return Charsets.UTF_8.newDecoder().decode(bytes.duplicate()).toString();
     }
 
     public static ByteBuffer toByteBuffer(long n)
@@ -558,7 +555,7 @@ public class FBUtilities
     {
         if (!partitionerClassName.contains("."))
             partitionerClassName = "org.apache.cassandra.dht." + partitionerClassName;
-        return FBUtilities.<IPartitioner>construct(partitionerClassName, "partitioner");
+        return FBUtilities.construct(partitionerClassName, "partitioner");
     }
 
     public static AbstractType getComparator(String compareWith) throws ConfigurationException
@@ -611,11 +608,10 @@ public class FBUtilities
      */
     public static <T> T construct(String classname, String readable) throws ConfigurationException
     {
-        Class<T> cls = FBUtilities.<T>classForName(classname, readable);
+        Class<T> cls = FBUtilities.classForName(classname, readable);
         try
         {
-            Constructor ctor = cls.getConstructor();
-            return (T)ctor.newInstance();
+            return cls.getConstructor().newInstance();
         }
         catch (NoSuchMethodException e)
         {
@@ -648,12 +644,6 @@ public class FBUtilities
         return joiner.join(map);
     }
 
-    /** slow! */
-    private static Object toString(Object o)
-    {
-        return o.getClass().isArray() ? Arrays.toString((Object[]) o) : o.toString();
-    }
-
     /**
      * Used to get access to protected/private field of the specified class
      * @param klass - name of the class



Mime
View raw message