本文整理汇总了Java中java.util.EnumSet.add方法的典型用法代码示例。如果您正苦于以下问题:Java EnumSet.add方法的具体用法?Java EnumSet.add怎么用?Java EnumSet.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.EnumSet
的用法示例。
在下文中一共展示了EnumSet.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testDeviceIndex
import java.util.EnumSet; //导入方法依赖的package包/类
@Test
public void testDeviceIndex() throws Exception {
EnumSet<IDeviceService.DeviceField> indexFields =
EnumSet.noneOf(IDeviceService.DeviceField.class);
indexFields.add(IDeviceService.DeviceField.IPv4);
indexFields.add(IDeviceService.DeviceField.VLAN);
deviceManager.addIndex(false, indexFields);
indexFields = EnumSet.noneOf(IDeviceService.DeviceField.class);
deviceManager.addIndex(false, indexFields);
ITopologyService mockTopology = createMock(ITopologyService.class);
deviceManager.topology = mockTopology;
expect(mockTopology.isAttachmentPointPort(DatapathId.of(anyLong()),
OFPort.of(anyShort()))).
andReturn(true).anyTimes();
expect(mockTopology.getOpenflowDomainId(DatapathId.of(EasyMock.anyLong()))).andReturn(DatapathId.of(1L)).anyTimes();
replay(mockTopology);
doTestDeviceQuery();
}
示例2: findTimeZoneNames
import java.util.EnumSet; //导入方法依赖的package包/类
/**
* Returns a collection of time zone display name matches for the specified types in the
* given text at the given offset. This method only finds matches from the TimeZoneNames
* used by this object.
* @param text the text
* @param start the start offset in the text
* @param types the set of name types.
* @return A collection of match info.
*/
private Collection<MatchInfo> findTimeZoneNames(String text, int start, EnumSet<GenericNameType> types) {
Collection<MatchInfo> tznamesMatches = null;
// Check if the target name type is really in the TimeZoneNames
EnumSet<NameType> nameTypes = EnumSet.noneOf(NameType.class);
if (types.contains(GenericNameType.LONG)) {
nameTypes.add(NameType.LONG_GENERIC);
nameTypes.add(NameType.LONG_STANDARD);
}
if (types.contains(GenericNameType.SHORT)) {
nameTypes.add(NameType.SHORT_GENERIC);
nameTypes.add(NameType.SHORT_STANDARD);
}
if (!nameTypes.isEmpty()) {
// Find matches in the TimeZoneNames
tznamesMatches = _tznames.find(text, start, nameTypes);
}
return tznamesMatches;
}
示例3: getDependenciesModes
import java.util.EnumSet; //导入方法依赖的package包/类
/**
* This method is used to parse the {@code completionDeps} option.
* Possible modes are separated by colon; a mode can be excluded by
* prepending '-' to its name. Finally, the special mode 'all' can be used to
* add all modes to the resulting enum.
*/
static EnumSet<DependenciesMode> getDependenciesModes(String[] modes) {
EnumSet<DependenciesMode> res = EnumSet.noneOf(DependenciesMode.class);
Collection<String> args = Arrays.asList(modes);
if (args.contains("all")) {
res = EnumSet.allOf(DependenciesMode.class);
}
for (DependenciesMode mode : values()) {
if (args.contains(mode.opt)) {
res.add(mode);
} else if (args.contains("-" + mode.opt)) {
res.remove(mode);
}
}
return res;
}
示例4: parseString
import java.util.EnumSet; //导入方法依赖的package包/类
public static EnumSet<Metric> parseString(String param, boolean ignoreUnknown) {
String[] metrics = Strings.splitStringByCommaToArray(param);
EnumSet<Metric> result = EnumSet.noneOf(Metric.class);
for (String metric : metrics) {
if ("_all".equals(metric)) {
result = EnumSet.allOf(Metric.class);
break;
}
Metric m = valueToEnum.get(metric);
if (m == null) {
if (!ignoreUnknown) {
throw new IllegalArgumentException("Unknown metric [" + metric + "]");
}
} else {
result.add(m);
}
}
return result;
}
示例5: getVerboseResolutionMode
import java.util.EnumSet; //导入方法依赖的package包/类
static EnumSet<VerboseResolutionMode> getVerboseResolutionMode(Options opts) {
String s = opts.get("verboseResolution");
EnumSet<VerboseResolutionMode> res = EnumSet.noneOf(VerboseResolutionMode.class);
if (s == null) return res;
if (s.contains("all")) {
res = EnumSet.allOf(VerboseResolutionMode.class);
}
Collection<String> args = Arrays.asList(s.split(","));
for (VerboseResolutionMode mode : values()) {
if (args.contains(mode.opt)) {
res.add(mode);
} else if (args.contains("-" + mode.opt)) {
res.remove(mode);
}
}
return res;
}
示例6: initBarcodeReader
import java.util.EnumSet; //导入方法依赖的package包/类
/**
* Initialize the barcode decoder.
*/
private void initBarcodeReader(List<String> barCodeTypes) {
EnumMap<DecodeHintType, Object> hints = new EnumMap<>(DecodeHintType.class);
EnumSet<BarcodeFormat> decodeFormats = EnumSet.noneOf(BarcodeFormat.class);
if (barCodeTypes != null) {
for (String code : barCodeTypes) {
BarcodeFormat format = parseBarCodeString(code);
if (format != null) {
decodeFormats.add(format);
}
}
}
hints.put(DecodeHintType.POSSIBLE_FORMATS, decodeFormats);
_multiFormatReader.setHints(hints);
}
示例7: getSelectedOptions
import java.util.EnumSet; //导入方法依赖的package包/类
private final EnumSet<DialogOption> getSelectedOptions() {
EnumSet<DialogOption> selected = EnumSet.noneOf(DialogOption.class);
for (Item item : mItems) {
if (item.isSelected()) selected.add(item.getOption());
}
return selected;
}
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:8,代码来源:ClearBrowsingDataPreferences.java
示例8: createModifierSet
import java.util.EnumSet; //导入方法依赖的package包/类
/**
* Creates a {@code Set} of {@code Modifier}s from the given list
* of modifiers.
*
* @param modifiers modifiers that should be contained in the set
* @return set containing exactly the given modifiers
*/
static Set<Modifier> createModifierSet(Modifier... modifiers) {
EnumSet<Modifier> modifierSet = EnumSet.noneOf(Modifier.class);
for (Modifier m : modifiers) {
modifierSet.add(m);
}
return modifierSet;
}
示例9: testFlagsSetSequence
import java.util.EnumSet; //导入方法依赖的package包/类
private void testFlagsSetSequence(Supplier<StatefulTestOp<Integer>> cf) {
EnumSet<StreamOpFlag> known = EnumSet.of(StreamOpFlag.ORDERED, StreamOpFlag.SIZED);
EnumSet<StreamOpFlag> preserve = EnumSet.of(StreamOpFlag.DISTINCT, StreamOpFlag.SORTED);
List<IntermediateTestOp<Integer, Integer>> ops = new ArrayList<>();
for (StreamOpFlag f : EnumSet.of(StreamOpFlag.DISTINCT, StreamOpFlag.SORTED)) {
ops.add(cf.get());
ops.add(new TestFlagExpectedOp<>(f.set(),
known.clone(),
preserve.clone(),
EnumSet.noneOf(StreamOpFlag.class)));
known.add(f);
preserve.remove(f);
}
ops.add(cf.get());
ops.add(new TestFlagExpectedOp<>(0,
known.clone(),
preserve.clone(),
EnumSet.noneOf(StreamOpFlag.class)));
TestData<Integer, Stream<Integer>> data = TestData.Factory.ofArray("Array", countTo(10).toArray(new Integer[0]));
@SuppressWarnings("rawtypes")
IntermediateTestOp[] opsArray = ops.toArray(new IntermediateTestOp[ops.size()]);
withData(data).ops(opsArray).
without(StreamTestScenario.CLEAR_SIZED_SCENARIOS).
exercise();
}
示例10: setSessionPersistPolicies
import java.util.EnumSet; //导入方法依赖的package包/类
public void setSessionPersistPolicies(String sessionPersistPolicies) {
String[] policyArray = sessionPersistPolicies.split(",");
EnumSet<SessionPersistPolicy> policySet = EnumSet.of(SessionPersistPolicy.DEFAULT);
for (String policyName : policyArray) {
SessionPersistPolicy policy = SessionPersistPolicy.fromName(policyName);
policySet.add(policy);
}
this.sessionPersistPoliciesSet = policySet;
}
示例11: convert
import java.util.EnumSet; //导入方法依赖的package包/类
public static EnumSet<XAttrSetFlag> convert(int flag) {
EnumSet<XAttrSetFlag> result =
EnumSet.noneOf(XAttrSetFlag.class);
if ((flag & XAttrSetFlagProto.XATTR_CREATE_VALUE) ==
XAttrSetFlagProto.XATTR_CREATE_VALUE) {
result.add(XAttrSetFlag.CREATE);
}
if ((flag & XAttrSetFlagProto.XATTR_REPLACE_VALUE) ==
XAttrSetFlagProto.XATTR_REPLACE_VALUE) {
result.add(XAttrSetFlag.REPLACE);
}
return result;
}
示例12: create
import java.util.EnumSet; //导入方法依赖的package包/类
private <T extends Enum<T>> EnumSet<T> create(final Class<T> type, final String s) {
final String[] enumValues = s.split(",");
final EnumSet<T> set = EnumSet.noneOf(type);
for (final String enumValue : enumValues) {
if (enumValue.length() > 0) {
final T value = Enum.valueOf(type, enumValue);
set.add(value);
}
}
return set;
}
示例13: convertCacheFlags
import java.util.EnumSet; //导入方法依赖的package包/类
public static EnumSet<CacheFlag> convertCacheFlags(int flags) {
EnumSet<CacheFlag> result = EnumSet.noneOf(CacheFlag.class);
if ((flags & CacheFlagProto.FORCE_VALUE) == CacheFlagProto.FORCE_VALUE) {
result.add(CacheFlag.FORCE);
}
return result;
}
示例14: main
import java.util.EnumSet; //导入方法依赖的package包/类
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Bridge.init();
EnumSet<TestCase> tests = EnumSet.noneOf(TestCase.class);
for (String arg : args) {
tests.add(TestCase.valueOf(arg));
}
if (args.length == 0) {
tests = EnumSet.complementOf(EnumSet.of(TestCase.LoadingMain));
}
final EnumSet<TestCase> loadingTests =
EnumSet.of(TestCase.LoadingApplet, TestCase.LoadingMain);
int testrun = 0;
for (TestCase test : tests) {
if (loadingTests.contains(test)) {
if (testrun > 0) {
throw new UnsupportedOperationException("Test case "
+ test + " must be executed first!");
}
}
System.out.println("Testing "+ test+": ");
System.out.println(test.describe());
try {
test.test();
} catch (Exception x) {
throw new Error(String.valueOf(test)
+ (System.getSecurityManager() == null ? " without " : " with ")
+ "security failed: "+x+"\n "+"FAILED: "+test.describe()+"\n", x);
} finally {
testrun++;
}
Bridge.changeContext();
System.out.println("PASSED: "+ test);
}
}
示例15: parsePlatformString
import java.util.EnumSet; //导入方法依赖的package包/类
/**
* Parse the platforms attribute returning the set of platform ids
*
* @param platformStr String
*/
protected final EnumSet<Platform.Type> parsePlatformString(String platformStr)
{
// Split the platform string and build up a set of platform types
EnumSet<Platform.Type> platformTypes = EnumSet.noneOf(Platform.Type.class);
if (platformStr == null || platformStr.length() == 0)
return platformTypes;
StringTokenizer token = new StringTokenizer(platformStr.toUpperCase(Locale.ENGLISH), ",");
String typ = null;
try
{
while (token.hasMoreTokens())
{
// Get the current platform type string and validate
typ = token.nextToken().trim();
Platform.Type platform = Platform.Type.valueOf(typ);
if (platform != Platform.Type.Unknown)
platformTypes.add(platform);
else
throw new AlfrescoRuntimeException("Invalid platform type, " + typ);
}
}
catch (IllegalArgumentException ex)
{
throw new AlfrescoRuntimeException("Invalid platform type, " + typ);
}
// Return the platform types
return platformTypes;
}