use of org.ff4j.property.Property in project ff4j by ff4j.
the class InMemoryPropertyStoreTest method testInitStores.
@Test
public void testInitStores() {
new InMemoryPropertyStore(new HashMap<String, Property<?>>());
InputStream in = getClass().getClassLoader().getResourceAsStream("test-ff4j-features.xml");
new InMemoryPropertyStore(in);
}
use of org.ff4j.property.Property in project ff4j by ff4j.
the class InMemoryPropertyStoreTest method testInvalidXML.
@Test(expected = IllegalArgumentException.class)
public void testInvalidXML() {
new InMemoryPropertyStore(new HashMap<String, Property<?>>());
InputStream in = getClass().getClassLoader().getResourceAsStream("invalid.xml");
new InMemoryPropertyStore(in);
}
use of org.ff4j.property.Property in project ff4j by ff4j.
the class PropertyStoreCassandra method readAllProperties.
/**
* {@inheritDoc}
*/
@Override
public Map<String, Property<?>> readAllProperties() {
Map<String, Property<?>> properties = new HashMap<String, Property<?>>();
ResultSet resultSet = conn.getSession().execute(getBuilder().selectAllProperties());
for (Row row : resultSet.all()) {
Property<?> p = CassandraMapper.mapProperty(row);
properties.put(p.getName(), p);
}
return properties;
}
use of org.ff4j.property.Property in project ff4j by ff4j.
the class FF4jConfiguration method subset.
/**
* {@inheritDoc}
*/
@Override
public Configuration subset(String prefix) {
Map<String, Property<?>> myProps = ff4jStore().readAllProperties();
PropertyStore ps = new InMemoryPropertyStore();
for (Map.Entry<String, Property<?>> prop : myProps.entrySet()) {
if (prop.getKey().startsWith(prefix)) {
ps.createProperty(prop.getValue());
}
}
return new FF4jConfiguration(ps);
}
use of org.ff4j.property.Property in project ff4j by ff4j.
the class FF4jConfiguration method getProperties.
/**
* {@inheritDoc}
*/
@Override
public Properties getProperties(String key) {
Properties props = new Properties();
if (key == null)
return props;
Map<String, Property<?>> myProps = ff4jStore().readAllProperties();
for (Map.Entry<String, Property<?>> prop : myProps.entrySet()) {
if (prop.getKey().startsWith(key)) {
props.put(prop.getKey(), prop.getValue().getValue());
}
}
return props;
}
Aggregations