org.glassfish.jersey.internal.util
Class PropertiesHelper

java.lang.Object
  extended by org.glassfish.jersey.internal.util.PropertiesHelper

public class PropertiesHelper
extends Object

Helper class containing convenience methods for reading org.glassfish.jersey.server.ResourceConfig and Configuration properties.

Author:
Martin Matula (martin.matula at oracle.com)

Constructor Summary
PropertiesHelper()
           
 
Method Summary
static
<T> T
getValue(Map<String,?> properties, RuntimeType runtimeType, String key, Class<T> type)
          Returns value of a specified property.
static
<T> T
getValue(Map<String,?> properties, RuntimeType runtimeType, String key, T defaultValue)
          Return value of a specified property.
static
<T> T
getValue(Map<String,?> properties, RuntimeType runtimeType, String key, T defaultValue, Class<T> type)
          Returns value of a specified property.
static
<T> T
getValue(Map<String,?> properties, String key, Class<T> type)
          Returns value of a specified property.
static
<T> T
getValue(Map<String,?> properties, String key, T defaultValue)
          Return value of a specified property.
static
<T> T
getValue(Map<String,?> properties, String key, T defaultValue, Class<T> type)
          Returns value of a specified property.
static boolean isProperty(Map<String,Object> properties, String name)
          Get the value of the property with a given name converted to boolean.
static boolean isProperty(Object value)
          Get the value of the property converted to boolean.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PropertiesHelper

public PropertiesHelper()
Method Detail

getValue

public static <T> T getValue(Map<String,?> properties,
                             String key,
                             T defaultValue)
Return value of a specified property. If the property is not set or the real value type is not compatible with defaultValue type, the specified defaultValue is returned. Calling this method is equivalent to calling PropertyHelper.getValue(properties, key, defaultValue, (Class<T>) defaultValue.getClass())

Type Parameters:
T - Type of the property value.
Parameters:
properties - Map of properties to get the property value from.
key - Name of the property.
defaultValue - Default value to be returned if the specified property is not set or cannot be read.
Returns:
Value of the property or defaultValue.

getValue

public static <T> T getValue(Map<String,?> properties,
                             RuntimeType runtimeType,
                             String key,
                             T defaultValue)
Return value of a specified property. If the property is not set or the real value type is not compatible with defaultValue type, the specified defaultValue is returned. Calling this method is equivalent to calling PropertyHelper.getValue(properties, runtimeType, key, defaultValue, (Class<T>) defaultValue.getClass())

Type Parameters:
T - Type of the property value.
Parameters:
properties - Map of properties to get the property value from.
runtimeType - Runtime type which is used to check whether there is a property with the same key but post-fixed by runtime type (.server or .client) which would override the key property.
key - Name of the property.
defaultValue - Default value to be returned if the specified property is not set or cannot be read.
Returns:
Value of the property or defaultValue.

getValue

public static <T> T getValue(Map<String,?> properties,
                             String key,
                             T defaultValue,
                             Class<T> type)
Returns value of a specified property. If the property is not set or the real value type is not compatible with the specified value type, returns defaultValue.

Type Parameters:
T - Type of the property value.
Parameters:
properties - Map of properties to get the property value from.
key - Name of the property.
defaultValue - Default value of the property.
type - Type to retrieve the value as.
Returns:
Value of the property or null.

getValue

public static <T> T getValue(Map<String,?> properties,
                             RuntimeType runtimeType,
                             String key,
                             T defaultValue,
                             Class<T> type)
Returns value of a specified property. If the property is not set or the real value type is not compatible with the specified value type, returns defaultValue.

Type Parameters:
T - Type of the property value.
Parameters:
properties - Map of properties to get the property value from.
runtimeType - Runtime type which is used to check whether there is a property with the same key but post-fixed by runtime type (.server or .client) which would override the key property.
key - Name of the property.
defaultValue - Default value of the property.
type - Type to retrieve the value as.
Returns:
Value of the property or null.

getValue

public static <T> T getValue(Map<String,?> properties,
                             String key,
                             Class<T> type)
Returns value of a specified property. If the property is not set or the real value type is not compatible with the specified value type, returns null.

Type Parameters:
T - Type of the property value.
Parameters:
properties - Map of properties to get the property value from.
key - Name of the property.
type - Type to retrieve the value as.
Returns:
Value of the property or null.

getValue

public static <T> T getValue(Map<String,?> properties,
                             RuntimeType runtimeType,
                             String key,
                             Class<T> type)
Returns value of a specified property. If the property is not set or the real value type is not compatible with the specified value type, returns null.

Type Parameters:
T - Type of the property value.
Parameters:
properties - Map of properties to get the property value from.
runtimeType - Runtime type which is used to check whether there is a property with the same key but post-fixed by runtime type (.server or .client) which would override the key property.
key - Name of the property.
type - Type to retrieve the value as.
Returns:
Value of the property or null.

isProperty

public static boolean isProperty(Map<String,Object> properties,
                                 String name)
Get the value of the property with a given name converted to boolean. Returns false if the value is not convertible.

Parameters:
properties - key-value map of properties.
name - property name.
Returns:
boolean property value or false if the property is not convertible.

isProperty

public static boolean isProperty(Object value)
Get the value of the property converted to boolean. Returns false if the value is not convertible.

Parameters:
value - property value.
Returns:
boolean property value or false if the property is not convertible.


Copyright © 2007-2014, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.