fix generic wildcard

Signed-off-by: Michael Hirsch <michael.hirsch@bosch-si.com>
This commit is contained in:
Michael Hirsch
2016-05-31 11:01:04 +02:00
parent 32e5d36f10
commit 252f409912
2 changed files with 14 additions and 27 deletions

View File

@@ -30,60 +30,45 @@ public enum TenantConfigurationKey {
/** /**
* boolean value {@code true} {@code false}. * boolean value {@code true} {@code false}.
*/ */
AUTHENTICATION_MODE_HEADER_ENABLED("authentication.header.enabled", AUTHENTICATION_MODE_HEADER_ENABLED("authentication.header.enabled", "hawkbit.server.ddi.security.authentication.header.enabled", Boolean.class, Boolean.FALSE.toString(), TenantConfigurationBooleanValidator.class),
"hawkbit.server.ddi.security.authentication.header.enabled", Boolean.class, Boolean.FALSE.toString(),
TenantConfigurationBooleanValidator.class),
/** /**
* *
*/ */
AUTHENTICATION_MODE_HEADER_AUTHORITY_NAME("authentication.header.authority", AUTHENTICATION_MODE_HEADER_AUTHORITY_NAME("authentication.header.authority", "hawkbit.server.ddi.security.authentication.header.authority", String.class, Boolean.FALSE.toString(), TenantConfigurationStringValidator.class),
"hawkbit.server.ddi.security.authentication.header.authority", String.class, Boolean.FALSE.toString(),
TenantConfigurationStringValidator.class),
/** /**
* boolean value {@code true} {@code false}. * boolean value {@code true} {@code false}.
*/ */
AUTHENTICATION_MODE_TARGET_SECURITY_TOKEN_ENABLED("authentication.targettoken.enabled", AUTHENTICATION_MODE_TARGET_SECURITY_TOKEN_ENABLED("authentication.targettoken.enabled", "hawkbit.server.ddi.security.authentication.targettoken.enabled", Boolean.class, Boolean.FALSE.toString(), TenantConfigurationBooleanValidator.class),
"hawkbit.server.ddi.security.authentication.targettoken.enabled", Boolean.class, Boolean.FALSE.toString(),
TenantConfigurationBooleanValidator.class),
/** /**
* boolean value {@code true} {@code false}. * boolean value {@code true} {@code false}.
*/ */
AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_ENABLED("authentication.gatewaytoken.enabled", AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_ENABLED("authentication.gatewaytoken.enabled", "hawkbit.server.ddi.security.authentication.gatewaytoken.enabled", Boolean.class, Boolean.FALSE.toString(), TenantConfigurationBooleanValidator.class),
"hawkbit.server.ddi.security.authentication.gatewaytoken.enabled", Boolean.class, Boolean.FALSE.toString(),
TenantConfigurationBooleanValidator.class),
/** /**
* string value which holds the name of the security token key. * string value which holds the name of the security token key.
*/ */
AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_NAME("authentication.gatewaytoken.name", AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_NAME("authentication.gatewaytoken.name", "hawkbit.server.ddi.security.authentication.gatewaytoken.name", String.class, null, TenantConfigurationStringValidator.class),
"hawkbit.server.ddi.security.authentication.gatewaytoken.name", String.class, null,
TenantConfigurationStringValidator.class),
/** /**
* string value which holds the actual security-key of the gateway security * string value which holds the actual security-key of the gateway security
* token. * token.
*/ */
AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_KEY("authentication.gatewaytoken.key", AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_KEY("authentication.gatewaytoken.key", "hawkbit.server.ddi.security.authentication.gatewaytoken.key", String.class, null, TenantConfigurationStringValidator.class),
"hawkbit.server.ddi.security.authentication.gatewaytoken.key", String.class, null,
TenantConfigurationStringValidator.class),
/** /**
* string value which holds the polling time interval in the format HH:mm:ss * string value which holds the polling time interval in the format HH:mm:ss
*/ */
POLLING_TIME_INTERVAL("pollingTime", "hawkbit.controller.pollingTime", String.class, null, POLLING_TIME_INTERVAL("pollingTime", "hawkbit.controller.pollingTime", String.class, null, TenantConfigurationPollingDurationValidator.class),
TenantConfigurationPollingDurationValidator.class),
/** /**
* string value which holds the polling time interval in the format HH:mm:ss * string value which holds the polling time interval in the format HH:mm:ss
*/ */
POLLING_OVERDUE_TIME_INTERVAL("pollingOverdueTime", "hawkbit.controller.pollingOverdueTime", String.class, null, POLLING_OVERDUE_TIME_INTERVAL("pollingOverdueTime", "hawkbit.controller.pollingOverdueTime", String.class, null, TenantConfigurationPollingDurationValidator.class),
TenantConfigurationPollingDurationValidator.class),
/** /**
* boolean value {@code true} {@code false}. * boolean value {@code true} {@code false}.
*/ */
ANONYMOUS_DOWNLOAD_MODE_ENABLED("anonymous.download.enabled", "hawkbit.server.download.anonymous.enabled", ANONYMOUS_DOWNLOAD_MODE_ENABLED("anonymous.download.enabled", "hawkbit.server.download.anonymous.enabled", Boolean.class, Boolean.FALSE.toString(), TenantConfigurationBooleanValidator.class);
Boolean.class, Boolean.FALSE.toString(), TenantConfigurationBooleanValidator.class);
private final String keyName; private final String keyName;
private final String defaultKeyName; private final String defaultKeyName;
@@ -140,8 +125,9 @@ public enum TenantConfigurationKey {
* @return the data type of the tenant configuration value. (e.g. * @return the data type of the tenant configuration value. (e.g.
* Integer.class, String.class) * Integer.class, String.class)
*/ */
public Class<?> getDataType() { @SuppressWarnings("unchecked")
return dataType; public <T> Class<T> getDataType() {
return (Class<T>) dataType;
} }
/** /**

View File

@@ -97,7 +97,7 @@ public class JpaTenantConfigurationManagement implements EnvironmentAware, Tenan
} }
@Override @Override
public TenantConfigurationValue<?> getConfigurationValue(final TenantConfigurationKey configurationKey) { public <T> TenantConfigurationValue<T> getConfigurationValue(final TenantConfigurationKey configurationKey) {
return getConfigurationValue(configurationKey, configurationKey.getDataType()); return getConfigurationValue(configurationKey, configurationKey.getDataType());
} }
@@ -147,6 +147,7 @@ public class JpaTenantConfigurationManagement implements EnvironmentAware, Tenan
final JpaTenantConfiguration updatedTenantConfiguration = tenantConfigurationRepository final JpaTenantConfiguration updatedTenantConfiguration = tenantConfigurationRepository
.save(tenantConfiguration); .save(tenantConfiguration);
@SuppressWarnings("unchecked")
final Class<T> clazzT = (Class<T>) value.getClass(); final Class<T> clazzT = (Class<T>) value.getClass();
return TenantConfigurationValue.<T> builder().global(false).createdBy(updatedTenantConfiguration.getCreatedBy()) return TenantConfigurationValue.<T> builder().global(false).createdBy(updatedTenantConfiguration.getCreatedBy())