本文整理汇总了Java中java.lang.module.ModuleDescriptor.Requires.Modifier方法的典型用法代码示例。如果您正苦于以下问题:Java Requires.Modifier方法的具体用法?Java Requires.Modifier怎么用?Java Requires.Modifier使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.lang.module.ModuleDescriptor.Requires
的用法示例。
在下文中一共展示了Requires.Modifier方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newRequires
import java.lang.module.ModuleDescriptor.Requires; //导入方法依赖的package包/类
/**
* Returns a {@link Requires} for a dependence on a module with the given
* (and possibly empty) set of modifiers, and optionally the version
* recorded at compile time.
*/
public static Requires newRequires(Set<Requires.Modifier> mods,
String mn,
String compiledVersion)
{
Version version = null;
if (compiledVersion != null) {
// use the cached version if the same version string
Version ver = cachedVersion;
if (ver != null && compiledVersion.equals(ver.toString())) {
version = ver;
} else {
version = Version.parse(compiledVersion);
}
}
return JLMA.newRequires(mods, mn, version);
}
示例2: requireModifiers
import java.lang.module.ModuleDescriptor.Requires; //导入方法依赖的package包/类
private static Set<Requires.Modifier> requireModifiers(int modifiers) {
return Map.of(
ACC_MANDATED, Requires.Modifier.MANDATED,
ACC_SYNTHETIC, Requires.Modifier.SYNTHETIC,
ACC_TRANSITIVE, Requires.Modifier.TRANSITIVE,
ACC_STATIC_PHASE, Requires.Modifier.STATIC)
.entrySet()
.stream()
.map(entry -> (modifiers & entry.getKey()) != 0? entry.getValue(): null)
.filter(Objects::nonNull)
.collect(Collectors.toSet());
}
示例3: modifierToInt
import java.lang.module.ModuleDescriptor.Requires; //导入方法依赖的package包/类
private static int modifierToInt(Requires.Modifier modifier) {
switch(modifier) {
case MANDATED:
return ACC_MANDATED;
case SYNTHETIC:
return ACC_SYNTHETIC;
case STATIC:
return ACC_STATIC_PHASE;
case TRANSITIVE:
return ACC_TRANSITIVE;
default:
throw new IllegalStateException("unknown modifier " + modifier);
}
}
示例4: newRequires
import java.lang.module.ModuleDescriptor.Requires; //导入方法依赖的package包/类
void newRequires(Set<Requires.Modifier> mods, String name, String compiledVersion) {
int varIndex = dedupSetBuilder.indexOfRequiresModifiers(mods);
mv.visitVarInsn(ALOAD, varIndex);
mv.visitLdcInsn(name);
if (compiledVersion != null) {
mv.visitLdcInsn(compiledVersion);
mv.visitMethodInsn(INVOKESTATIC, MODULE_DESCRIPTOR_BUILDER,
"newRequires", REQUIRES_SET_STRING_STRING_SIG, false);
} else {
mv.visitMethodInsn(INVOKESTATIC, MODULE_DESCRIPTOR_BUILDER,
"newRequires", REQUIRES_SET_STRING_SIG, false);
}
}
示例5: requires
import java.lang.module.ModuleDescriptor.Requires; //导入方法依赖的package包/类
/**
* Adds a module dependence with the given modifier.
*/
public Builder requires(Requires.Modifier mod, String mn) {
if (mod == Requires.Modifier.MANDATED) {
requires.add(jlma.newRequires(MANDATED, mn));
} else if (mod == Requires.Modifier.PUBLIC) {
requires.add(jlma.newRequires(PUBLIC, mn));
} else {
requires.add(jlma.newRequires(Collections.singleton(mod), mn));
}
return this;
}
示例6: mergeRequiresModifiers
import java.lang.module.ModuleDescriptor.Requires; //导入方法依赖的package包/类
private static Set<Requires.Modifier> mergeRequiresModifiers(Set<Requires.Modifier> s1, Set<Requires.Modifier> s2) {
boolean transitive = s1.contains(Requires.Modifier.TRANSITIVE) || s2.contains(Requires.Modifier.TRANSITIVE);
boolean staticz = s1.contains(Requires.Modifier.STATIC) && s2.contains(Requires.Modifier.STATIC);
return Stream.of(
Optional.of(Requires.Modifier.TRANSITIVE).filter(__ -> transitive),
Optional.of(Requires.Modifier.STATIC).filter(__ -> staticz)
).flatMap(Optional::stream).collect(Collectors.toSet());
}
示例7: requires
import java.lang.module.ModuleDescriptor.Requires; //导入方法依赖的package包/类
/**
* Adds a dependence on a module with the given (possibly un-parsable)
* version string.
*/
void requires(ModuleDescriptor.Builder builder,
Set<Requires.Modifier> ms,
String mn,
String rawCompiledVersion);
示例8: requiresModifiers
import java.lang.module.ModuleDescriptor.Requires; //导入方法依赖的package包/类
void requiresModifiers(Set<Requires.Modifier> mods) {
requiresModifiersSets.computeIfAbsent(mods, s ->
new EnumSetBuilder<>(s, REQUIRES_MODIFIER_CLASSNAME,
enumSetVar, localVarSupplier)
).increment();
}
示例9: indexOfRequiresModifiers
import java.lang.module.ModuleDescriptor.Requires; //导入方法依赖的package包/类
int indexOfRequiresModifiers(Set<Requires.Modifier> mods) {
return requiresModifiersSets.get(mods).build();
}
示例10: mergeModuleDescriptor
import java.lang.module.ModuleDescriptor.Requires; //导入方法依赖的package包/类
public static ModuleDescriptor mergeModuleDescriptor(ModuleDescriptor sourceModule, ModuleDescriptor testModule) {
boolean open = sourceModule.isOpen() || testModule.isOpen();
Set<Modifier> moduleModifiers = open? Set.of(Modifier.OPEN): Set.of();
Builder builder = ModuleDescriptor.newModule(testModule.name(), moduleModifiers);
HashMap<String, Set<Requires.Modifier>> requires = merge(ModuleDescriptor::requires,
Requires::name, Requires::modifiers, ModuleHelper::mergeRequiresModifiers, sourceModule, testModule);
HashMap<String, Set<String>> exports = merge(ModuleDescriptor::exports,
Exports::source, Exports::targets, ModuleHelper::mergeRestrictions, sourceModule, testModule);
HashMap<String, Boolean> packages = merge(ModuleDescriptor::packages,
x -> x, x -> true, (_1, _2) -> true, sourceModule, testModule);
HashMap<String, Set<String>> opens = merge(ModuleDescriptor::opens,
Opens::source, Opens::targets, ModuleHelper::mergeRestrictions, sourceModule, testModule);
HashMap<String, Boolean> uses = merge(ModuleDescriptor::uses,
x -> x, x -> true, (_1, _2) -> true, sourceModule, testModule);
HashMap<String, Set<String>> provides = merge(ModuleDescriptor::provides,
Provides::service, p -> new HashSet<>(p.providers()), ModuleHelper::mergeAll, sourceModule, testModule);
requires.forEach((name, modifiers) -> builder.requires(modifiers, name));
exports.forEach((source, target) -> {
if (target.isEmpty()) {
builder.exports(Set.of(), source);
} else {
builder.exports(source, target);
}
});
packages.keySet().removeAll(exports.keySet());
builder.packages(packages.keySet());
opens.forEach((source, target) -> {
if (target.isEmpty()) {
builder.opens(Set.of(), source);
} else {
builder.opens(source, target);
}
});
uses.keySet().forEach(builder::uses);
provides.forEach((service, providers) -> builder.provides(service, providers.stream().collect(toList())));
return builder.build();
}
示例11: newRequires
import java.lang.module.ModuleDescriptor.Requires; //导入方法依赖的package包/类
/**
* Returns a {@code ModuleDescriptor.Requires} of the given modifiers
* and module name.
*/
Requires newRequires(Set<Requires.Modifier> ms, String mn, Version v);
示例12: newRequires
import java.lang.module.ModuleDescriptor.Requires; //导入方法依赖的package包/类
/**
* Returns {@code ModuleDescriptor.Requires} of the given modifier
* and module name.
*/
Requires newRequires(Set<Requires.Modifier> ms, String mn);