本文整理了Java中org.ff4j.core.Feature.getDescription()
方法的一些代码示例,展示了Feature.getDescription()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Feature.getDescription()
方法的具体详情如下:
包路径:org.ff4j.core.Feature
类名称:Feature
方法名:getDescription
[英]Getter accessor for attribute 'description'.
[中]
代码示例来源:origin: ff4j/ff4j
private String createUpdateCoreFeature(Feature fp) {
StringBuilder cypherUpdate = new StringBuilder("MATCH (f:" + FF4jNeo4jLabels.FF4J_FEATURE + " { uid:'");
cypherUpdate.append(fp.getUid());
cypherUpdate.append("' }) ");
cypherUpdate.append("SET f.enable = " + fp.isEnable());
if (fp.getDescription() != null && fp.getDescription().length() > 0) {
cypherUpdate.append(", f.description = '");
cypherUpdate.append(fp.getDescription());
cypherUpdate.append("'");
}
if (fp.getPermissions() != null && fp.getPermissions().size() > 0) {
cypherUpdate.append(", f.roles = [");
boolean first = true;
for(String role : fp.getPermissions()) {
if (!first) {
cypherUpdate.append(",");
}
cypherUpdate.append("'" + role + "'");
first = false;
}
cypherUpdate.append("]");
} else {
// AS role is null
cypherUpdate.append(", f.roles = []");
}
cypherUpdate.append(";");
return cypherUpdate.toString();
}
代码示例来源:origin: ff4j/ff4j
private String createQueryNewCoreFeature(Feature fp) {
StringBuilder cypherCreate = new StringBuilder("CREATE (");
cypherCreate.append("f:" + FF4jNeo4jLabels.FF4J_FEATURE + " { uid :'");
cypherCreate.append(fp.getUid());
cypherCreate.append("', enable:");
cypherCreate.append(fp.isEnable());
if (fp.getDescription() != null && fp.getDescription().length() > 0) {
cypherCreate.append(", description:'");
cypherCreate.append(fp.getDescription());
cypherCreate.append("'");
}
if (fp.getPermissions() != null && fp.getPermissions().size() > 0) {
cypherCreate.append(", roles: [");
boolean first = true;
for(String role : fp.getPermissions()) {
if (!first) {
cypherCreate.append(",");
}
cypherCreate.append("'" + role + "'");
first = false;
}
cypherCreate.append("]");
}
cypherCreate.append("});");
return cypherCreate.toString();
}
代码示例来源:origin: ff4j/ff4j
sb.append("\r\n");
for (Map.Entry<String, Feature> feat : ff4j.getFeatureStore().readAll().entrySet()) {
sb.append("\r\n /* Feature '" + feat.getKey() + "' : '" + feat.getValue().getDescription() + "' */");
sb.append("\r\n String FEATURE_" + feat.getKey().replaceAll(" ", "_").toUpperCase() + " = \"" + feat.getKey()
+ "\";");
代码示例来源:origin: ff4j/ff4j
sb.append(MessageFormat.format(XML_FEATURE, feat.getUid(), feat.getDescription(), feat.isEnable()));
代码示例来源:origin: ff4j/ff4j
if (null != currentFeature.getDescription()) {
sb.append(" tooltip=\"");
sb.append(currentFeature.getDescription());
sb.append("\"");
sb.append(" data-desc=\"" + currentFeature.getDescription() + "\"");
sb.append(" data-group=\"" + currentFeature.getGroup() + "\"");
sb.append(" data-strategy=\"");
代码示例来源:origin: ff4j/ff4j
/**
* TDD.
*/
@Test
public void testReadFullFeature() {
// Given
assertFf4j.assertThatFeatureExist(F4);
// When
Feature f = testedStore.read(F4);
// Then
Assert.assertEquals(f.getUid(), F4);
Assert.assertTrue(f.getDescription() != null && !"".equals(f.getDescription()));
Assert.assertTrue(f.getPermissions() != null && !f.getPermissions().isEmpty());
assertFf4j.assertThatFeatureHasRole(F4, ROLE_ADMIN);
assertFf4j.assertThatFeatureIsInGroup(F4, G1);
}
代码示例来源:origin: ff4j/ff4j
byte[] desc = (fp.getDescription() == null) ? null : Bytes.toBytes(fp.getDescription());
put.addColumn(B_FEATURES_CF_CORE, B_FEAT_DESCRIPTION, desc);
代码示例来源:origin: ff4j/ff4j
/**
* TDD.
*/
@Test
public void testReadAllFeatures() {
// Given
assertFf4j.assertThatFeatureExist(F4);
assertFf4j.assertThatStoreHasSize(EXPECTED_FEATURES_NUMBERS);
// When
Map<String, Feature> features = testedStore.readAll();
// Then
Assert.assertEquals(EXPECTED_FEATURES_NUMBERS, features.size());
// Then testing whole structure
Feature f = features.get(F4);
Assert.assertEquals(F4 + " does not exist", f.getUid(), F4);
Assert.assertTrue("no description", f.getDescription() != null && !"".equals(f.getDescription()));
Assert.assertTrue("no authorizations", f.getPermissions() != null && !f.getPermissions().isEmpty());
assertFf4j.assertThatFeatureHasRole(F4, ROLE_ADMIN);
assertFf4j.assertThatFeatureIsInGroup(F4, G1);
}
代码示例来源:origin: ff4j/ff4j
private void createCoreFeature(Feature fp) {
// Transaction wraps the method, could pipe several sql queries
String strategyColumn = null;
String expressionColumn = null;
if (fp.getFlippingStrategy() != null) {
strategyColumn = fp.getFlippingStrategy().getClass().getName();
expressionColumn = MappingUtil.fromMap(fp.getFlippingStrategy().getInitParams());
}
getJdbcTemplate().update(getQueryBuilder().createFeature(),
fp.getUid(), fp.isEnable() ? 1 : 0,
fp.getDescription(), strategyColumn,
expressionColumn, fp.getGroup());
}
代码示例来源:origin: ff4j/ff4j
/** {@inheritDoc} */
@Override
public void create(Feature fp) {
assertFeatureNotNull(fp);
assertFeatureNotExist(fp.getUid());
// Convert map<String, Property> to map<String, String>, structure in DB
Map < String, String > mapOfProperties = new HashMap<String, String>();
if (fp.getCustomProperties() != null && !fp.getCustomProperties().isEmpty()) {
for (Map.Entry<String, Property<?>> customP : fp.getCustomProperties().entrySet()) {
if (customP.getValue() != null) {
mapOfProperties.put(customP.getKey(), customP.getValue().toJson());
}
}
}
conn.getSession().execute(getBuilder().cqlCreateFeature(),
fp.getUid(),
fp.isEnable() ? 1 : 0,
fp.getDescription(),
JsonUtils.flippingStrategyAsJson(fp.getFlippingStrategy()),
fp.getGroup(), fp.getPermissions(), mapOfProperties);
}
代码示例来源:origin: ff4j/ff4j
public FeatureApiBean(Feature f) {
this.uid = f.getUid();
this.enable = f.isEnable();
this.description = f.getDescription();
this.group = f.getGroup();
this.permissions = new ArrayList<String>(f.getPermissions());
if (f.getFlippingStrategy() != null) {
this.flippingStrategy = new FlippingStrategyApiBean(f.getFlippingStrategy());
}
if (f.getCustomProperties() != null) {
for (Property<?> ap1 : f.getCustomProperties().values()) {
customProperties.put(ap1.getName(), new PropertyApiBean(ap1));
}
}
}
代码示例来源:origin: ff4j/ff4j
/**
* TDD.
*/
@Test
public void testUpdateFeatureCoreData() {
// Parameters
String newDescription = "new-description";
FlippingStrategy newStrategy = new PonderationStrategy(0.12);
// Given
assertFf4j.assertThatFeatureExist(F1);
Assert.assertFalse(newDescription.equals(testedStore.read(F1).getDescription()));
// When
Feature fpBis = testedStore.read(F1);
fpBis.setDescription(newDescription);
fpBis.setFlippingStrategy(newStrategy);
testedStore.update(fpBis);
// Then
Feature updatedFeature = testedStore.read(F1);
Assert.assertTrue(newDescription.equals(updatedFeature.getDescription()));
Assert.assertNotNull(updatedFeature.getFlippingStrategy());
Assert.assertEquals(newStrategy.toString(), updatedFeature.getFlippingStrategy().toString());
}
代码示例来源:origin: ff4j/ff4j
/**
* Copy constructor.
*
* @param f
*
* target feature
*/
public FeatureApiBean(Feature f) {
this.uid = f.getUid();
this.enable = f.isEnable();
this.description = f.getDescription();
this.group = f.getGroup();
this.permissions = new ArrayList<String>(f.getPermissions());
if (f.getFlippingStrategy() != null) {
this.flippingStrategy = new FlippingStrategyApiBean(f.getFlippingStrategy());
}
if (f.getCustomProperties() != null) {
for (Property<?> ap1 : f.getCustomProperties().values()) {
customProperties.put(ap1.getName(), new PropertyApiBean(ap1));
}
}
}
代码示例来源:origin: ff4j/ff4j
ps.setString(1, fp.getUid());
ps.setInt(2, fp.isEnable() ? 1 : 0);
ps.setString(3, fp.getDescription());
String strategyColumn = null;
String expressionColumn = null;
代码示例来源:origin: ff4j/ff4j
/**
* Copy constructor.
*
* @param f
* current feature
*/
public Feature(final Feature f) {
this(f.getUid(), f.isEnable(), f.getDescription(), f.getGroup());
this.permissions.addAll(f.getPermissions());
// Flipping Strategy
if (f.getFlippingStrategy() != null) {
this.flippingStrategy = MappingUtil.instanceFlippingStrategy(f.getUid(),
f.getFlippingStrategy().getClass().getName(),
f.getFlippingStrategy().getInitParams());
}
// Custom Properties
if (f.getCustomProperties() != null && !f.getCustomProperties().isEmpty()) {
for(Property<?> p : f.getCustomProperties().values()) {
Property<?> targetProp = PropertyFactory.createProperty(
p.getName(), p.getType(), p.asString(), p.getDescription(), null);
if (p.getFixedValues() != null) {
for(Object o : p.getFixedValues()) {
targetProp.add2FixedValueFromString(o.toString());
}
}
this.getCustomProperties().put(targetProp.getName(), targetProp);
}
}
}
代码示例来源:origin: ff4j/ff4j
enable, fp.getDescription(), fStrategy, fExpression, fp.getGroup(), fp.getUid());
代码示例来源:origin: ff4j/ff4j
@Override
public Document toStore(Feature feature) {
String strategyColumn = null;
String expressionColumn = null;
if (feature.getFlippingStrategy() != null) {
strategyColumn = feature.getFlippingStrategy().getClass().getName();
expressionColumn = MappingUtil.fromMap(feature.getFlippingStrategy().getInitParams());
}
String customProperties = null;
if (feature.getCustomProperties() != null) {
customProperties = JsonUtils.customPropertiesAsJson(feature.getCustomProperties());
}
return new FeatureDocumentBuilder().addFeatUid(feature.getUid()).//
addEnable(feature.isEnable()).//
addDescription(feature.getDescription()).//
addGroupName(feature.getGroup()).//
addStrategy(strategyColumn).//
addExpression(expressionColumn).//
addCustomProperties(customProperties). //
addRoles(feature.getPermissions()).build();
}
代码示例来源:origin: ff4j/ff4j
/**
* Convert {@link Feature} to {@link DBObject}.
*
* @param feature
* target feature.
* @return document in mongo db
*/
public DBObject toDBObject(Feature feature) {
String strategyColumn = null;
String expressionColumn = null;
if (feature.getFlippingStrategy() != null) {
strategyColumn = feature.getFlippingStrategy().getClass().getName();
expressionColumn = MappingUtil.fromMap(feature.getFlippingStrategy().getInitParams());
}
String customProperties = null;
if (feature.getCustomProperties() != null) {
customProperties = JsonUtils.customPropertiesAsJson(feature.getCustomProperties());
}
return new FeatureDBObjectBuilder().addFeatUid(feature.getUid()).//
addEnable(feature.isEnable()).//
addDescription(feature.getDescription()).//
addGroupName(feature.getGroup()).//
addStrategy(strategyColumn).//
addExpression(expressionColumn).//
addCustomProperties(customProperties).
addRoles(feature.getPermissions()).build();
}
内容来源于网络,如有侵权,请联系作者删除!