Skip to content

Commit

Permalink
adding utility class checkstyle, fixed violations and converted enum …
Browse files Browse the repository at this point in the history
…utils to final class utils
  • Loading branch information
zoewangg committed Nov 1, 2017
1 parent fc10d6a commit e7055e4
Show file tree
Hide file tree
Showing 96 changed files with 348 additions and 111 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -412,5 +412,8 @@

<!-- Checks for redundant public modifier on interfaces and other redundant modifiers -->
<module name="RedundantModifier" />

<!-- Checks for utility and constants classes to have private constructor-->
<module name="HideUtilityClassConstructor"/>
</module>
</module>
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,12 @@
* Constructs the metadata that is required for generating the java client from the service meta data.
*/
final class AddMetadata {

private static final String AWS_PACKAGE_PREFIX = "software.amazon.awssdk.services";

private AddMetadata() {
}


public static Metadata constructMetadata(ServiceModel serviceModel,
BasicCodeGenConfig codeGenConfig,
CustomizationConfig customizationConfig) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
*/
final class RemoveUnusedShapes {

private RemoveUnusedShapes() {
}

public static Map<String, ShapeModel> removeUnusedShapes(IntermediateModel model) {

Map<String, ShapeModel> out = new HashMap<String, ShapeModel>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@

public final class DefaultCustomizationProcessor {

private DefaultCustomizationProcessor() {
}

public static CodegenCustomizationProcessor getProcessorFor(
CustomizationConfig config) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,15 @@
* {@link #getDocs(IntermediateModel, OperationModel, ClientType, SimpleMethodOverload)} with the specified
* convenience overload as defined in {@link SimpleMethodOverload}.
*/
public class OperationDocs {
public final class OperationDocs {

private static final Map<ClientType, Map<SimpleMethodOverload, Factory>> FACTORIES =
ImmutableMapParameter.of(ClientType.SYNC, syncFactories(),
ClientType.ASYNC, asyncFactories());

private OperationDocs() {
}

/**
* Get documentation for the {@link SimpleMethodOverload#NORMAL} overload. That is, the actual implementation that
* simple methods delegate to.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
* @deprecated should be replaced with {@link software.amazon.awssdk.core.util.ClassLoaderHelper}
*/
@Deprecated
public enum ClassLoaderHelper {
;
public final class ClassLoaderHelper {

private ClassLoaderHelper() {
}

/**
* If classesFirst is false, retrieves the resource via the context class loader of the current
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

package software.amazon.awssdk.codegen.internal;

public class Constants {
public final class Constants {

public static final String CODEGEN_CONFIG_FILE = "codegen.config";

Expand Down Expand Up @@ -72,4 +72,6 @@ public class Constants {

public static final String APPROVED_SIMPLE_METHOD_VERBS = "(get|list|describe|lookup|batchGet).*";

private Constants() {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import software.amazon.awssdk.codegen.model.intermediate.Metadata;
import software.amazon.awssdk.codegen.model.intermediate.ShapeModel;

public class DocumentationUtils {
public final class DocumentationUtils {

public static final String DEFAULT_SETTER = "Sets the value of the %s property for this object.";

Expand All @@ -46,6 +46,9 @@ public class DocumentationUtils {
"iot", "data.iot", "machinelearning", "rekognition", "s3", "sdb", "swf"
));

private DocumentationUtils() {
}

/**
* Returns a documentation with HTML tags prefixed and suffixed removed, or
* returns empty string if the input is empty or null. This method is to be
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import java.io.InputStream;
import java.io.Writer;

public class Jackson {
public final class Jackson {

private static final ObjectMapper MAPPER = new ObjectMapper();

Expand All @@ -45,6 +45,9 @@ public class Jackson {
MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
}

private Jackson() {
}

public static <T> T load(Class<T> clazz, File file)
throws JsonParseException, JsonMappingException, IOException {
return load(clazz, new FileInputStream(file));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@
import software.amazon.awssdk.utils.IoUtils;
import software.amazon.awssdk.utils.StringUtils;

public class Utils {
public final class Utils {

private Utils() {
}

public static boolean isScalar(Shape shape) {
// enums are treated as scalars in C2j.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,13 @@
import software.amazon.awssdk.codegen.internal.Utils;
import software.amazon.awssdk.codegen.model.service.ServiceModel;

public class ModelLoaderUtils {
public final class ModelLoaderUtils {

public static final Logger log = LoggerFactory.getLogger(ModelLoaderUtils.class);

private ModelLoaderUtils() {
}

public static ServiceModel loadModel(String modelLocation) {
return loadConfigurationModel(ServiceModel.class, modelLocation);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
* Used for clock skew adjustment between the client JVM where the SDK is run,
* and the server side.
*/
public class SdkGlobalTime {
public final class SdkGlobalTime {

/**
* globalTimeOffset is a time difference in seconds between the running JVM
* and AWS. Used to globally adjust the client clock skew. Java SDK already
Expand All @@ -30,6 +31,9 @@ public class SdkGlobalTime {
*/
private static volatile int globalTimeOffset;

private SdkGlobalTime() {
}

/**
* Gets the global time difference in seconds between the running JVM and
* AWS. See <code>Request#getTimeOffset()</code> if global time offset is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ public final class Aws4SignerUtils {
private static final DateTimeFormatter TIME_FORMATTER = DateTimeFormatter
.ofPattern("yyyyMMdd'T'HHmmss'Z'").withZone(ZoneId.of("UTC"));

private Aws4SignerUtils() {
}

/**
* Returns a string representation of the given date time in yyyyMMdd
* format. The date returned is in the UTC zone.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,7 @@ public final class SignerConstants {
public static final String AUTHORIZATION = "Authorization";

public static final String HOST = "Host";

private SignerConstants() {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,13 @@
/**
* The class for creating and modifying the credential profiles file.
*/
public class ProfilesConfigFileWriter {
public final class ProfilesConfigFileWriter {

private static final Logger LOG = LoggerFactory.getLogger(ProfilesConfigFileWriter.class);

private ProfilesConfigFileWriter() {
}

/**
* Write all the credential profiles to a file. Note that this method will
* clobber the existing content in the destination file if it's in the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* Keys the Java SDK uses in the CLI credentials and config files.
*/
@SdkInternalApi
public class ProfileKeyConstants {
public final class ProfileKeyConstants {

/**
* Property name for specifying the Amazon AWS Access Key
Expand Down Expand Up @@ -62,4 +62,7 @@ public class ProfileKeyConstants {
* AWS Region to use when creating clients.
*/
public static final String REGION = "region";

private ProfileKeyConstants() {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ public interface DeliveryMode {
* synchronously.
*/
class Check {

private Check() {
}

public static boolean isSyncCallSafe(ProgressListener listener) {
if (listener instanceof DeliveryMode) {
DeliveryMode mode = (DeliveryMode) listener;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,16 @@
* ProgressListener; listener callbacks are executed sequentially in a separate
* single thread.
*/
public class SdkProgressPublisher {
public final class SdkProgressPublisher {

/**
* Used for testing purposes only.
*/
private static volatile Future<?> latestFutureTask;

private SdkProgressPublisher() {
}

/**
* Used to deliver a progress event to the given listener.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@
* Adapts a {@link Request} to the new {@link SdkHttpFullRequest} interface.
*/
@ReviewBeforeRelease("This should eventually be removed and SdkHttpFullRequest should completely replace Request")
public class SdkHttpFullRequestAdapter {
public final class SdkHttpFullRequestAdapter {

private SdkHttpFullRequestAdapter() {
}

public static SdkHttpFullRequest toHttpFullRequest(Request<?> request) {
return toMutableHttpFullRequest(request).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@
*
* TODO this should eventually be removed and SdkHttpFullResponse should completely replace HttpResponse
*/
public class SdkHttpResponseAdapter {
public final class SdkHttpResponseAdapter {

private SdkHttpResponseAdapter() {
}

public static HttpResponse adapt(boolean calculateCrc32FromCompressedData,
SdkHttpFullRequest request,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
+ "4. The remaining public AWS stuff should be moved to the AWS module. "
+ "We should also consider making some of the SDK/AWS-owned set of attributes part of the immutable context "
+ "if we don't want the interceptors to modify them.")
public class AwsExecutionAttributes {
public final class AwsExecutionAttributes {
/**
* The key under which the request credentials are set.
*/
Expand Down Expand Up @@ -64,4 +64,7 @@ public class AwsExecutionAttributes {
*/
public static final ExecutionAttribute<ServiceAdvancedConfiguration> SERVICE_ADVANCED_CONFIG =
new ExecutionAttribute<>("ServiceAdvancedConfig");

private AwsExecutionAttributes() {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@
* execution timeout features
*/
@SdkInternalApi
public class TimeoutThreadPoolBuilder {
public final class TimeoutThreadPoolBuilder {

private TimeoutThreadPoolBuilder() {
}

/**
* Creates a {@link ScheduledThreadPoolExecutor} with custom name for the threads.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,13 @@
* @deprecated Use {@link IoUtils}
*/
@Deprecated
public enum SdkIoUtils {
;
public final class SdkIoUtils {

private static final Logger DEFAULT_LOG = LoggerFactory.getLogger(SdkIoUtils.class);

private SdkIoUtils() {
}

public static void closeQuietly(Closeable is) {
closeQuietly(is, null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* Creates generators and protocol handlers for CBOR wire format.
*/
@SdkInternalApi
class SdkStructuredCborFactory {
final class SdkStructuredCborFactory {

private static final JsonFactory CBOR_FACTORY = new CBORFactory();

Expand Down Expand Up @@ -65,4 +65,6 @@ protected StructuredJsonGenerator createWriter(JsonFactory jsonFactory,
}
};

private SdkStructuredCborFactory() {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* Creates generators and protocol handlers for plain text JSON wire format.
*/
@SdkProtectedApi
public class SdkStructuredPlainJsonFactory {
public final class SdkStructuredPlainJsonFactory {

/**
* Recommended to share JsonFactory instances per http://wiki.fasterxml
Expand Down Expand Up @@ -66,4 +66,6 @@ protected StructuredJsonGenerator createWriter(JsonFactory jsonFactory,
}
};

private SdkStructuredPlainJsonFactory() {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import software.amazon.awssdk.annotations.SdkInternalApi;

@SdkInternalApi
public class HeaderMarshallers {
public final class HeaderMarshallers {

public static final JsonMarshaller<String> STRING = new SimpleHeaderMarshaller<>(ValueToStringConverters.FROM_STRING);

Expand All @@ -35,6 +35,9 @@ public class HeaderMarshallers {

public static final JsonMarshaller<Instant> INSTANT = new SimpleHeaderMarshaller<>(ValueToStringConverters.FROM_INSTANT);

private HeaderMarshallers() {
}

private static class SimpleHeaderMarshaller<T> implements JsonMarshaller<T> {

private final ValueToStringConverters.ValueToString<T> converter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import software.amazon.awssdk.core.protocol.MarshallLocation;

@SdkInternalApi
public class QueryParamMarshallers {
public final class QueryParamMarshallers {

public static final JsonMarshaller<String> STRING = new SimpleQueryParamMarshaller<>(
ValueToStringConverters.FROM_STRING);
Expand Down Expand Up @@ -55,6 +55,9 @@ public class QueryParamMarshallers {
}
};

private QueryParamMarshallers() {
}

private static class SimpleQueryParamMarshaller<T> implements JsonMarshaller<T> {

private final ValueToStringConverters.ValueToString<T> converter;
Expand Down
Loading

0 comments on commit e7055e4

Please sign in to comment.