From 1dd9350f543519a54c0848cf5099bc986e997133 Mon Sep 17 00:00:00 2001 From: Brandon Arp Date: Sun, 18 Dec 2016 00:57:33 -0800 Subject: [PATCH] checkstyle fixes --- .../com/arpnetworking/akka/ActorBuilder.java | 15 ++++++++++++ .../akka/NonJoiningClusterJoiner.java | 12 ++++++++-- .../akka/ActorBuilderDeserializer.java | 23 +++++++++++++++---- .../configuration/ActorBuilderTest.java | 21 ++++++++++++++--- 4 files changed, 62 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/arpnetworking/akka/ActorBuilder.java b/src/main/java/com/arpnetworking/akka/ActorBuilder.java index 3fa81b00..71b6ca76 100644 --- a/src/main/java/com/arpnetworking/akka/ActorBuilder.java +++ b/src/main/java/com/arpnetworking/akka/ActorBuilder.java @@ -1,3 +1,18 @@ +/** + * Copyright 2016 InscopeMetrics, Inc + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.arpnetworking.akka; import akka.actor.Props; diff --git a/src/main/java/com/arpnetworking/akka/NonJoiningClusterJoiner.java b/src/main/java/com/arpnetworking/akka/NonJoiningClusterJoiner.java index fdf9cd2c..65157470 100644 --- a/src/main/java/com/arpnetworking/akka/NonJoiningClusterJoiner.java +++ b/src/main/java/com/arpnetworking/akka/NonJoiningClusterJoiner.java @@ -1,5 +1,5 @@ /** - * Copyright 2016 Inscope Metrics + * Copyright 2016 Inscope Metrics, Inc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -60,9 +60,17 @@ public void onReceive(final Object message) throws Exception { unhandled(message); } - private static Logger LOGGER = LoggerFactory.getLogger(NonJoiningClusterJoiner.class); + private static final Logger LOGGER = LoggerFactory.getLogger(NonJoiningClusterJoiner.class); + /** + * Implementation of the {@link com.arpnetworking.commons.builder.Builder} pattern for a {@link NonJoiningClusterJoiner}. + * + * @author Brandon Arp (brandon dot arp at inscopemetrics dot com) + */ public static class Builder extends ActorBuilder { + /** + * Public constructor. + */ public Builder() { super(NonJoiningClusterJoiner::props); } diff --git a/src/main/java/com/arpnetworking/configuration/jackson/akka/ActorBuilderDeserializer.java b/src/main/java/com/arpnetworking/configuration/jackson/akka/ActorBuilderDeserializer.java index 3cfa7f25..3ea81a62 100644 --- a/src/main/java/com/arpnetworking/configuration/jackson/akka/ActorBuilderDeserializer.java +++ b/src/main/java/com/arpnetworking/configuration/jackson/akka/ActorBuilderDeserializer.java @@ -1,9 +1,23 @@ +/** + * Copyright 2016 InscopeMetrics, Inc + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.arpnetworking.configuration.jackson.akka; import akka.actor.Props; import com.arpnetworking.commons.builder.Builder; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.TreeNode; import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.JsonDeserializer; @@ -14,7 +28,8 @@ import java.io.IOException; /** - * Deserializer that will create an ActorBuilder for the given actor, then create the Actor from Guice + * Deserializer that will create an ActorBuilder for the given actor, then create a Props from Guice. + * * @author Brandon Arp (brandon dot arp at inscopemetrics dot com) */ public class ActorBuilderDeserializer extends JsonDeserializer { @@ -28,7 +43,7 @@ public ActorBuilderDeserializer(final ObjectMapper mapper) { } @Override - public Props deserialize(final JsonParser p, final DeserializationContext ctxt) throws IOException, JsonProcessingException { + public Props deserialize(final JsonParser p, final DeserializationContext ctxt) throws IOException { final TreeNode treeNode = p.readValueAsTree(); final String type = ((TextNode) treeNode.get("type")).textValue(); try { @@ -36,7 +51,7 @@ public Props deserialize(final JsonParser p, final DeserializationContext ctxt) final Class> builder = getBuilderForClass(clazz); final Builder value = _mapper.readValue(treeNode.toString(), builder); return value.build(); - } catch (ClassNotFoundException e) { + } catch (final ClassNotFoundException e) { throw new JsonMappingException(p, String.format("Unable to find class %s referenced by Props type", type)); } } diff --git a/src/test/java/com/arpnetworking/clusteraggregator/configuration/ActorBuilderTest.java b/src/test/java/com/arpnetworking/clusteraggregator/configuration/ActorBuilderTest.java index 91421ad4..10b0a32f 100644 --- a/src/test/java/com/arpnetworking/clusteraggregator/configuration/ActorBuilderTest.java +++ b/src/test/java/com/arpnetworking/clusteraggregator/configuration/ActorBuilderTest.java @@ -1,3 +1,18 @@ +/** + * Copyright 2016 InscopeMetrics, Inc + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.arpnetworking.clusteraggregator.configuration; import akka.actor.Props; @@ -29,9 +44,9 @@ public void testPolyDeserialize() throws IOException { module.addDeserializer(Props.class, new ActorBuilderDeserializer(mapper)); mapper.registerModule(module); - @Language("JSON") final String data = "{\n" + - " \"type\": \"com.arpnetworking.akka.NonJoiningClusterJoiner\"\n" + - "}"; + @Language("JSON") final String data = "{\n" + + " \"type\": \"com.arpnetworking.akka.NonJoiningClusterJoiner\"\n" + + "}"; final Props props = mapper.readValue(data, Props.class); } }