#1936: Configuration#contains(Ljava/lang/String;)Z

This commit is contained in:
md_5 2016-08-21 09:10:23 +10:00
parent 356ca08337
commit 6563a9241b
2 changed files with 11 additions and 0 deletions

View File

@ -91,6 +91,11 @@ public final class Configuration
return ( val != null ) ? (T) val : def;
}
public boolean contains(String path)
{
return get( path, null ) != null;
}
public Object get(String path)
{
return get( path, getDefault( path ) );

View File

@ -94,6 +94,12 @@ public class YamlConfigurationTest
conf.set( "other.new.section", "bar" );
Assert.assertEquals( "bar", conf.get( "other.new.section" ) );
Assert.assertTrue( conf.contains( "customer.given" ) );
Assert.assertTrue( customer.contains( "given" ) );
Assert.assertFalse( conf.contains( "customer.foo" ) );
Assert.assertFalse( customer.contains( "foo" ) );
}
@Test