本文整理汇总了Java中com.helger.jcodemodel.JDefinedClass._extends方法的典型用法代码示例。如果您正苦于以下问题:Java JDefinedClass._extends方法的具体用法?Java JDefinedClass._extends怎么用?Java JDefinedClass._extends使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.helger.jcodemodel.JDefinedClass
的用法示例。
在下文中一共展示了JDefinedClass._extends方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitService_def
import com.helger.jcodemodel.JDefinedClass; //导入方法依赖的package包/类
@Override
public Void visitService_def(Service_defContext ctx) {
try {
String name = ctx.service_name().IDENTIFIER().getText();
ProtoContext pkgCtx = (ProtoContext) ctx.getParent();
String pkg = pkgCtx.package_def().package_name().QUALIFIED_IDENTIFIER().getText();
JPackage jPackage = codeModel._package( pkg );
JDefinedClass i = jPackage._interface( name );
JDefinedClass container = jPackage._getClass( containerName );
if ( ctx.service_parent() != null && ctx.service_parent().service_parent_message() != null ) {
All_identifiersContext parent = ctx.service_parent().service_parent_message().all_identifiers();
i._extends( resolveType( container, parent ) );
}
addDenifition( container, i );
logger.info( "Interface({}.{})", i._package().name(), i.name() );
return super.visitService_def( ctx );
}
catch ( JClassAlreadyExistsException err ) {
throw new RuntimeException( err );
}
}
示例2: generate
import com.helger.jcodemodel.JDefinedClass; //导入方法依赖的package包/类
@Override
@SneakyThrows
public JCodeModel generate() {
final JDefinedClass c = camundaRestService.getDefinedClass();
// class information
c._extends(camundaRestService.getServiceImplClass());
c.annotate(codeModel.ref(Path.class)).param("value", camundaRestService.getPath());
final String tags = TagRespository.lookup(camundaRestService);
camundaRestService.getRestService().setPath(camundaRestService.getPath());
camundaRestService.getRestService().setTags(tags);
camundaRestService.getRestService().setDescription(camundaRestService.getName());
c.annotate(codeModel.ref(Api.class)).param("value", camundaRestService.getName()).param("tags", tags);
// generate constructor
for (final Constructor<?> constructor : camundaRestService.getServiceImplClass().getConstructors()) {
new InvocationStep(c.constructor(constructor.getModifiers())).constructor(constructor);
}
// construct return type information
final Map<Method, ReturnTypeInfo> returnTypes = Arrays.stream(camundaRestService.getServiceInterfaceClass().getDeclaredMethods()) // iterate over interface
// methods
.map(m -> new ReturnTypeInfo(camundaRestService.getModelRepository(), codeModel, m)
.applyImplementationMethods(camundaRestService.getServiceImplClass().getDeclaredMethods())) // apply impl methods
.collect(Collectors.toMap(r -> r.getMethod(), r -> r)); // build the map
generateMethods(c, camundaRestService.getRestService(), returnTypes, NO_PREFIX);
return this.codeModel;
}
示例3: visitMessage_def
import com.helger.jcodemodel.JDefinedClass; //导入方法依赖的package包/类
@Override
public Void visitMessage_def(Message_defContext ctx) {
try {
boolean isError = ctx.messsage_type().ERROR_LITERAL() != null;
String name = ctx.message_name().IDENTIFIER().getText();
AbstractJClass parent = isError ? codeModel.ref( Exception.class ) : codeModel.ref( Object.class );
ProtoContext pkgCtx = (ProtoContext) ctx.getParent();
String pkg = pkgCtx.package_def().package_name().QUALIFIED_IDENTIFIER().getText();
JPackage jPackage = codeModel._package( pkg );
JDefinedClass m = jPackage._class( name );
JDefinedClass container = jPackage._getClass( containerName );
if ( ctx.message_parent() != null && ctx.message_parent().message_parent_message() != null ) {
All_identifiersContext parentCtx = ctx.message_parent().message_parent_message().all_identifiers();
parent = resolveType( container, parentCtx );
}
if ( parent != null ) {
m._extends( parent );
}
container.field( JMod.PUBLIC | JMod.FINAL | JMod.STATIC, m, name, JExpr._new( m ) );
addDenifition( container, m );
JAnnotationUse generated = m.annotate( Generated.class );
generated.param( "date", new Date().toString() );
generated.paramArray( JAnnotationUse.SPECIAL_KEY_VALUE ).param( Generator.class.getName() );
logger.info( "Message({}.{})", m._package().name(), m.name() );
return super.visitMessage_def( ctx );
}
catch ( JClassAlreadyExistsException err ) {
throw new RuntimeException( err );
}
}