Clean up warnings in commons package.

This commit is contained in:
Simon Willnauer 2013-09-03 12:35:10 +02:00
parent 2ac7421f89
commit d5323231fe
4 changed files with 10 additions and 14 deletions

View File

@ -1366,7 +1366,7 @@ public class Base64 {
@Override
public Class<?> resolveClass(java.io.ObjectStreamClass streamClass)
throws java.io.IOException, ClassNotFoundException {
Class c = Class.forName(streamClass.getName(), false, loader);
Class<?> c = Class.forName(streamClass.getName(), false, loader);
if (c == null) {
return super.resolveClass(streamClass);
} else {

View File

@ -67,13 +67,13 @@ public class Classes {
* @return the package name, or the empty String if the class
* is defined in the default package
*/
public static String getPackageName(Class clazz) {
public static String getPackageName(Class<?> clazz) {
String className = clazz.getName();
int lastDotIndex = className.lastIndexOf(PACKAGE_SEPARATOR);
return (lastDotIndex != -1 ? className.substring(0, lastDotIndex) : "");
}
public static String getPackageNameNoDomain(Class clazz) {
public static String getPackageNameNoDomain(Class<?> clazz) {
String fullPackage = getPackageName(clazz);
if (fullPackage.startsWith("org.") || fullPackage.startsWith("com.") || fullPackage.startsWith("net.")) {
return fullPackage.substring(4);

View File

@ -19,6 +19,7 @@
package org.elasticsearch.common;
import com.google.common.base.Charsets;
import jsr166y.ThreadLocalRandom;
import java.io.BufferedReader;
@ -28,10 +29,6 @@ import java.io.InputStreamReader;
import java.net.URL;
import java.util.Random;
import org.elasticsearch.common.io.Streams;
import com.google.common.base.Charsets;
/**
*
*/

View File

@ -1025,7 +1025,6 @@ public class Strings {
final int len = chars.length;
int start = 0; // starting index in chars of the current substring.
int pos = 0; // current index in chars.
int i = 0; // number of the current substring.
for (; pos < len; pos++) {
if (chars[pos] == c) {
int size = pos - start;
@ -1303,15 +1302,15 @@ public class Strings {
* @param suffix the String to end each element with
* @return the delimited String
*/
public static String collectionToDelimitedString(Iterable coll, String delim, String prefix, String suffix) {
public static String collectionToDelimitedString(Iterable<?> coll, String delim, String prefix, String suffix) {
return collectionToDelimitedString(coll, delim, prefix, suffix, new StringBuilder());
}
public static String collectionToDelimitedString(Iterable coll, String delim, String prefix, String suffix, StringBuilder sb) {
public static String collectionToDelimitedString(Iterable<?> coll, String delim, String prefix, String suffix, StringBuilder sb) {
if (Iterables.isEmpty(coll)) {
return "";
}
Iterator it = coll.iterator();
Iterator<?> it = coll.iterator();
while (it.hasNext()) {
sb.append(prefix).append(it.next()).append(suffix);
if (it.hasNext()) {
@ -1329,7 +1328,7 @@ public class Strings {
* @param delim the delimiter to use (probably a ",")
* @return the delimited String
*/
public static String collectionToDelimitedString(Iterable coll, String delim) {
public static String collectionToDelimitedString(Iterable<?> coll, String delim) {
return collectionToDelimitedString(coll, delim, "", "");
}
@ -1340,7 +1339,7 @@ public class Strings {
* @param coll the Collection to display
* @return the delimited String
*/
public static String collectionToCommaDelimitedString(Iterable coll) {
public static String collectionToCommaDelimitedString(Iterable<?> coll) {
return collectionToDelimitedString(coll, ",");
}
@ -1490,7 +1489,6 @@ public class Strings {
}
private Strings() {
}
public static byte[] toUTF8Bytes(CharSequence charSequence) {
@ -1505,6 +1503,7 @@ public class Strings {
}
private static class SecureRandomHolder {
// class loading is atomic - this is a lazy & safe singleton
private static final SecureRandom INSTANCE = new SecureRandom();
}