ninja.utils
Class NinjaPropertiesImpl

java.lang.Object
  extended by ninja.utils.NinjaPropertiesImpl
All Implemented Interfaces:
NinjaProperties

public class NinjaPropertiesImpl
extends Object
implements NinjaProperties


Field Summary
 
Fields inherited from interface ninja.utils.NinjaProperties
CONF_FILE_LOCATION_BY_CONVENTION, NINJA_EXTERNAL_CONF
 
Constructor Summary
NinjaPropertiesImpl()
           
 
Method Summary
 void bindProperties(com.google.inject.Binder binder)
           
 String get(String key)
          Get a String property or null if it is not there...
 Properties getAllCurrentNinjaProperties()
           
 Boolean getBoolean(String key)
           
 Boolean getBooleanOrDie(String key)
          The "die" method forces this key to be set.
 Boolean getBooleanWithDefault(String key, Boolean defaultValue)
          Get a Boolean property or a default value when property cannot be found in any configuration file.
 Integer getInteger(String key)
          Get a property as Integer of null if not there / or property no integer
 Integer getIntegerOrDie(String key)
          The "die" method forces this key to be set.
 Integer getIntegerWithDefault(String key, Integer defaultValue)
          Get a Integer property or a default value when property cannot be found in any configuration file.
 String getOrDie(String key)
          The "die" method forces this key to be set.
 String[] getStringArray(String key)
          eg.
 String getWithDefault(String key, String defaultValue)
          Get a String property or a default value when property cannot be found in any configuration file.
 boolean isDev()
          Whether we are in dev mode
 boolean isProd()
          Whether we are in prod mode
 boolean isTest()
          Whether we are in test mode
 void setProperty(String key, String value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NinjaPropertiesImpl

@Inject
public NinjaPropertiesImpl()
Method Detail

get

public String get(String key)
Description copied from interface: NinjaProperties
Get a String property or null if it is not there...

Specified by:
get in interface NinjaProperties
Returns:
the property of null if not there

getOrDie

public String getOrDie(String key)
Description copied from interface: NinjaProperties
The "die" method forces this key to be set. Otherwise a runtime exception will be thrown.

Specified by:
getOrDie in interface NinjaProperties
Returns:
the String or a RuntimeException will be thrown.

getInteger

public Integer getInteger(String key)
Description copied from interface: NinjaProperties
Get a property as Integer of null if not there / or property no integer

Specified by:
getInteger in interface NinjaProperties
Returns:
the property or null if not there or property no integer

getIntegerOrDie

public Integer getIntegerOrDie(String key)
Description copied from interface: NinjaProperties
The "die" method forces this key to be set. Otherwise a runtime exception will be thrown.

Specified by:
getIntegerOrDie in interface NinjaProperties
Returns:
the Integer or a RuntimeException will be thrown.

getBooleanOrDie

public Boolean getBooleanOrDie(String key)
Description copied from interface: NinjaProperties
The "die" method forces this key to be set. Otherwise a runtime exception will be thrown.

Specified by:
getBooleanOrDie in interface NinjaProperties
Returns:
the boolean or a RuntimeException will be thrown.

getBoolean

public Boolean getBoolean(String key)
Specified by:
getBoolean in interface NinjaProperties
Returns:
the property or null if not there or property no boolean

setProperty

public void setProperty(String key,
                        String value)

bindProperties

public void bindProperties(com.google.inject.Binder binder)

isProd

public boolean isProd()
Description copied from interface: NinjaProperties
Whether we are in prod mode

Specified by:
isProd in interface NinjaProperties
Returns:
True if we are in prod mode

isDev

public boolean isDev()
Description copied from interface: NinjaProperties
Whether we are in dev mode

Specified by:
isDev in interface NinjaProperties
Returns:
True if we are in dev mode

isTest

public boolean isTest()
Description copied from interface: NinjaProperties
Whether we are in test mode

Specified by:
isTest in interface NinjaProperties
Returns:
True if we are in test mode

getAllCurrentNinjaProperties

public Properties getAllCurrentNinjaProperties()
Specified by:
getAllCurrentNinjaProperties in interface NinjaProperties
Returns:
All properties that are currently loaded from internal and external files

getStringArray

public String[] getStringArray(String key)
Description copied from interface: NinjaProperties
eg. key=myval1,myval2 Delimiter is a comma "," as outlined in the example above.

Specified by:
getStringArray in interface NinjaProperties
Returns:
an array containing the values of that key or null if not found.

getWithDefault

public String getWithDefault(String key,
                             String defaultValue)
Description copied from interface: NinjaProperties
Get a String property or a default value when property cannot be found in any configuration file.

Specified by:
getWithDefault in interface NinjaProperties
Parameters:
key - the key used in the configuration file.
defaultValue - Default value returned, when value cannot be found in configuration.
Returns:
the value of the key or the default value.

getIntegerWithDefault

public Integer getIntegerWithDefault(String key,
                                     Integer defaultValue)
Description copied from interface: NinjaProperties
Get a Integer property or a default value when property cannot be found in any configuration file.

Specified by:
getIntegerWithDefault in interface NinjaProperties
Parameters:
key - the key used in the configuration file.
defaultValue - Default value returned, when value cannot be found in configuration.
Returns:
the value of the key or the default value.

getBooleanWithDefault

public Boolean getBooleanWithDefault(String key,
                                     Boolean defaultValue)
Description copied from interface: NinjaProperties
Get a Boolean property or a default value when property cannot be found in any configuration file.

Specified by:
getBooleanWithDefault in interface NinjaProperties
Parameters:
key - the key used in the configuration file.
defaultValue - Default value returned, when value cannot be found in configuration.
Returns:
the value of the key or the default value.


Copyright © 2012. All Rights Reserved.