Java源码示例:io.vertx.codegen.doc.Text
示例1
public MethodInfo(Set<ClassTypeInfo> ownerTypes, String name,
TypeInfo returnType, Text returnDescription, boolean fluent, boolean cacheReturn,
List<ParamInfo> params, String comment, Doc doc, boolean staticMethod, boolean defaultMethod,
List<TypeParamInfo.Method> typeParams, boolean deprecated, Text deprecatedDesc) {
this.comment = comment;
this.name = name;
this.returnType = returnType;
this.returnDescription = returnDescription;
this.fluent = fluent;
this.cacheReturn = cacheReturn;
this.doc = doc;
this.staticMethod = staticMethod;
this.defaultMethod = defaultMethod;
this.params = params;
this.typeParams = typeParams;
this.ownerTypes = ownerTypes;
this.deprecated = deprecated;
this.deprecatedDesc = deprecatedDesc;
}
示例2
@Override
protected MethodInfo createMethodInfo(Set<ClassTypeInfo> ownerTypes, String methodName, String comment, Doc doc, TypeInfo returnType, Text returnDescription, boolean isFluent, boolean isCacheReturn, List<ParamInfo> mParams, ExecutableElement methodElt, boolean isStatic, boolean isDefault, ArrayList<TypeParamInfo.Method> typeParams, TypeElement declaringElt, boolean methodDeprecated, Text methodDeprecatedDesc) {
AnnotationMirror proxyIgnoreAnnotation = Helper.resolveMethodAnnotation(ProxyIgnore.class, elementUtils, typeUtils, declaringElt, methodElt);
boolean isProxyIgnore = proxyIgnoreAnnotation != null;
AnnotationMirror proxyCloseAnnotation = Helper.resolveMethodAnnotation(ProxyClose.class, elementUtils, typeUtils, declaringElt, methodElt);
boolean isProxyClose = proxyCloseAnnotation != null;
ProxyMethodInfo proxyMeth = new ProxyMethodInfo(ownerTypes, methodName, returnType, returnDescription,
isFluent, isCacheReturn, mParams, comment, doc, isStatic, isDefault, typeParams, isProxyIgnore,
isProxyClose, methodDeprecated, methodDeprecatedDesc);
if (isProxyClose && mParams.size() > 0) {
if (mParams.size() > 1) {
throw new GenException(this.modelElt, "@ProxyClose methods can't have more than one parameter");
}
if (proxyMeth.getKind() != MethodKind.FUTURE) {
throw new GenException(this.modelElt, "@ProxyClose parameter must be Handler<AsyncResult<Void>>");
}
TypeInfo type = mParams.get(0).getType();
TypeInfo arg = ((ParameterizedTypeInfo) ((ParameterizedTypeInfo) type).getArgs().get(0)).getArgs().get(0);
if (arg.getKind() != ClassKind.VOID) {
throw new GenException(this.modelElt, "@ProxyClose parameter must be " +
"Handler<AsyncResult<Void>> instead of " + type);
}
}
return proxyMeth;
}
示例3
@Override
protected MethodInfo createMethodInfo(Set<ClassTypeInfo> ownerTypes, String methodName, String comment, Doc doc, TypeInfo returnType, Text returnDescription, boolean isFluent, boolean isCacheReturn, List<ParamInfo> mParams, ExecutableElement methodElt, boolean isStatic, boolean isDefault, ArrayList<TypeParamInfo.Method> typeParams, TypeElement declaringElt, boolean methodDeprecated, Text deprecatedDesc) {
ProxyMethodInfo baseInfo = (ProxyMethodInfo) super.createMethodInfo(ownerTypes, methodName, comment, doc, returnType, returnDescription, isFluent, isCacheReturn, mParams, methodElt, isStatic, isDefault, typeParams, declaringElt, methodDeprecated, deprecatedDesc);
if (!isStatic && !baseInfo.isProxyClose()) {
// Check signature constraints
TypeInfo ret;
if (baseInfo.getKind() == MethodKind.FUTURE) {
ret = ((ParameterizedTypeInfo) ((ParameterizedTypeInfo) mParams.get(mParams.size() - 1).getType()).getArg(0)).getArg(0);
} else {
throw new GenException(methodElt, SIGNATURE_CONSTRAINT_ERROR);
}
if (!ServiceResponse.class.getName().equals(ret.getName())) {
throw new GenException(methodElt, SIGNATURE_CONSTRAINT_ERROR);
}
TypeInfo shouldBeServiceRequest;
if (baseInfo.getKind() == MethodKind.FUTURE) {
if (mParams.size() <= 1) {
throw new GenException(methodElt, SIGNATURE_CONSTRAINT_ERROR);
}
shouldBeServiceRequest = mParams.get(mParams.size() - 2).getType();
} else {
if (mParams.size() == 0) {
throw new GenException(methodElt, SIGNATURE_CONSTRAINT_ERROR);
}
shouldBeServiceRequest = mParams.get(mParams.size() - 1).getType();
}
if (!ServiceRequest.class.getName().equals(shouldBeServiceRequest.getName())) {
throw new GenException(methodElt, SIGNATURE_CONSTRAINT_ERROR);
}
return new WebApiProxyMethodInfo(baseInfo);
} else {
return baseInfo;
}
}
示例4
protected MethodInfo createMethodInfo(Set<ClassTypeInfo> ownerTypes, String methodName, String comment, Doc doc, TypeInfo returnType,
Text returnDescription,
boolean isFluent, boolean isCacheReturn, List<ParamInfo> mParams,
ExecutableElement methodElt, boolean isStatic, boolean isDefault, ArrayList<TypeParamInfo.Method> typeParams,
TypeElement declaringElt, boolean methodDeprecated, Text methodDeprecatedDesc) {
return new MethodInfo(ownerTypes, methodName, returnType, returnDescription,
isFluent, isCacheReturn, mParams, comment, doc, isStatic, isDefault, typeParams, methodDeprecated, methodDeprecatedDesc);
}
示例5
public PropertyInfo(boolean declared, String name, Doc doc, TypeInfo type, String setterMethod, String adderMethod, String getterMethod,
List<AnnotationValueInfo> annotations, PropertyKind kind, boolean jsonifiable, boolean deprecated, Text deprecatedDesc) {
this.kind = kind;
this.declared = declared;
this.name = name;
this.doc = doc;
this.type = type;
this.annotations = annotations.stream().collect(HashMap::new, (m, a) -> m.put(a.getName(), a), HashMap::putAll);
this.adderMethod = adderMethod;
this.setterMethod = setterMethod;
this.getterMethod = getterMethod;
this.jsonifiable = jsonifiable;
this.deprecated = deprecated;
this.deprecatedDesc = deprecatedDesc;
}
示例6
public ParamInfo(int index, String name, Text description, TypeInfo type, TypeInfo unresolvedType) {
this.index = index;
this.name = name;
this.description = description;
this.type = type;
this.unresolvedType = unresolvedType;
}
示例7
public ProxyMethodInfo(Set<ClassTypeInfo> ownerTypes, String name, TypeInfo returnType, Text returnDescription, boolean fluent,
boolean cacheReturn, List<ParamInfo> params, String comment, Doc doc, boolean staticMethod, boolean defaultMethod,
List<TypeParamInfo.Method> typeParams, boolean proxyIgnore, boolean proxyClose, boolean deprecated, Text deprecatedDesc) {
super(ownerTypes, name, returnType, returnDescription, fluent, cacheReturn, params, comment, doc, staticMethod, defaultMethod, typeParams, deprecated, deprecatedDesc);
this.proxyIgnore = proxyIgnore;
this.proxyClose = proxyClose;
}
示例8
public WebApiProxyMethodInfo(Set<ClassTypeInfo> ownerTypes, String name, TypeInfo returnType, Text returnDescription, boolean fluent, boolean cacheReturn, List<ParamInfo> params, String comment, Doc doc, boolean staticMethod, boolean defaultMethod, List<TypeParamInfo.Method> typeParams, boolean proxyIgnore, boolean proxyClose, boolean deprecated, Text deprecatedDesc) {
super(ownerTypes, name, returnType, returnDescription, fluent, cacheReturn, params, comment, doc, staticMethod, defaultMethod, typeParams, proxyIgnore, proxyClose, deprecated, deprecatedDesc);
paramsToExtract = params.subList(0, params.size() - 2);
requestContextName = params.get(params.size() - 2).getName();
}
示例9
public EnumValueInfo(String identifier, Doc doc, boolean deprecated, Text deprecatedDesc) {
this.identifier = identifier;
this.doc = doc;
this.deprecated = deprecated;
this.deprecatedDesc = deprecatedDesc;
}
示例10
/**
* @return the description of deprecated
*/
public Text getDeprecatedDesc() {
return deprecatedDesc;
}
示例11
/**
* @return the description of deprecated
*/
public Text getDeprecatedDesc() {
return deprecatedDesc;
}
示例12
private void traverse() {
DataObject ann = modelElt.getAnnotation(DataObject.class);
this.generateConverter = ann.generateConverter();
this.publicConverter = ann.publicConverter();
this.inheritConverter = ann.inheritConverter();
this.isClass = modelElt.getKind() == ElementKind.CLASS;
this.concrete = isClass && !modelElt.getModifiers().contains(Modifier.ABSTRACT);
try {
this.type = (ClassTypeInfo) typeFactory.create(modelElt.asType());
} catch (ClassCastException e) {
throw new GenException(modelElt, "Data object must be a plain java class with no type parameters");
}
Helper.checkUnderModule(this, "@VertxGen");
doc = docFactory.createDoc(modelElt);
if (doc != null)
doc.getBlockTags().stream().filter(tag -> tag.getName().equals("deprecated")).findFirst().ifPresent(tag ->
deprecatedDesc = new Text(Helper.normalizeWhitespaces(tag.getValue())).map(Token.tagMapper(elementUtils, typeUtils, modelElt))
);
if (getModule() == null) {
throw new GenException(modelElt, "Data object must have an ancestor package annotated with @ModuleGen");
}
modelElt.getInterfaces().stream()
.filter(superTM -> superTM instanceof DeclaredType && ((DeclaredType) superTM).asElement().getAnnotation(DataObject.class) != null)
.map(e -> (ClassTypeInfo) typeFactory.create(e)).forEach(abstractSuperTypes::add);
superTypes.addAll(abstractSuperTypes);
TypeMirror superClass = modelElt.getSuperclass();
if (superClass instanceof DeclaredType && ((DeclaredType) superClass).asElement().getAnnotation(DataObject.class) != null) {
superType = (ClassTypeInfo) typeFactory.create(superClass);
superTypes.add(superType);
}
List<ExecutableElement> methodsElt = new ArrayList<>();
for (Element enclosedElt : elementUtils.getAllMembers(modelElt)) {
switch (enclosedElt.getKind()) {
case CONSTRUCTOR:
ExecutableElement constrElt = (ExecutableElement) enclosedElt;
processConstructor(constrElt);
break;
case METHOD: {
ExecutableElement methodElt = (ExecutableElement) enclosedElt;
if (methodElt.getSimpleName().toString().equals("toJson") &&
methodElt.getParameters().isEmpty() &&
typeFactory.create(methodElt.getReturnType()).getKind() == ClassKind.JSON_OBJECT) {
hasToJsonMethod = true;
}
if (methodElt.getSimpleName().contentEquals("decode") &&
methodElt.getModifiers().containsAll(Arrays.asList(Modifier.STATIC, Modifier.PUBLIC)) &&
methodElt.getParameters().size() == 1 &&
typeFactory.create(methodElt.getParameters().get(0).asType()).getKind() == ClassKind.JSON_OBJECT &&
typeUtils.isSameType(methodElt.getReturnType(), this.modelElt.asType())) {
hasDecodeStaticMethod = true;
}
if (methodElt.getAnnotation(GenIgnore.class) == null) {
methodsElt.add(methodElt);
}
break;
}
}
}
processMethods(methodsElt);
// Sort the properties so we do have a consistent order
ArrayList<PropertyInfo> props = new ArrayList<>(propertyMap.values());
Collections.sort(props, (p1, p2) -> p1.name.compareTo(p2.name));
propertyMap.clear();
props.forEach(prop -> propertyMap.put(prop.name, prop));
}
示例13
/**
* @return the description of deprecated
*/
public Text getDeprecatedDesc() {
return deprecatedDesc;
}
示例14
public Text getReturnDescription() {
return returnDescription;
}
示例15
public MethodInfo setReturnDescription(Text returnDescription) {
this.returnDescription = returnDescription;
return this;
}
示例16
/**
* @return the description of deprecated
*/
public Text getDeprecatedDesc() {
return deprecatedDesc;
}
示例17
public MethodInfo setDeprecatedDesc(Text deprecatedDesc) {
this.deprecatedDesc = deprecatedDesc;
return this;
}
示例18
/**
* @return the description of deprecated
*/
public Text getDeprecatedDesc() {
return deprecatedDesc;
}
示例19
/**
* @return the description of deprecated
*/
public Text getDeprecatedDesc() {
return deprecatedDesc;
}
示例20
public ParamInfo(int index, String name, Text description, TypeInfo type) {
this(index, name, description, type, null);
}
示例21
public Text getDescription() {
return description;
}