本文整理汇总了Java中java.util.EnumSet.copyOf方法的典型用法代码示例。如果您正苦于以下问题:Java EnumSet.copyOf方法的具体用法?Java EnumSet.copyOf怎么用?Java EnumSet.copyOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.EnumSet
的用法示例。
在下文中一共展示了EnumSet.copyOf方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import java.util.EnumSet; //导入方法依赖的package包/类
public static void main(String... args) {
Tool compiler = ToolProvider.getSystemJavaCompiler();
Set<SourceVersion> expected = EnumSet.noneOf(SourceVersion.class);
for (String arg : args)
expected.add(SourceVersion.valueOf(arg));
Set<SourceVersion> found = compiler.getSourceVersions();
Set<SourceVersion> notExpected = EnumSet.copyOf(found);
for (SourceVersion version : expected) {
if (!found.contains(version))
throw new AssertionError("Expected source version not found: " + version);
else
notExpected.remove(version);
}
if (!notExpected.isEmpty())
throw new AssertionError("Unexpected source versions: " + notExpected);
}
示例2: toEncrypted
import java.util.EnumSet; //导入方法依赖的package包/类
/**
* Get encrypted reference for clear text directory path.
*
* @param session Connection
* @param directoryId Directory ID or null to read directory id from metadata file
* @param directory Clear text
*/
public Path toEncrypted(final Session<?> session, final String directoryId, final Path directory) throws BackgroundException {
if(!directory.isDirectory()) {
throw new NotfoundException(directory.getAbsolute());
}
if(new SimplePathPredicate(directory).test(home) || directory.isChild(home)) {
final PathAttributes attributes = new PathAttributes(directory.attributes()).withVersionId(null);
// Remember random directory id for use in vault
final String id = this.toDirectoryId(session, directory, directoryId);
if(log.isDebugEnabled()) {
log.debug(String.format("Use directory ID '%s' for folder %s", id, directory));
}
attributes.setDirectoryId(id);
attributes.setDecrypted(directory);
final String directoryIdHash = cryptomator.getCryptor().fileNameCryptor().hashDirectoryId(id);
// Intermediate directory
final Path intermediate = new Path(dataRoot, directoryIdHash.substring(0, 2), dataRoot.getType());
// Add encrypted type
final EnumSet<AbstractPath.Type> type = EnumSet.copyOf(directory.getType());
type.add(Path.Type.encrypted);
type.remove(Path.Type.decrypted);
return new Path(intermediate, directoryIdHash.substring(2), type, attributes);
}
throw new NotfoundException(directory.getAbsolute());
}
示例3: collectingAndThen
import java.util.EnumSet; //导入方法依赖的package包/类
/**
* Adapts a {@code Collector} to perform an additional finishing
* transformation. For example, one could adapt the {@link #toList()}
* collector to always produce an immutable list with:
* <pre>{@code
* List<String> people
* = people.stream().collect(collectingAndThen(toList(), Collections::unmodifiableList));
* }</pre>
*
* @param <T> the type of the input elements
* @param <A> intermediate accumulation type of the downstream collector
* @param <R> result type of the downstream collector
* @param <RR> result type of the resulting collector
* @param downstream a collector
* @param finisher a function to be applied to the final result of the downstream collector
* @return a collector which performs the action of the downstream collector,
* followed by an additional finishing step
*/
public static<T,A,R,RR> Collector<T,A,RR> collectingAndThen(Collector<T,A,R> downstream,
Function<R,RR> finisher) {
Set<Collector.Characteristics> characteristics = downstream.characteristics();
if (characteristics.contains(Collector.Characteristics.IDENTITY_FINISH)) {
if (characteristics.size() == 1)
characteristics = Collectors.CH_NOID;
else {
characteristics = EnumSet.copyOf(characteristics);
characteristics.remove(Collector.Characteristics.IDENTITY_FINISH);
characteristics = Collections.unmodifiableSet(characteristics);
}
}
return new CollectorImpl<>(downstream.supplier(),
downstream.accumulator(),
downstream.combiner(),
downstream.finisher().andThen(finisher),
characteristics);
}
示例4: collectingAndThen
import java.util.EnumSet; //导入方法依赖的package包/类
/**
* Adapts a {@code Collector} to perform an additional finishing
* transformation. For example, one could adapt the {@link #toList()}
* collector to always produce an immutable list with:
* <pre>{@code
* List<String> list
* = people.stream().collect(collectingAndThen(toList(), Collections::unmodifiableList));
* }</pre>
*
* @param <T> the type of the input elements
* @param <A> intermediate accumulation type of the downstream collector
* @param <R> result type of the downstream collector
* @param <RR> result type of the resulting collector
* @param downstream a collector
* @param finisher a function to be applied to the final result of the downstream collector
* @return a collector which performs the action of the downstream collector,
* followed by an additional finishing step
*/
public static<T,A,R,RR> Collector<T,A,RR> collectingAndThen(Collector<T,A,R> downstream,
Function<R,RR> finisher) {
Set<Collector.Characteristics> characteristics = downstream.characteristics();
if (characteristics.contains(Collector.Characteristics.IDENTITY_FINISH)) {
if (characteristics.size() == 1) {
characteristics = Collectors.CH_NOID;
} else {
characteristics = EnumSet.copyOf(characteristics);
characteristics.remove(Collector.Characteristics.IDENTITY_FINISH);
characteristics = Collections.unmodifiableSet(characteristics);
}
}
return new CollectorImpl<>(downstream.supplier(),
downstream.accumulator(),
downstream.combiner(),
downstream.finisher().andThen(finisher),
characteristics);
}
示例5: remove
import java.util.EnumSet; //导入方法依赖的package包/类
public OptimisticOptimizations remove(Optimization... optimizations) {
Set<Optimization> newOptimizations = EnumSet.copyOf(enabledOpts);
for (Optimization o : optimizations) {
newOptimizations.remove(o);
}
return new OptimisticOptimizations(newOptimizations);
}
示例6: noModifiers
import java.util.EnumSet; //导入方法依赖的package包/类
/**
* Returns an empty {@literal EnumSet} of {@literal Modifier}s.
*
* @return empty {@literal EnumSet} of all {@literal Modifier}s;
* it is guaranteed that the returned set is always empty
* but the returned instance may not always be the same
*/
protected static EnumSet<Modifier> noModifiers() {
/*
* An alternative would be to create an instance of
* unmodifiable Set<Modifier> (e.g. Collections.<Modifier>emptySet())
* and always return that instance. But the instance would not be an
* instance of (subclass of) EnumSet which would significantly slow down
* many operations performed on it.
*/
return EnumSet.copyOf(NO_MODIFIERS);
}
示例7: DirectoryScanner
import java.util.EnumSet; //导入方法依赖的package包/类
/**
* Constructs a new {@code DirectoryScanner}.
* <p>This constructor is
* package protected, and this MBean cannot be created by a remote
* client, because it needs a reference to the {@link ResultLogManager},
* which cannot be provided from remote.
* </p>
* <p>This is a conscious design choice: {@code DirectoryScanner} MBeans
* are expected to be completely managed (created, registered, unregistered)
* by the {@link ScanManager} which does provide this reference.
* </p>
*
* @param config This {@code DirectoryScanner} configuration.
* @param logManager The info log manager with which to log the info
* records.
* @throws IllegalArgumentException if one of the parameter is null, or if
* the provided {@code config} doesn't have its {@code name} set,
* or if the {@link DirectoryScannerConfig#getRootDirectory
* root directory} provided in the {@code config} is not acceptable
* (not provided or not found or not readable, etc...).
**/
public DirectoryScanner(DirectoryScannerConfig config,
ResultLogManager logManager)
throws IllegalArgumentException {
if (logManager == null)
throw new IllegalArgumentException("log=null");
if (config == null)
throw new IllegalArgumentException("config=null");
if (config.getName() == null)
throw new IllegalArgumentException("config.name=null");
broadcaster = new NotificationBroadcasterSupport();
// Clone the config: ensure data encapsulation.
//
this.config = XmlConfigUtils.xmlClone(config);
// Checks that the provided root directory is valid.
// Throws IllegalArgumentException if it isn't.
//
rootFile = validateRoot(config.getRootDirectory());
// Initialize the Set<Action> for which this DirectoryScanner
// is configured.
//
if (config.getActions() == null)
actions = Collections.emptySet();
else
actions = EnumSet.copyOf(Arrays.asList(config.getActions()));
this.logManager = logManager;
}
示例8: AbstractExporter
import java.util.EnumSet; //导入方法依赖的package包/类
/** Constructor for subclassing. */
protected AbstractExporter(Kind... formatKinds) {
this.formatKinds = EnumSet.copyOf(Arrays.asList(formatKinds));
this.fileTypes = EnumSet.noneOf(FileType.class);
this.fileTypeMap = new EnumMap<>(ResourceKind.class);
this.resourceKindMap = new EnumMap<>(FileType.class);
}
示例9: createMarkOccurrencesNodeVisitor
import java.util.EnumSet; //导入方法依赖的package包/类
/**
* Creates a generic mark occurrences node visitor for given node types.
* Only elements of the same type (from the given types list) and the same image are marked.
*/
public static <T extends Set<OffsetRange>> NodeVisitor<T> createMarkOccurrencesNodeVisitor(EditorFeatureContext context, T result, NodeType... nodeTypesToMatch) {
final Snapshot snapshot = context.getSnapshot();
int astCaretOffset = snapshot.getEmbeddedOffset(context.getCaretOffset());
if (astCaretOffset == -1) {
return null;
}
final Node current = NodeUtil.findNonTokenNodeAtOffset(context.getParseTreeRoot(), astCaretOffset);
if (current == null) {
//this may happen if the offset falls to the area outside the selectors rule node.
//(for example when the stylesheet starts or ends with whitespaces or comment and
//and the offset falls there).
//In such case root node (with null parent) is returned from NodeUtil.findNodeAtOffset()
return null;
}
Set types = EnumSet.copyOf(Arrays.asList(nodeTypesToMatch));
if(!types.contains(current.type())) {
return null;
}
final CharSequence selectedNamespacePrefixImage = current.image();
return new NodeVisitor<T>(result) {
@Override
public boolean visit(Node node) {
if (node.type() == current.type()
&& CharSequenceUtilities.textEquals(selectedNamespacePrefixImage, node.image())) {
OffsetRange documentNodeRange = Css3Utils.getDocumentOffsetRange(node, snapshot);
getResult().add(Css3Utils.getValidOrNONEOffsetRange(documentNodeRange));
}
return false;
}
};
}
示例10: SimpleRetryStrategy
import java.util.EnumSet; //导入方法依赖的package包/类
public SimpleRetryStrategy(int maxRetries, long delay, HttpMethod... methods) {
this(maxRetries, delay);
this.allowedMethods = EnumSet.copyOf(Arrays.asList(methods));
}
示例11: getVisible
import java.util.EnumSet; //导入方法依赖的package包/类
public EnumSet<DiagnosticPart> getVisible() {
return EnumSet.copyOf(visibleParts);
}
示例12: Style
import java.util.EnumSet; //导入方法依赖的package包/类
Style(@NonNull final Style that) {
this.color = that.color;
this.decorations = EnumSet.copyOf(that.decorations);
}
示例13: LocaleValidityChecker
import java.util.EnumSet; //导入方法依赖的package包/类
public LocaleValidityChecker(Datasubtype... datasubtypes) {
this.datasubtypes = EnumSet.copyOf(Arrays.asList(datasubtypes));
allowsDeprecated = this.datasubtypes.contains(Datasubtype.deprecated);
}
示例14: put
import java.util.EnumSet; //导入方法依赖的package包/类
private static void put(String coloring, ColoringAttributes... attributes) {
Set<ColoringAttributes> attribs = EnumSet.copyOf(Arrays.asList(attributes));
type2Coloring.put(attribs, coloring);
}
示例15: getRegions
import java.util.EnumSet; //导入方法依赖的package包/类
public EnumSet<Region> getRegions() {
return EnumSet.copyOf(regions);
}