本文整理了Java中org.ff4j.utils.Util.set()
方法的一些代码示例,展示了Util.set()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.set()
方法的具体详情如下:
包路径:org.ff4j.utils.Util
类名称:Util
方法名:set
[英]Create an HashSet.
[中]创建一个哈希集。
代码示例来源:origin: ff4j/ff4j
/** {@inheritDoc} */
@Override
public void createSchema() {
conn.createTable(FEATURES_TABLENAME_ID, Util.set(FEATURES_CF_CORE, FEATURES_CF_PROPERTIES));
}
代码示例来源:origin: ff4j/ff4j
/** {@inheritDoc} */
@Override
public void createSchema() {
conn.createTable(AUDIT_TABLENAME_ID, Util.set(AUDIT_CF));
}
代码示例来源:origin: ff4j/ff4j
/** {@inheritDoc} */
@Override
public void createSchema() {
conn.createTable(PROPERTIES_TABLENAME_ID, Util.set(FEATURES_CF_PROPERTIES));
}
代码示例来源:origin: ff4j/ff4j
/** {@inheritDoc} */
private Map<String, MutableHitCount> computeHitCount(EventQueryDefinition query, String pColName) {
Map < String, MutableHitCount > hitCount = new HashMap<String, MutableHitCount>();
try (Connection hbConn = ConnectionFactory.createConnection(conn.getConfig())) {
try(Table table = hbConn.getTable(AUDIT_TABLENAME)) {
query.getActionFilters().add(ACTION_CHECK_OK);
Scan scanQuery = buildQuery(query, Util.set(pColName), EventConstants.TARGET_FEATURE);
try(ResultScanner scanner = table.getScanner(scanQuery)) {
for (Result rr = scanner.next(); rr != null; rr = scanner.next()) {
String colValue = Bytes.toString(rr.getValue(B_AUDIT_CF, Bytes.toBytes(pColName)));
if (hitCount.containsKey(colValue)) {
hitCount.get(colValue).inc();
} else {
hitCount.put(colValue, new MutableHitCount(1));
}
}
}
}
} catch (IOException e) {
throw new AuditAccessException("Compute hitcount based on " + pColName, e);
}
return hitCount;
}
代码示例来源:origin: ff4j/ff4j
/** {@inheritDoc} */
@Override
public EventSeries getAuditTrail(EventQueryDefinition query) {
String cqlQuery = getBuilder().cqlAuditTrail(query);
LOGGER.debug("Query " + cqlQuery);
ResultSet rs = conn.getSession().execute(cqlQuery);
EventSeries es = new EventSeries();
Set < String > candidates = Util.set(ACTION_DISCONNECT,
ACTION_TOGGLE_ON, ACTION_TOGGLE_OFF,
ACTION_CREATE, ACTION_DELETE,
ACTION_UPDATE, ACTION_CLEAR);
for (Row row : rs.all()) {
if (candidates.contains(row.getString(COL_EVENT_ACTION)))
es.add(CassandraMapper.mapEvent(row));
}
return es;
}
代码示例来源:origin: ff4j/ff4j
/** {@inheritDoc} */
@Override
public void purgeAuditTrail(EventQueryDefinition query) {
try (Connection hbConn = ConnectionFactory.createConnection(conn.getConfig())) {
try(Table table = hbConn.getTable(AUDIT_TABLENAME)) {
query.getActionFilters().add(ACTION_CHECK_OK);
// Scan for ids
Scan scanQuery = buildQuery(query, Util.set(COL_EVENT_UID), null);
List < Delete > list = new ArrayList<Delete>();
try(ResultScanner scanner = table.getScanner(scanQuery)) {
for (Result rr = scanner.next(); rr != null; rr = scanner.next()) {
list.add(new Delete(rr.getValue(B_AUDIT_CF, B_EVENT_UID)));
}
}
table.delete(list);
}
} catch (IOException e) {
throw new AuditAccessException("Cannot search audit trail ", e);
}
}
代码示例来源:origin: ff4j/ff4j
@Override
public EventSeries getAuditTrail(EventQueryDefinition query) {
JestResult result = getConnection().execute(getBuilder().queryGetEventQueryDefinition(query));
List<Event> events = result.getSourceAsObjectList(Event.class);
EventSeries es = new EventSeries();
Set<String> candidates = Util.set(ACTION_DISCONNECT, //
ACTION_TOGGLE_ON, ACTION_TOGGLE_OFF, ACTION_CREATE, //
ACTION_DELETE, ACTION_UPDATE, ACTION_CLEAR);
for (Event event : events) {
if (candidates.contains(event.getAction()))
es.add(event);
}
return es;
}
代码示例来源:origin: ff4j/ff4j
/** {@inheritDoc} */
@Override
public EventSeries getAuditTrail(EventQueryDefinition query) {
EventSeries es = new EventSeries();
try (Connection hbConn = ConnectionFactory.createConnection(conn.getConfig())) {
try(Table table = hbConn.getTable(AUDIT_TABLENAME)) {
query.getActionFilters().add(ACTION_CHECK_OK);
Scan scanQuery = buildQuery(query, COLS_EVENT, null);
Set < String > candidates = Util.set(ACTION_DISCONNECT,
ACTION_TOGGLE_ON, ACTION_TOGGLE_OFF,
ACTION_CREATE, ACTION_DELETE,
ACTION_UPDATE, ACTION_CLEAR);
try(ResultScanner scanner = table.getScanner(scanQuery)) {
for (Result rr = scanner.next(); rr != null; rr = scanner.next()) {
String action = Bytes.toString(rr.getValue(B_AUDIT_CF, B_EVENT_ACTION));
if (candidates.contains(action)) {
es.add(MAPPER.fromStore(rr));
}
}
}
}
} catch (IOException e) {
throw new AuditAccessException("Cannot search audit trail ", e);
}
return es;
}
代码示例来源:origin: ff4j/ff4j
/**
* TDD.
*/
@Test
public void testUpdateAddProperty() {
// Given
assertFf4j.assertThatFeatureExist(F2);
assertFf4j.assertThatFeatureHasNotProperty(F2, "p1");
// When
Feature myFeature = ff4j.getFeatureStore().read(F2);
PropertyString p1 = new PropertyString("p1", "v1", Util.set("v1", "v2"));
myFeature.getCustomProperties().put(p1.getName(), p1);
testedStore.update(myFeature);
// Then
assertFf4j.assertThatFeatureHasProperty(F2, "p1");
}
代码示例来源:origin: ff4j/ff4j
/**
* TDD.
*/
@Test
@SuppressWarnings("unchecked")
public void testUpdateEditPropertyAddFixedValues() {
// Given
assertFf4j.assertThatFeatureExist(F1);
Feature myFeature = ff4j.getFeatureStore().read(F1);
myFeature.addProperty(new PropertyInt(DIGIT_VALUE, 2, Util.set(0, 1, 2, 3)));
ff4j.getFeatureStore().update(myFeature);
assertFf4j.assertThatFeatureHasProperty(F1, DIGIT_VALUE);
Set<Integer> fixValues = (Set<Integer>) ff4j.getFeatureStore().read(F1)//
.getCustomProperties().get(DIGIT_VALUE).getFixedValues();
Assert.assertEquals(4, fixValues.size());
// When
myFeature = ff4j.getFeatureStore().read(F1);
PropertyInt p1 = new PropertyInt(DIGIT_VALUE);
p1.setFixedValues(Util.set(0, 1, 2, 3, 4));
p1.setValue(4);
myFeature.getCustomProperties().put(p1.getName(), p1);
testedStore.update(myFeature);
// Then
Set<Integer> fixValues2 = (Set<Integer>) ff4j.getFeatureStore().read(F1) //
.getCustomProperties().get(DIGIT_VALUE).getFixedValues();
Assert.assertEquals(5, fixValues2.size());
}
代码示例来源:origin: ff4j/ff4j
/**
* TDD.
*/
@Test
@SuppressWarnings("unchecked")
public void testUpdateEditPropertyRemoveFixedValues() {
// Given
assertFf4j.assertThatFeatureExist(F1);
Feature myFeature = ff4j.getFeatureStore().read(F1);
myFeature.addProperty(new PropertyString(REGION_IDENTIFIER, "AMER", Util.set("AMER", "SSSS", "EAST")));
testedStore.update(myFeature);
assertFf4j.assertThatFeatureHasProperty(F1, REGION_IDENTIFIER);
Set<String> fixValues = (Set<String>) ff4j.getFeatureStore().read(F1)//
.getCustomProperties().get(REGION_IDENTIFIER).getFixedValues();
Assert.assertEquals(3, fixValues.size());
// When
myFeature = ff4j.getFeatureStore().read(F1);
PropertyString p1 = new PropertyString(REGION_IDENTIFIER);
p1.setValue("AMER");
p1.setFixedValues(Util.set("AMER", "SSSS"));
myFeature.getCustomProperties().put(p1.getName(), p1);
testedStore.update(myFeature);
// Then
Set<Integer> fixValues2 = (Set<Integer>) ff4j.getFeatureStore().read(F1)//
.getCustomProperties().get(REGION_IDENTIFIER).getFixedValues();
Assert.assertEquals(2, fixValues2.size());
}
代码示例来源:origin: ff4j/ff4j
this.indexName = indexName;
this.connectionMode = mode;
this.urlSet = Util.set(url);
内容来源于网络,如有侵权,请联系作者删除!