本文整理汇总了Java中javax.lang.model.SourceVersion.valueOf方法的典型用法代码示例。如果您正苦于以下问题:Java SourceVersion.valueOf方法的具体用法?Java SourceVersion.valueOf怎么用?Java SourceVersion.valueOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.lang.model.SourceVersion
的用法示例。
在下文中一共展示了SourceVersion.valueOf方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sourceVersion
import javax.lang.model.SourceVersion; //导入方法依赖的package包/类
public @NonNull SourceVersion sourceVersion() {
String sourceLevel = SourceLevelQuery.getSourceLevel(ctx.getInfo().getFileObject());
if (sourceLevel == null) {
return SourceVersion.latest(); //TODO
}
String[] splited = sourceLevel.split("\\.");
String spec = splited[1];
return SourceVersion.valueOf("RELEASE_"+ spec);//!!!
}
示例2: setSourceVersion
import javax.lang.model.SourceVersion; //导入方法依赖的package包/类
public Builder setSourceVersion(String version) {
if (version == null || version.isEmpty()) {
this.sourceVersion = SourceVersion.RELEASE_3;
} else {
if (version.startsWith("1.")) {
version = version.substring(2);
}
try {
this.sourceVersion = SourceVersion.valueOf("RELEASE_" + version);
} catch (IllegalArgumentException ex) {
this.sourceVersion = SourceVersion.RELEASE_3;
}
}
return this;
}
示例3: getSupportedSourceVersion
import javax.lang.model.SourceVersion; //导入方法依赖的package包/类
@Override
public SourceVersion getSupportedSourceVersion() {
if (SourceVersion.latest().compareTo(SourceVersion.RELEASE_6) > 0)
return SourceVersion.valueOf("RELEASE_7");
else
return SourceVersion.RELEASE_6;
}
示例4: process
import javax.lang.model.SourceVersion; //导入方法依赖的package包/类
public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnvironment) {
SourceVersion expectedVersion =
SourceVersion.valueOf(processingEnv.getOptions().get("ExpectedVersion"));
SourceVersion actualVersion = processingEnv.getSourceVersion();
System.out.println("Expected SourceVersion " + expectedVersion +
" actual SourceVersion " + actualVersion);
if (expectedVersion != actualVersion)
throw new RuntimeException();
return true;
}
示例5: getSupportedSourceVersion
import javax.lang.model.SourceVersion; //导入方法依赖的package包/类
@Override
public SourceVersion getSupportedSourceVersion() {
String sourceVersion = processingEnv.getOptions().get("SourceVersion");
if (sourceVersion == null) {
processingEnv.getMessager().printMessage(WARNING,
"No SourceVersion option given");
return SourceVersion.RELEASE_6;
} else {
return SourceVersion.valueOf(sourceVersion);
}
}