use of org.ff4j.property.util.PropertyJsonBean in project ff4j by ff4j.
the class PropertyJsonParser method parsePropertyMap.
/**
* Map of property.
*
* @param fMap
* map of properties
* @return
* property
*/
@SuppressWarnings("unchecked")
public static Property<?> parsePropertyMap(Map<String, Object> fMap) {
PropertyJsonBean pf = new PropertyJsonBean();
pf.setName((String) fMap.get("name"));
pf.setDescription((String) fMap.get("description"));
pf.setType((String) fMap.get("type"));
pf.setValue((String) fMap.get("value"));
if (fMap.containsKey(FIXED_VALUES)) {
List<String> dbList = (ArrayList<String>) fMap.get(FIXED_VALUES);
if (dbList != null) {
for (Object item : dbList) {
pf.addFixedValue((String) item);
}
}
}
return pf.asProperty();
}
use of org.ff4j.property.util.PropertyJsonBean in project ff4j by ff4j.
the class MongoPropertyMapper method fromStore.
/**
* Map a property.
*
* @param dbObject
* db object
* @return
* list of property
*/
public Property<?> fromStore(DBObject dbObject) {
PropertyJsonBean pf = new PropertyJsonBean();
pf.setName((String) dbObject.get(PROPERTY_NAME));
pf.setDescription((String) dbObject.get(PROPERTY_DESCRIPTION));
pf.setType((String) dbObject.get(PROPERTY_TYPE));
pf.setValue((String) dbObject.get(PROPERTY_VALUE));
if (dbObject.containsField(PROPERTY_FIXEDVALUES)) {
BasicDBList dbList = (BasicDBList) dbObject.get(PROPERTY_FIXEDVALUES);
if (dbList != null) {
for (Object item : dbList) {
pf.addFixedValue((String) item);
}
}
}
return pf.asProperty();
}
use of org.ff4j.property.util.PropertyJsonBean in project ff4j by ff4j.
the class PropertyTest method testPropertyJsonBeanFromScratchBis.
@Test
public void testPropertyJsonBeanFromScratchBis() {
PropertyJsonBean jb = new PropertyJsonBean();
jb.setName("name");
jb.setType(PropertyString.class.getName());
jb.setFixedValues(null);
jb.addFixedValue("AMER");
jb.addFixedValue("XRZ");
jb.setValue("AMER");
Assert.assertNotNull(jb.toString());
}
use of org.ff4j.property.util.PropertyJsonBean in project ff4j by ff4j.
the class FeatureDBObjectMapper method mapProperty.
/**
* Map a property.
*
* @param dbObject
* db object
* @return
* list of property
*/
public Property<?> mapProperty(DBObject dbObject) {
PropertyJsonBean pf = new PropertyJsonBean();
pf.setName((String) dbObject.get(PROPERTY_NAME));
pf.setDescription((String) dbObject.get(PROPERTY_DESCRIPTION));
pf.setType((String) dbObject.get(PROPERTY_TYPE));
pf.setValue((String) dbObject.get(PROPERTY_VALUE));
if (dbObject.containsField(PROPERTY_FIXEDVALUES)) {
BasicDBList dbList = (BasicDBList) dbObject.get(PROPERTY_FIXEDVALUES);
if (dbList != null) {
for (Object item : dbList) {
pf.addFixedValue((String) item);
}
}
}
return pf.asProperty();
}
use of org.ff4j.property.util.PropertyJsonBean in project ff4j by ff4j.
the class FeatureJsonParserTest method assertMarshalling.
/**
* Check serialized string against json serializer.
*
* @param json
* json value
* @param feat
* feature
*/
private void assertMarshalling(Feature feat) throws Exception {
Map<String, Property<?>> props = feat.getCustomProperties();
if (props != null && !props.isEmpty()) {
// Custom properties are unforce to PropertyJsonBean
for (String pName : props.keySet()) {
PropertyJsonBean pjb = new PropertyJsonBean(props.get(pName));
Assert.assertEquals(marshallWithJackson(pjb), pjb.asJson());
}
feat.setCustomProperties(new HashMap<String, Property<?>>());
}
Assert.assertEquals(marshallWithJackson(feat), feat.toJson());
feat.setCustomProperties(props);
}
Aggregations