From 480f0e883d8a11ef031c167b1d4b1dc3052103ab Mon Sep 17 00:00:00 2001 From: Andrew Gaul Date: Tue, 26 Aug 2014 11:49:46 -0700 Subject: [PATCH] Prevent instantiation of utility classes Also prevent extension. --- .../org/jclouds/atmos/reference/AtmosHeaders.java | 7 +++++-- .../cloudstack/config/CloudStackProperties.java | 6 +++++- .../org/jclouds/cloudwatch/domain/Namespaces.java | 5 ++++- .../src/main/java/org/jclouds/ec2/domain/Tag.java | 6 +++++- .../keystone/v2_0/config/KeystoneProperties.java | 6 +++++- .../v2_0/extensions/ExtensionNamespaces.java | 6 +++++- .../openstack/v2_0/reference/AuthHeaders.java | 5 ++++- .../nova/v2_0/extensions/ExtensionNamespaces.java | 6 +++++- .../org/jclouds/s3/domain/AccessControlList.java | 12 ++++++++++-- .../java/org/jclouds/s3/reference/S3Headers.java | 6 +++++- .../java/org/jclouds/sqs/config/SQSProperties.java | 5 ++++- .../main/java/org/jclouds/sqs/domain/Attribute.java | 6 +++++- .../org/jclouds/sqs/reference/SQSParameters.java | 6 +++++- .../org/jclouds/aws/reference/FormParameters.java | 6 +++++- .../java/org/jclouds/vcloud/VCloudMediaType.java | 5 ++++- .../azure/storage/reference/AzureStorageHeaders.java | 5 ++++- .../org/jclouds/openstack/reference/AuthHeaders.java | 5 ++++- .../compute/config/ComputeServiceProperties.java | 5 ++++- .../org/jclouds/gogrid/reference/GoGridHeaders.java | 6 +++++- .../jclouds/gogrid/reference/GoGridQueryParams.java | 6 +++++- .../softlayer/reference/SoftLayerConstants.java | 5 ++++- 21 files changed, 102 insertions(+), 23 deletions(-) diff --git a/apis/atmos/src/main/java/org/jclouds/atmos/reference/AtmosHeaders.java b/apis/atmos/src/main/java/org/jclouds/atmos/reference/AtmosHeaders.java index de5c796547..acf48bb287 100644 --- a/apis/atmos/src/main/java/org/jclouds/atmos/reference/AtmosHeaders.java +++ b/apis/atmos/src/main/java/org/jclouds/atmos/reference/AtmosHeaders.java @@ -21,7 +21,7 @@ package org.jclouds.atmos.reference; * * @see */ -public interface AtmosHeaders { +public final class AtmosHeaders { public static final String SIGNATURE = "x-emc-signature"; public static final String LISTABLE_META = "x-emc-listable-meta"; @@ -34,5 +34,8 @@ public interface AtmosHeaders { public static final String UID = "x-emc-uid"; public static final String TOKEN = "x-emc-token"; public static final String CHECKSUM = "x-emc-wschecksum"; - + + private AtmosHeaders() { + throw new AssertionError("intentionally unimplemented"); + } } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/config/CloudStackProperties.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/config/CloudStackProperties.java index 42a70e8d25..e123847e0a 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/config/CloudStackProperties.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/config/CloudStackProperties.java @@ -20,7 +20,7 @@ package org.jclouds.cloudstack.config; /** * Configuration properties and constants used in CloudStack connections. */ -public interface CloudStackProperties { +public final class CloudStackProperties { /** * Type of credentials specified during {@link ComputeServiceContextBuilder#overrides}. If @@ -45,4 +45,8 @@ public interface CloudStackProperties { * delete the keypair(s) when the last node in the group is destroyed. */ public static final String AUTO_GENERATE_KEYPAIRS = "jclouds.cloudstack.auto-generate-keypairs"; + + private CloudStackProperties() { + throw new AssertionError("intentionally unimplemented"); + } } diff --git a/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/domain/Namespaces.java b/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/domain/Namespaces.java index 6362a4bd94..c034776469 100644 --- a/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/domain/Namespaces.java +++ b/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/domain/Namespaces.java @@ -21,7 +21,7 @@ package org.jclouds.cloudwatch.domain; * * @see */ -public interface Namespaces { +public final class Namespaces { public static final String AUTO_SCALING = "AWS/AutoScaling"; public static final String DYNAMODB = "AWS/DynamoDB"; @@ -34,4 +34,7 @@ public interface Namespaces { public static final String SQS = "AWS/SQS"; public static final String STORAGE_GATEWAY = "AWS/StorageGateway"; + private Namespaces() { + throw new AssertionError("intentionally unimplemented"); + } } diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/domain/Tag.java b/apis/ec2/src/main/java/org/jclouds/ec2/domain/Tag.java index 4c1c1dff75..88e5069089 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/domain/Tag.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/domain/Tag.java @@ -37,7 +37,7 @@ public class Tag { /** * Describes the well-known resource types that can be tagged. */ - public interface ResourceType { + public static final class ResourceType { public static final String CUSTOMER_GATEWAY = "customer-gateway"; public static final String DHCP_OPTIONS = "dhcp-options"; public static final String IMAGE = "image"; @@ -54,6 +54,10 @@ public class Tag { public static final String VPC = "vpc"; public static final String VPN_CONNECTION = "vpn-connection"; public static final String VPN_GATEWAY = "vpn-gateway"; + + private ResourceType() { + throw new AssertionError("intentionally unimplemented"); + } } public static Builder builder() { diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneProperties.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneProperties.java index ece82c97b0..dcb83cff7b 100644 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneProperties.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneProperties.java @@ -19,7 +19,7 @@ package org.jclouds.openstack.keystone.v2_0.config; /** * Configuration properties and constants used in Keystone connections. */ -public interface KeystoneProperties { +public final class KeystoneProperties { /** * Type of credentials used to log into the auth service. @@ -68,4 +68,8 @@ public interface KeystoneProperties { * @see ServiceType */ public static final String SERVICE_TYPE = "jclouds.keystone.service-type"; + + private KeystoneProperties() { + throw new AssertionError("intentionally unimplemented"); + } } diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/extensions/ExtensionNamespaces.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/extensions/ExtensionNamespaces.java index bc241100cc..dbcad2daf0 100644 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/extensions/ExtensionNamespaces.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/extensions/ExtensionNamespaces.java @@ -21,9 +21,13 @@ package org.jclouds.openstack.keystone.v2_0.extensions; * * @see */ -public interface ExtensionNamespaces { +public final class ExtensionNamespaces { /** * OpenStack Keystone Admin Support */ public static final String OS_KSADM = "http://docs.openstack.org/identity/api/ext/OS-KSADM/v1.0"; + + private ExtensionNamespaces() { + throw new AssertionError("intentionally unimplemented"); + } } diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/v2_0/reference/AuthHeaders.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/v2_0/reference/AuthHeaders.java index 40133f547a..88ea817383 100644 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/v2_0/reference/AuthHeaders.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/v2_0/reference/AuthHeaders.java @@ -16,10 +16,13 @@ */ package org.jclouds.openstack.v2_0.reference; -public interface AuthHeaders { +public final class AuthHeaders { public static final String AUTH_USER = "X-Auth-User"; public static final String AUTH_KEY = "X-Auth-Key"; public static final String AUTH_TOKEN = "X-Auth-Token"; + private AuthHeaders() { + throw new AssertionError("intentionally unimplemented"); + } } diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ExtensionNamespaces.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ExtensionNamespaces.java index 503f32e186..1a98e7cf91 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ExtensionNamespaces.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ExtensionNamespaces.java @@ -21,7 +21,7 @@ package org.jclouds.openstack.nova.v2_0.extensions; * * @see */ -public interface ExtensionNamespaces { +public final class ExtensionNamespaces { /** * Keypair Support */ @@ -110,4 +110,8 @@ public interface ExtensionNamespaces { * Consoles extension */ public static final String CONSOLES = "http://docs.openstack.org/compute/ext/os-consoles/api/v2"; + + private ExtensionNamespaces() { + throw new AssertionError("intentionally unimplemented"); + } } diff --git a/apis/s3/src/main/java/org/jclouds/s3/domain/AccessControlList.java b/apis/s3/src/main/java/org/jclouds/s3/domain/AccessControlList.java index d666741f0a..0faaa38a82 100644 --- a/apis/s3/src/main/java/org/jclouds/s3/domain/AccessControlList.java +++ b/apis/s3/src/main/java/org/jclouds/s3/domain/AccessControlList.java @@ -247,12 +247,16 @@ public class AccessControlList { // Class and Enum declarations to represent Grants, Grantees and Permissions // // ///////////////////////////////////////////////////////////////////////////// - public interface Permission { + public static final class Permission { public static final String READ = "READ"; public static final String WRITE = "WRITE"; public static final String READ_ACP = "READ_ACP"; public static final String WRITE_ACP = "WRITE_ACP"; public static final String FULL_CONTROL = "FULL_CONTROL"; + + private Permission() { + throw new AssertionError("intentionally unimplemented"); + } }; public static class Grant implements Comparable { @@ -417,11 +421,15 @@ public class AccessControlList { } } - public interface GroupGranteeURI { + public static final class GroupGranteeURI { public static final URI ALL_USERS = URI.create("http://acs.amazonaws.com/groups/global/AllUsers"); public static final URI AUTHENTICATED_USERS = URI .create("http://acs.amazonaws.com/groups/global/AuthenticatedUsers"); public static final URI LOG_DELIVERY = URI.create("http://acs.amazonaws.com/groups/s3/LogDelivery"); + + private GroupGranteeURI() { + throw new AssertionError("intentionally unimplemented"); + } } public static class GroupGrantee extends Grantee { diff --git a/apis/s3/src/main/java/org/jclouds/s3/reference/S3Headers.java b/apis/s3/src/main/java/org/jclouds/s3/reference/S3Headers.java index 79cd561e33..acc7ddcc9f 100644 --- a/apis/s3/src/main/java/org/jclouds/s3/reference/S3Headers.java +++ b/apis/s3/src/main/java/org/jclouds/s3/reference/S3Headers.java @@ -23,7 +23,7 @@ package org.jclouds.s3.reference; * href="http://docs.amazonwebservices.com/AmazonS3/latest/index.html?RESTAuthentication.html" * /> */ -public interface S3Headers { +public final class S3Headers { /** * Amazon S3 has clones, which often replace this with their particular tag. @@ -126,4 +126,8 @@ public interface S3Headers { * Instruction file header to be placed in the metadata of instruction files */ public static final String CRYPTO_INSTRUCTION_FILE = HEADER_PREFIX + "crypto-instr-file"; + + private S3Headers() { + throw new AssertionError("intentionally unimplemented"); + } } diff --git a/apis/sqs/src/main/java/org/jclouds/sqs/config/SQSProperties.java b/apis/sqs/src/main/java/org/jclouds/sqs/config/SQSProperties.java index a25cf819a7..692225af91 100644 --- a/apis/sqs/src/main/java/org/jclouds/sqs/config/SQSProperties.java +++ b/apis/sqs/src/main/java/org/jclouds/sqs/config/SQSProperties.java @@ -20,7 +20,7 @@ package org.jclouds.sqs.config; /** * Configuration properties and constants used in SQS connections. */ -public interface SQSProperties { +public final class SQSProperties { /** * Integer property. @@ -41,4 +41,7 @@ public interface SQSProperties { */ public static final String CREATE_QUEUE_RETRY_INTERVAL = "jclouds.sqs.create-queue.retry-interval"; + private SQSProperties() { + throw new AssertionError("intentionally unimplemented"); + } } diff --git a/apis/sqs/src/main/java/org/jclouds/sqs/domain/Attribute.java b/apis/sqs/src/main/java/org/jclouds/sqs/domain/Attribute.java index 6eb9996960..30859d02fa 100644 --- a/apis/sqs/src/main/java/org/jclouds/sqs/domain/Attribute.java +++ b/apis/sqs/src/main/java/org/jclouds/sqs/domain/Attribute.java @@ -24,7 +24,7 @@ package org.jclouds.sqs.domain; * "http://docs.amazonwebservices.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/acp-overview.html#PermissionTypes" * /> */ -public interface Attribute { +public final class Attribute { /** * approximate number of visible messages in a queue. @@ -82,4 +82,8 @@ public interface Attribute { * delayed. */ public static final String DELAY_SECONDS = "DelaySeconds"; + + private Attribute() { + throw new AssertionError("intentionally unimplemented"); + } } diff --git a/apis/sqs/src/main/java/org/jclouds/sqs/reference/SQSParameters.java b/apis/sqs/src/main/java/org/jclouds/sqs/reference/SQSParameters.java index 0f161eef89..bd89252ecd 100644 --- a/apis/sqs/src/main/java/org/jclouds/sqs/reference/SQSParameters.java +++ b/apis/sqs/src/main/java/org/jclouds/sqs/reference/SQSParameters.java @@ -22,7 +22,7 @@ package org.jclouds.sqs.reference; * @see */ -public interface SQSParameters { +public final class SQSParameters { /** * The action to perform. For example: CreateQueue. @@ -67,4 +67,8 @@ public interface SQSParameters { * For more information, see Query Request Authentication in the Amazon SQS Developer Guide. */ public static final String SIGNATURE_VERSION = "SignatureVersion"; + + private SQSParameters() { + throw new AssertionError("intentionally unimplemented"); + } } diff --git a/apis/sts/src/main/java/org/jclouds/aws/reference/FormParameters.java b/apis/sts/src/main/java/org/jclouds/aws/reference/FormParameters.java index bff02d7d51..8689c6b443 100644 --- a/apis/sts/src/main/java/org/jclouds/aws/reference/FormParameters.java +++ b/apis/sts/src/main/java/org/jclouds/aws/reference/FormParameters.java @@ -21,7 +21,7 @@ package org.jclouds.aws.reference; * * @see */ -public interface FormParameters { +public final class FormParameters { /** * Indicates the action to perform. Example: RunInstances @@ -72,4 +72,8 @@ public interface FormParameters { * */ public static final String SIGNATURE_VERSION = "SignatureVersion"; + + private FormParameters() { + throw new AssertionError("intentionally unimplemented"); + } } diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudMediaType.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudMediaType.java index f698b3e1de..f8f5ed4f42 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudMediaType.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudMediaType.java @@ -23,7 +23,7 @@ import javax.ws.rs.core.MediaType; * * @see MediaType */ -public interface VCloudMediaType { +public final class VCloudMediaType { /** * "application/vnd.vmware.vcloud.error+xml" */ @@ -209,4 +209,7 @@ public interface VCloudMediaType { */ public static final MediaType RASDITEM_XML_TYPE = new MediaType("application", "vnd.vmware.vcloud.rasdItem+xml"); + private VCloudMediaType() { + throw new AssertionError("intentionally unimplemented"); + } } diff --git a/common/azure/src/main/java/org/jclouds/azure/storage/reference/AzureStorageHeaders.java b/common/azure/src/main/java/org/jclouds/azure/storage/reference/AzureStorageHeaders.java index a51fa5472e..0c60e51ba1 100644 --- a/common/azure/src/main/java/org/jclouds/azure/storage/reference/AzureStorageHeaders.java +++ b/common/azure/src/main/java/org/jclouds/azure/storage/reference/AzureStorageHeaders.java @@ -21,10 +21,13 @@ package org.jclouds.azure.storage.reference; * * @see */ -public interface AzureStorageHeaders { +public final class AzureStorageHeaders { public static final String USER_METADATA_PREFIX = "x-ms-meta-"; public static final String REQUEST_ID = "x-ms-request-id"; public static final String VERSION = "x-ms-version"; + private AzureStorageHeaders() { + throw new AssertionError("intentionally unimplemented"); + } } diff --git a/common/openstack/src/main/java/org/jclouds/openstack/reference/AuthHeaders.java b/common/openstack/src/main/java/org/jclouds/openstack/reference/AuthHeaders.java index 4958b993d9..57cc168655 100644 --- a/common/openstack/src/main/java/org/jclouds/openstack/reference/AuthHeaders.java +++ b/common/openstack/src/main/java/org/jclouds/openstack/reference/AuthHeaders.java @@ -21,7 +21,7 @@ package org.jclouds.openstack.reference; * * @see */ -public interface AuthHeaders { +public final class AuthHeaders { public static final String AUTH_USER = "X-Auth-User"; public static final String AUTH_KEY = "X-Auth-Key"; @@ -34,4 +34,7 @@ public interface AuthHeaders { public static final String SERVER_MANAGEMENT_URL = "X-Server-Management" + URL_SUFFIX; public static final String STORAGE_URL = "X-Storage" + URL_SUFFIX; + private AuthHeaders() { + throw new AssertionError("intentionally unimplemented"); + } } diff --git a/compute/src/main/java/org/jclouds/compute/config/ComputeServiceProperties.java b/compute/src/main/java/org/jclouds/compute/config/ComputeServiceProperties.java index 90662780bf..8611a1f7a7 100644 --- a/compute/src/main/java/org/jclouds/compute/config/ComputeServiceProperties.java +++ b/compute/src/main/java/org/jclouds/compute/config/ComputeServiceProperties.java @@ -16,7 +16,7 @@ */ package org.jclouds.compute.config; -public interface ComputeServiceProperties { +public final class ComputeServiceProperties { public static final String RESOURCENAME_PREFIX = "jclouds.compute.resourcename-prefix"; public static final String RESOURCENAME_DELIMITER = "jclouds.compute.resourcename-delimiter"; @@ -109,4 +109,7 @@ public interface ComputeServiceProperties { */ public static final String SOCKET_FINDER_ALLOWED_INTERFACES = "jclouds.compute.socket-finder-allowed-interfaces"; + private ComputeServiceProperties() { + throw new AssertionError("intentionally unimplemented"); + } } diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/reference/GoGridHeaders.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/reference/GoGridHeaders.java index f84b95b3e6..7d0201932d 100644 --- a/providers/gogrid/src/main/java/org/jclouds/gogrid/reference/GoGridHeaders.java +++ b/providers/gogrid/src/main/java/org/jclouds/gogrid/reference/GoGridHeaders.java @@ -16,6 +16,10 @@ */ package org.jclouds.gogrid.reference; -public interface GoGridHeaders { +public final class GoGridHeaders { public static final String VERSION = "v"; + + private GoGridHeaders() { + throw new AssertionError("intentionally unimplemented"); + } } diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/reference/GoGridQueryParams.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/reference/GoGridQueryParams.java index 8b297e7f3d..cb993cd7bd 100644 --- a/providers/gogrid/src/main/java/org/jclouds/gogrid/reference/GoGridQueryParams.java +++ b/providers/gogrid/src/main/java/org/jclouds/gogrid/reference/GoGridQueryParams.java @@ -16,7 +16,7 @@ */ package org.jclouds.gogrid.reference; -public interface GoGridQueryParams { +public final class GoGridQueryParams { public static final String ID_KEY = "id"; public static final String NAME_KEY = "name"; @@ -60,4 +60,8 @@ public interface GoGridQueryParams { public static final String IMAGE_DESCRIPTION_KEY = "description"; public static final String LOOKUP_LIST_KEY = "lookup"; + + private GoGridQueryParams() { + throw new AssertionError("intentionally unimplemented"); + } } diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/reference/SoftLayerConstants.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/reference/SoftLayerConstants.java index 0947659f42..71d924a15e 100644 --- a/providers/softlayer/src/main/java/org/jclouds/softlayer/reference/SoftLayerConstants.java +++ b/providers/softlayer/src/main/java/org/jclouds/softlayer/reference/SoftLayerConstants.java @@ -19,7 +19,7 @@ package org.jclouds.softlayer.reference; /** * Configuration properties and constants used in SoftLayer connections. */ -public interface SoftLayerConstants { +public final class SoftLayerConstants { public static final String SOFTLAYER_PROVIDER_NAME = "softlayer"; @@ -40,4 +40,7 @@ public interface SoftLayerConstants { */ public static final String PROPERTY_SOFTLAYER_INCLUDE_PUBLIC_IMAGES = "jclouds.softlayer.include_public_images"; + private SoftLayerConstants() { + throw new AssertionError("intentionally unimplemented"); + } }