Avoid unnecessary boxing

Found with FindBugs.
This commit is contained in:
Andrew Gaul 2014-08-27 10:16:34 -07:00
parent 63d43f236e
commit 5399cb6877
17 changed files with 50 additions and 50 deletions

View File

@ -63,7 +63,7 @@ public class MapToDriveInfo implements Function<Map<String, String>, DriveInfo>
if (from.containsKey("readers"))
builder.readers(Splitter.on(' ').split(from.get("readers")));
if (from.containsKey("size"))
builder.size(Long.valueOf(from.get("size")));
builder.size(Long.parseLong(from.get("size")));
Map<String, String> metadata = Maps.newLinkedHashMap();
for (Entry<String, String> entry : from.entrySet()) {
if (entry.getKey().startsWith("user:"))
@ -72,7 +72,7 @@ public class MapToDriveInfo implements Function<Map<String, String>, DriveInfo>
if (from.containsKey("use"))
builder.use(Splitter.on(' ').split(from.get("use")));
if (from.containsKey("bits"))
builder.bits(Integer.valueOf(from.get("bits")));
builder.bits(Integer.parseInt(from.get("bits")));
if (from.containsKey("url"))
builder.url(URI.create(from.get("url")));
builder.encryptionKey(from.get("encryption:key"));
@ -98,13 +98,13 @@ public class MapToDriveInfo implements Function<Map<String, String>, DriveInfo>
protected DriveMetrics buildMetrics(Map<String, String> from) {
DriveMetrics.Builder metricsBuilder = new DriveMetrics.Builder();
if (from.containsKey("read:bytes"))
metricsBuilder.readBytes(Long.valueOf(from.get("read:bytes")));
metricsBuilder.readBytes(Long.parseLong(from.get("read:bytes")));
if (from.containsKey("read:requests"))
metricsBuilder.readRequests(Long.valueOf(from.get("read:requests")));
metricsBuilder.readRequests(Long.parseLong(from.get("read:requests")));
if (from.containsKey("write:bytes"))
metricsBuilder.writeBytes(Long.valueOf(from.get("write:bytes")));
metricsBuilder.writeBytes(Long.parseLong(from.get("write:bytes")));
if (from.containsKey("write:requests"))
metricsBuilder.writeRequests(Long.valueOf(from.get("write:requests")));
metricsBuilder.writeRequests(Long.parseLong(from.get("write:requests")));
return metricsBuilder.build();
}
}

View File

@ -68,13 +68,13 @@ public class MapToDriveMetrics implements Function<Map<String, String>, Map<Stri
protected DriveMetrics buildMetrics(String key, Map<String, String> from) {
DriveMetrics.Builder builder = new DriveMetrics.Builder();
if (from.containsKey(key + ":read:bytes"))
builder.readBytes(Long.valueOf(from.get(key + ":read:bytes")));
builder.readBytes(Long.parseLong(from.get(key + ":read:bytes")));
if (from.containsKey(key + ":read:requests"))
builder.readRequests(Long.valueOf(from.get(key + ":read:requests")));
builder.readRequests(Long.parseLong(from.get(key + ":read:requests")));
if (from.containsKey(key + ":write:bytes"))
builder.writeBytes(Long.valueOf(from.get(key + ":write:bytes")));
builder.writeBytes(Long.parseLong(from.get(key + ":write:bytes")));
if (from.containsKey(key + ":write:requests"))
builder.writeRequests(Long.valueOf(from.get(key + ":write:requests")));
builder.writeRequests(Long.parseLong(from.get(key + ":write:requests")));
return builder.build();
}
}

View File

@ -62,12 +62,12 @@ public class MapToServerInfo implements Function<Map<String, String>, ServerInfo
if (from.containsKey("status"))
builder.status(ServerStatus.fromValue(from.get("status")));
if (from.containsKey("smp") && !"auto".equals(from.get("smp")))
builder.smp(Integer.valueOf(from.get("smp")));
builder.smp(Integer.parseInt(from.get("smp")));
builder.cpu(Integer.parseInt(from.get("cpu")));
builder.mem(Integer.parseInt(from.get("mem")));
builder.user(from.get("user"));
if (from.containsKey("started"))
builder.started(new Date(Long.valueOf(from.get("started"))));
builder.started(new Date(Long.parseLong(from.get("started"))));
builder.uuid(from.get("server"));
builder.vnc(new VNC(from.get("vnc:ip"), from.get("vnc:password"), from.containsKey("vnc:tls")
&& Boolean.valueOf(from.get("vnc:tls"))));

View File

@ -38,13 +38,13 @@ public class MapToServerMetrics implements Function<Map<String, String>, ServerM
public ServerMetrics apply(Map<String, String> from) {
ServerMetrics.Builder metricsBuilder = new ServerMetrics.Builder();
if (from.containsKey("tx:packets"))
metricsBuilder.txPackets(Long.valueOf(from.get("tx:packets")));
metricsBuilder.txPackets(Long.parseLong(from.get("tx:packets")));
if (from.containsKey("tx"))
metricsBuilder.tx(Long.valueOf(from.get("tx")));
metricsBuilder.tx(Long.parseLong(from.get("tx")));
if (from.containsKey("rx:packets"))
metricsBuilder.rxPackets(Long.valueOf(from.get("rx:packets")));
metricsBuilder.rxPackets(Long.parseLong(from.get("rx:packets")));
if (from.containsKey("rx"))
metricsBuilder.rx(Long.valueOf(from.get("rx")));
metricsBuilder.rx(Long.parseLong(from.get("rx")));
metricsBuilder.driveMetrics(mapToDriveMetrics.apply(from));
ServerMetrics metrics = metricsBuilder.build();

View File

@ -138,13 +138,13 @@ public class MetricAlarmHandler extends ParseSax.HandlerForGeneratedRequestWithR
} else if (qName.equals("ComparisonOperator")) {
comparisonOperator = ComparisonOperator.fromValue(SaxUtils.currentOrNull(currentText));
} else if (qName.equals("EvaluationPeriods")) {
evaluationPeriods = Integer.valueOf(SaxUtils.currentOrNull(currentText));
evaluationPeriods = Integer.parseInt(SaxUtils.currentOrNull(currentText));
} else if (qName.equals("MetricName")) {
metricName = SaxUtils.currentOrNull(currentText);
} else if (qName.equals("Namespace")) {
namespace = SaxUtils.currentOrNull(currentText);
} else if (qName.equals("Period")) {
period = Integer.valueOf(SaxUtils.currentOrNull(currentText));
period = Integer.parseInt(SaxUtils.currentOrNull(currentText));
} else if (qName.equals("StateReason")) {
stateReason = SaxUtils.currentOrNull(currentText);
} else if (qName.equals("StateReasonData")) {

View File

@ -59,7 +59,7 @@ public class MapToDriveInfo implements Function<Map<String, String>, DriveInfo>
if (from.containsKey("readers"))
builder.readers(Splitter.on(' ').split(from.get("readers")));
if (from.containsKey("size"))
builder.size(Long.valueOf(from.get("size")));
builder.size(Long.parseLong(from.get("size")));
Map<String, String> metadata = Maps.newLinkedHashMap();
for (Entry<String, String> entry : from.entrySet()) {
if (entry.getKey().startsWith("user:"))
@ -77,13 +77,13 @@ public class MapToDriveInfo implements Function<Map<String, String>, DriveInfo>
protected DriveMetrics buildMetrics(Map<String, String> from) {
DriveMetrics.Builder metricsBuilder = new DriveMetrics.Builder();
if (from.containsKey("read:bytes"))
metricsBuilder.readBytes(Long.valueOf(from.get("read:bytes")));
metricsBuilder.readBytes(Long.parseLong(from.get("read:bytes")));
if (from.containsKey("read:requests"))
metricsBuilder.readRequests(Long.valueOf(from.get("read:requests")));
metricsBuilder.readRequests(Long.parseLong(from.get("read:requests")));
if (from.containsKey("write:bytes"))
metricsBuilder.writeBytes(Long.valueOf(from.get("write:bytes")));
metricsBuilder.writeBytes(Long.parseLong(from.get("write:bytes")));
if (from.containsKey("write:requests"))
metricsBuilder.writeRequests(Long.valueOf(from.get("write:requests")));
metricsBuilder.writeRequests(Long.parseLong(from.get("write:requests")));
return metricsBuilder.build();
}
}

View File

@ -68,13 +68,13 @@ public class MapToDriveMetrics implements Function<Map<String, String>, Map<Stri
protected DriveMetrics buildMetrics(String key, Map<String, String> from) {
DriveMetrics.Builder builder = new DriveMetrics.Builder();
if (from.containsKey(key + ":read:bytes"))
builder.readBytes(Long.valueOf(from.get(key + ":read:bytes")));
builder.readBytes(Long.parseLong(from.get(key + ":read:bytes")));
if (from.containsKey(key + ":read:requests"))
builder.readRequests(Long.valueOf(from.get(key + ":read:requests")));
builder.readRequests(Long.parseLong(from.get(key + ":read:requests")));
if (from.containsKey(key + ":write:bytes"))
builder.writeBytes(Long.valueOf(from.get(key + ":write:bytes")));
builder.writeBytes(Long.parseLong(from.get(key + ":write:bytes")));
if (from.containsKey(key + ":write:requests"))
builder.writeRequests(Long.valueOf(from.get(key + ":write:requests")));
builder.writeRequests(Long.parseLong(from.get(key + ":write:requests")));
return builder.build();
}
}

View File

@ -63,16 +63,16 @@ public class MapToServerInfo implements Function<Map<String, String>, ServerInfo
if (from.containsKey("smp:cores")) {
builder.smp(Integer.valueOf(from.get("smp:cores")));
builder.smp(Integer.parseInt(from.get("smp:cores")));
} else if (from.containsKey("smp") && !"auto".equals(from.get("smp"))) {
builder.smp(Integer.valueOf(from.get("smp")));
builder.smp(Integer.parseInt(from.get("smp")));
}
builder.cpu(Integer.parseInt(from.get("cpu")));
builder.mem(Integer.parseInt(from.get("mem")));
builder.user(from.get("user"));
if (from.containsKey("started"))
builder.started(new Date(Long.valueOf(from.get("started"))));
builder.started(new Date(Long.parseLong(from.get("started"))));
builder.uuid(from.get("server"));
if (from.containsKey("boot"))
builder.bootDeviceIds(Splitter.on(' ').split(from.get("boot")));

View File

@ -38,13 +38,13 @@ public class MapToServerMetrics implements Function<Map<String, String>, ServerM
public ServerMetrics apply(Map<String, String> from) {
ServerMetrics.Builder metricsBuilder = new ServerMetrics.Builder();
if (from.containsKey("tx:packets"))
metricsBuilder.txPackets(Long.valueOf(from.get("tx:packets")));
metricsBuilder.txPackets(Long.parseLong(from.get("tx:packets")));
if (from.containsKey("tx"))
metricsBuilder.tx(Long.valueOf(from.get("tx")));
metricsBuilder.tx(Long.parseLong(from.get("tx")));
if (from.containsKey("rx:packets"))
metricsBuilder.rxPackets(Long.valueOf(from.get("rx:packets")));
metricsBuilder.rxPackets(Long.parseLong(from.get("rx:packets")));
if (from.containsKey("rx"))
metricsBuilder.rx(Long.valueOf(from.get("rx")));
metricsBuilder.rx(Long.parseLong(from.get("rx")));
metricsBuilder.driveMetrics(mapToDriveMetrics.apply(from));
ServerMetrics metrics = metricsBuilder.build();

View File

@ -53,9 +53,9 @@ public class MapToStandardDrive implements Function<Map<String, String>, Standar
if (from.containsKey("readers"))
builder.readers(Splitter.on(' ').split(from.get("readers")));
if (from.containsKey("size"))
builder.size(Long.valueOf(from.get("size")));
builder.size(Long.parseLong(from.get("size")));
if (from.containsKey("rawsize"))
builder.rawSize(Long.valueOf(from.get("rawsize")));
builder.rawSize(Long.parseLong(from.get("rawsize")));
if (from.containsKey("format"))
builder.format(ImageConversionType.fromValue(from.get("format")));
Map<String, String> metadata = Maps.newLinkedHashMap();

View File

@ -44,7 +44,7 @@ public class SubdomainsToPagedIterable extends Arg0ToPagedIterable<Subdomain, Su
@Override
protected Function<Object, IterableWithMarker<Subdomain>> markerToNextForArg0(Optional<Object> domainId) {
return new ListSubdomainsUnderDomainIdAtMarker(api, Integer.valueOf(domainId.get().toString()));
return new ListSubdomainsUnderDomainIdAtMarker(api, Integer.parseInt(domainId.get().toString()));
}
private static class ListSubdomainsUnderDomainIdAtMarker implements Function<Object, IterableWithMarker<Subdomain>> {

View File

@ -77,7 +77,7 @@ public class ParseNodes extends ParseJson<Nodes> {
int lastSlash = path.lastIndexOf('/');
int secondLastSlash = path.lastIndexOf('/', lastSlash - 1);
lbId = Integer.valueOf(path.substring(secondLastSlash + 1, lastSlash));
lbId = Integer.parseInt(path.substring(secondLastSlash + 1, lastSlash));
return super.setContext(request);
}

View File

@ -43,8 +43,8 @@ public class ParseContainerMetadataFromHeaders implements Function<HttpResponse,
public ContainerMetadata apply(HttpResponse from) {
return ContainerMetadata.builder().name(request.getInvocation().getArgs().get(0).toString())
.readACL(from.getFirstHeaderOrNull(SwiftHeaders.CONTAINER_READ))
.bytes(Long.valueOf(from.getFirstHeaderOrNull(SwiftHeaders.CONTAINER_BYTES_USED)))
.count(Long.valueOf(from.getFirstHeaderOrNull(SwiftHeaders.CONTAINER_OBJECT_COUNT)))
.bytes(Long.parseLong(from.getFirstHeaderOrNull(SwiftHeaders.CONTAINER_BYTES_USED)))
.count(Long.parseLong(from.getFirstHeaderOrNull(SwiftHeaders.CONTAINER_OBJECT_COUNT)))
.metadata(extractUserMetadata(from)).build();
}

View File

@ -55,7 +55,7 @@ public class ListContainerOptions extends BaseHttpRequestOptions {
public int getMaxResults() {
String val = getFirstQueryOrNull("limit");
return val != null ? Integer.valueOf(val) : 10000;
return val != null ? Integer.parseInt(val) : 10000;
}
/**

View File

@ -160,7 +160,7 @@ public class Sha512Crypt {
if (shadowPrefix.startsWith(sha512_rounds_prefix)) {
String num = shadowPrefix.substring(sha512_rounds_prefix.length(), shadowPrefix.indexOf('$'));
int srounds = Integer.valueOf(num).intValue();
int srounds = Integer.parseInt(num);
shadowPrefix = shadowPrefix.substring(shadowPrefix.indexOf('$') + 1);
rounds = Math.max(ROUNDS_MIN, Math.min(srounds, ROUNDS_MAX));
}

View File

@ -102,9 +102,9 @@ public class JcloudsVersion {
version, SEMANTIC_VERSION_PATTERN);
this.version = version;
// a match will produce three or five matching groups (alpha/beta/release candidate identifier and version optional)
majorVersion = Integer.valueOf(versionMatcher.group(1));
minorVersion = Integer.valueOf(versionMatcher.group(2));
patchVersion = Integer.valueOf(versionMatcher.group(3));
majorVersion = Integer.parseInt(versionMatcher.group(1));
minorVersion = Integer.parseInt(versionMatcher.group(2));
patchVersion = Integer.parseInt(versionMatcher.group(3));
String alphaOrBetaOrReleaseCandidateVersionIfPresent = versionMatcher.group(4);
if (alphaOrBetaOrReleaseCandidateVersionIfPresent != null) {

View File

@ -150,31 +150,31 @@ public class GoGridComputeServiceAdapter implements ComputeServiceAdapter<Server
@Override
public Server getNode(String id) {
return Iterables.getOnlyElement(client.getServerServices().getServersById(Long.valueOf(checkNotNull(id, "id"))),
return Iterables.getOnlyElement(client.getServerServices().getServersById(Long.parseLong(checkNotNull(id, "id"))),
null);
}
@Override
public ServerImage getImage(String id) {
return Iterables.getOnlyElement(client.getImageServices().getImagesById(Long.valueOf(checkNotNull(id, "id"))),
return Iterables.getOnlyElement(client.getImageServices().getImagesById(Long.parseLong(checkNotNull(id, "id"))),
null);
}
@Override
public void destroyNode(String id) {
client.getServerServices().deleteById(Long.valueOf(id));
client.getServerServices().deleteById(Long.parseLong(id));
}
@Override
public void rebootNode(String id) {
executeCommandOnServer(PowerCommand.RESTART, id);
Server server = Iterables.getOnlyElement(client.getServerServices().getServersById(Long.valueOf(id)));
Server server = Iterables.getOnlyElement(client.getServerServices().getServersById(Long.parseLong(id)));
client.getServerServices().power(server.getName(), PowerCommand.START);
serverLatestJobCompletedShort.apply(server);
}
private boolean executeCommandOnServer(PowerCommand command, String id) {
Server server = Iterables.getOnlyElement(client.getServerServices().getServersById(Long.valueOf(id)));
Server server = Iterables.getOnlyElement(client.getServerServices().getServersById(Long.parseLong(id)));
client.getServerServices().power(server.getName(), command);
return serverLatestJobCompleted.apply(server);
}