本文整理汇总了Java中edu.emory.mathcs.backport.java.util.Collections类的典型用法代码示例。如果您正苦于以下问题:Java Collections类的具体用法?Java Collections怎么用?Java Collections使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Collections类属于edu.emory.mathcs.backport.java.util包,在下文中一共展示了Collections类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFlowsWithAffectedPathBySwitch
import edu.emory.mathcs.backport.java.util.Collections; //导入依赖的package包/类
@Test
public void getFlowsWithAffectedPathBySwitch() throws Exception {
Set<ImmutablePair<Flow, Flow>> affected;
ImmutablePair<Flow, Flow> first = flowCache.createFlow(firstFlow, computer.getPath(firstFlow));
ImmutablePair<Flow, Flow> second = flowCache.createFlow(secondFlow, computer.getPath(secondFlow));
ImmutablePair<Flow, Flow> third = flowCache.createFlow(thirdFlow, computer.getPath(thirdFlow));
affected = flowCache.getFlowsWithAffectedPath(NetworkTopologyConstants.sw5.getSwitchId());
assertEquals(new HashSet<>(Arrays.asList(first, second)), affected);
affected = flowCache.getFlowsWithAffectedPath(NetworkTopologyConstants.sw3.getSwitchId());
assertEquals(new HashSet<>(Arrays.asList(first, second, third)), affected);
affected = flowCache.getFlowsWithAffectedPath(NetworkTopologyConstants.sw1.getSwitchId());
assertEquals(Collections.singleton(first), affected);
}
示例2: getFlowsWithAffectedPathByIsl
import edu.emory.mathcs.backport.java.util.Collections; //导入依赖的package包/类
@Test
public void getFlowsWithAffectedPathByIsl() throws Exception {
Set<ImmutablePair<Flow, Flow>> affected;
ImmutablePair<Flow, Flow> first = flowCache.createFlow(firstFlow, computer.getPath(firstFlow));
ImmutablePair<Flow, Flow> second = flowCache.createFlow(secondFlow, computer.getPath(secondFlow));
flowCache.createFlow(thirdFlow, computer.getPath(thirdFlow));
affected = flowCache.getFlowsWithAffectedPath(NetworkTopologyConstants.isl12);
assertEquals(Collections.singleton(first), affected);
affected = flowCache.getFlowsWithAffectedPath(NetworkTopologyConstants.isl21);
assertEquals(Collections.singleton(first), affected);
affected = flowCache.getFlowsWithAffectedPath(NetworkTopologyConstants.isl53);
assertEquals(new HashSet<>(Arrays.asList(first, second)), affected);
affected = flowCache.getFlowsWithAffectedPath(NetworkTopologyConstants.isl35);
assertEquals(new HashSet<>(Arrays.asList(first, second)), affected);
}
示例3: getFlowsWithAffectedPathByPort
import edu.emory.mathcs.backport.java.util.Collections; //导入依赖的package包/类
@Test
public void getFlowsWithAffectedPathByPort() throws Exception {
Set<ImmutablePair<Flow, Flow>> affected;
ImmutablePair<Flow, Flow> first = flowCache.createFlow(firstFlow, computer.getPath(firstFlow));
ImmutablePair<Flow, Flow> second = flowCache.createFlow(secondFlow, computer.getPath(secondFlow));
flowCache.createFlow(thirdFlow, computer.getPath(thirdFlow));
affected = flowCache.getFlowsWithAffectedPath(new PortInfoData(
NetworkTopologyConstants.isl12.getPath().get(0)));
assertEquals(Collections.singleton(first), affected);
affected = flowCache.getFlowsWithAffectedPath(new PortInfoData(
NetworkTopologyConstants.isl21.getPath().get(0)));
assertEquals(Collections.singleton(first), affected);
affected = flowCache.getFlowsWithAffectedPath(new PortInfoData(
NetworkTopologyConstants.isl53.getPath().get(0)));
assertEquals(new HashSet<>(Arrays.asList(first, second)), affected);
affected = flowCache.getFlowsWithAffectedPath(new PortInfoData(
NetworkTopologyConstants.isl35.getPath().get(0)));
assertEquals(new HashSet<>(Arrays.asList(first, second)), affected);
}
示例4: getFlowsForUpState
import edu.emory.mathcs.backport.java.util.Collections; //导入依赖的package包/类
@Test
public void getFlowsForUpState() throws Exception {
Map<String, String> affected;
ImmutablePair<Flow, Flow> first = flowCache.createFlow(firstFlow, computer.getPath(firstFlow));
ImmutablePair<Flow, Flow> second = flowCache.createFlow(secondFlow, computer.getPath(secondFlow));
ImmutablePair<Flow, Flow> third = flowCache.createFlow(thirdFlow, computer.getPath(thirdFlow));
affected = flowCache.getFlowsWithAffectedEndpoint(NetworkTopologyConstants.sw5.getSwitchId());
assertEquals(Collections.singleton(second.getLeft().getFlowId()), affected.keySet());
affected = flowCache.getFlowsWithAffectedEndpoint(NetworkTopologyConstants.sw3.getSwitchId());
assertEquals(new HashSet<>(Arrays.asList(first.getLeft().getFlowId(),
second.getLeft().getFlowId(), third.getLeft().getFlowId())), affected.keySet());
affected = flowCache.getFlowsWithAffectedEndpoint(NetworkTopologyConstants.sw1.getSwitchId());
assertEquals(Collections.singleton(first.getLeft().getFlowId()), affected.keySet());
}
示例5: updateSwitch
import edu.emory.mathcs.backport.java.util.Collections; //导入依赖的package包/类
@Test
public void updateSwitch() throws Exception {
String swId = "sw7";
SwitchInfoData sw7 = new SwitchInfoData(swId, SwitchState.ACTIVATED, "", "", "", "");
networkCache.createSwitch(sw7);
assertEquals(sw7, networkCache.getSwitch(swId));
SwitchInfoData sw7updated = new SwitchInfoData(swId, SwitchState.ACTIVATED, "", "", "", "");
networkCache.updateSwitch(sw7updated);
assertEquals(sw7updated, networkCache.getSwitch(swId));
networkCache.deleteSwitch(swId);
Set<SwitchInfoData> switches = networkCache.dumpSwitches();
assertEquals(Collections.emptySet(), switches);
}
示例6: updateSagan
import edu.emory.mathcs.backport.java.util.Collections; //导入依赖的package包/类
public void updateSagan(String branch, ProjectVersion originalVersion, ProjectVersion version) {
ReleaseUpdate update = releaseUpdate(branch, originalVersion, version);
log.info("Updating Sagan with \n\n{}", update);
this.saganClient.updateRelease(version.projectName, Collections.singletonList(update));
if (version.isRelease() || version.isServiceRelease()) {
log.info("Version is GA [{}]. Will remove old snapshot and add a new one", version);
String snapshot = toSnapshot(version.version);
String bumpedSnapshot = toSnapshot(version.bumpedVersion());
log.info("Removing [{}/{}] from Sagan", version.projectName, snapshot);
this.saganClient.deleteRelease(version.projectName, snapshot);
ReleaseUpdate snapshotUpdate =
releaseUpdate(branch, originalVersion, new ProjectVersion(version.projectName, bumpedSnapshot));
log.info("Updating Sagan with \n\n[{}]", snapshotUpdate);
this.saganClient.updateRelease(version.projectName, Collections.singletonList(snapshotUpdate));
}
}
示例7: sortSteps
import edu.emory.mathcs.backport.java.util.Collections; //导入依赖的package包/类
public List<String> sortSteps(Map<String, Map<String, String>> testData,
String indexColumn, String valueColumn) {
List<String> sortedSteps = new ArrayList<>();
Map<String, Integer> elementSteps = testData.values().stream()
.collect(Collectors.toMap(o -> o.get(indexColumn),
o -> Integer.parseInt(o.get(valueColumn))));
/*
elementSteps = testData.keySet().stream().collect(Collectors.toMap(o -> o,
o -> Integer.parseInt(testData.get(o).get(valueColumn))));
*/
List<Entry<String, Integer>> stepNumbers = new ArrayList<>();
stepNumbers.addAll(elementSteps.entrySet());
Collections.sort(stepNumbers, new Comparator<Entry<String, Integer>>() {
public int compare(Entry<String, Integer> obj_left,
Entry<String, Integer> obj_right) {
return obj_left.getValue().compareTo(obj_right.getValue());
}
});
return stepNumbers.stream().map(e -> e.getKey())
.collect(Collectors.toList());
}
示例8: get
import edu.emory.mathcs.backport.java.util.Collections; //导入依赖的package包/类
/**
* Get a sorted PostProcessors by generic type
* @param targetType the generic type of a registered PostProcessor.
* @param <T> the type.
* @return the List of PostProcessor
*/
@SuppressWarnings("unchecked")
public <T> List<PostProcessor<T>> get(Class<T> targetType) {
List<PostProcessor<T>> selected = new ArrayList<>();
for (PostProcessor postProcessor : postProcessors) {
Type type = postProcessor.getTargetClass();
if (TypeToken.of(targetType).isSubtypeOf(TypeToken.of(type))) {
selected.add(postProcessor);
}
}
Collections.sort(selected);
return selected;
}
示例9: removeTaskFromList
import edu.emory.mathcs.backport.java.util.Collections; //导入依赖的package包/类
private void removeTaskFromList(ArrayList<Integer> deletedIds) {
if (deletedIds.size() == 1) {
controller.importantList.remove(controller.indexMatch.get(deletedIds.get(0)));
controller.relayFb(String.format(Constants.CMD_SUCCESS_DELETED_1, deletedIds.get(0)), MsgType.SUCCESS);
} else {
int count = 0;
int indexCount;
String indices = "";
Collections.sort(deletedIds, Collections.reverseOrder());
for (int screenId : deletedIds) {
indexCount = controller.indexMatch.get(screenId);
indices += "#" + String.valueOf(screenId);
count++;
if (count == deletedIds.size() - 1) {
indices += " and ";
} else if (!(count == deletedIds.size())) {
indices += ", ";
}
controller.importantList.remove(indexCount);
}
controller.relayFb(String.format(Constants.CMD_SUCCESS_DELETED_2, indices), MsgType.SUCCESS);
}
}
示例10: testComposeWhere_pkWithSingleCondition
import edu.emory.mathcs.backport.java.util.Collections; //导入依赖的package包/类
@Test
public void testComposeWhere_pkWithSingleCondition() throws Exception {
WithPk data = new WithPk();
data.field1 = 10;
data.field2 = "STR";
data.field3 = Arrays.asList(1L, 2L, 3L);
data.field4 = 0.1f;
String expected = "WHERE (`field2`!='STR')";
@SuppressWarnings("unchecked")
List<Where<?>> conditions = (List<Where<?>>) Collections.singletonList(new Where<>(
Conjunction.AND, "field2", Sign.NE, "STR"
));
String actual = composeWhereClause(data, conditions);
assertEquals(expected, actual);
}
示例11: compile
import edu.emory.mathcs.backport.java.util.Collections; //导入依赖的package包/类
@Override
public OOPSourceCodeModel compile(SourceFiles rawData) throws Exception {
final OOPSourceCodeModel srcModel = new OOPSourceCodeModel();
final List<RawFile> files = rawData.getFiles();
if (files.size() < 1) {
return srcModel;
} else {
List<String> projectFileTypes = getProjectFileSymbols(files);
// sort fileTypes by length in desc order so that the longest types are at the
// top.
Collections.sort(projectFileTypes, new LengthComp());
// compile code based on number of workers
compileFiles(files, srcModel, projectFileTypes);
/**
* In GoLang, interfaces are implemented implicitly. As a result, we handle
* their detection in the following way: Once we have parsed the entire code
* base, we compare every parsed interface to every parsed struct to see if
* there is a match. Then we modify the source code model to represent our
* findings accordingly.
*/
resolveInterfaces(srcModel);
}
return srcModel;
}
示例12: test
import edu.emory.mathcs.backport.java.util.Collections; //导入依赖的package包/类
@Test
public void test() throws Exception {
/*
This selector aims at keeping amplified test that execute new lines in the source code.
*/
Utils.reset();
Utils.init("src/test/resources/test-projects/test-projects.properties");
EntryPoint.verbose = true;
final DSpot dspot = new DSpot(Utils.getInputConfiguration(),
1,
Arrays.asList(new Amplifier[]{new TestDataMutator(), new StatementAdd()}),
new CloverCoverageSelector()
);
final CtType ctType = dspot.amplifyTest(Utils.findClass("example.TestSuiteExample"),
Collections.singletonList(Utils.findMethod("example.TestSuiteExample", "test2"))
);
assertFalse(ctType.getMethodsByName("test2_literalMutationNumber9").isEmpty());
EntryPoint.verbose = false;
}
示例13: testExcludedClassesInPropertyFile
import edu.emory.mathcs.backport.java.util.Collections; //导入依赖的package包/类
@Test
public void testExcludedClassesInPropertyFile() throws Exception {
/*
Usage of properties:
- excludedClasses: list of full qualified name of test classes to be excluded (separated by comma ',')
- excludedTestCases: list of name of test cases (methods) to be excluded (separated by comma ',')
*/
final MockDSpot dSpot = new MockDSpot(Utils.getInputConfiguration(),
1,
Collections.singletonList(new TestMethodCallAdder()),
new JacocoCoverageSelector()
);
// the test class fr.inria.filter.passing.PassingTest has 2 method, but only one is amplified
assertEquals(2, Utils.findClass("fr.inria.filter.passing.PassingTest").getMethods().size());
// the test class fr.inria.filter.failing.FailingTest match the regex, but it is excluded in the properties
final List<CtType> ctTypes = dSpot.amplifyTest("fr.inria.filter.*");
assertEquals(1, ctTypes.size());
// uses the mock to retrieve the number of method to be amplified
assertEquals(1, dSpot.numberOfMethod);
}
示例14: renderClassMembers
import edu.emory.mathcs.backport.java.util.Collections; //导入依赖的package包/类
private void renderClassMembers(StringBuilder sb, Class<?> aClass) {
List<String> fields = new ArrayList<>();
List<String> methods = new ArrayList<>();
List<String> constructors = new ArrayList<>();
addMembers(aClass.getDeclaredFields(), fields);
addMembers(aClass.getDeclaredConstructors(), constructors);
addMembers(aClass.getDeclaredMethods(), methods);
Collections.sort(fields);
Collections.sort(methods);
Collections.sort(constructors);
for (String field : fields) {
sb.append(field + "\n");
}
sb.append("--\n");
for (String constructor : constructors) {
sb.append(constructor + "\n");
}
for (String method : methods) {
sb.append(method + "\n");
}
}
示例15: serializeList
import edu.emory.mathcs.backport.java.util.Collections; //导入依赖的package包/类
public String serializeList(List<HouseNumber> houseNumberList){
if (houseNumberList==null || houseNumberList.size()==0){
return null;
}
Collections.sort(houseNumberList,comparator);
StringBuffer sb = new StringBuffer();
for (HouseNumber houseNumber:houseNumberList){
if (houseNumber==null || houseNumber.getNumber()==null || houseNumber.getLocation()==null){
continue;
}
String serialized = serialize(houseNumber);
if (serialized!=null){
sb.append(serialized)
.append(HOUSE_NUMBERS_SEPARATOR);
}
}
return sb.toString().trim();
}