本文整理匯總了Java中com.sun.codemodel.JDefinedClass._class方法的典型用法代碼示例。如果您正苦於以下問題:Java JDefinedClass._class方法的具體用法?Java JDefinedClass._class怎麽用?Java JDefinedClass._class使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.sun.codemodel.JDefinedClass
的用法示例。
在下文中一共展示了JDefinedClass._class方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: ClassGenerator
import com.sun.codemodel.JDefinedClass; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
ClassGenerator(CodeGenerator<T> codeGenerator, MappingSet mappingSet, SignatureHolder signature, EvaluationVisitor eval, JDefinedClass clazz, JCodeModel model) throws JClassAlreadyExistsException {
this.codeGenerator = codeGenerator;
this.clazz = clazz;
this.mappings = mappingSet;
this.sig = signature;
this.evaluationVisitor = eval;
this.model = model;
blocks = (LinkedList<JBlock>[]) new LinkedList[sig.size()];
for (int i =0; i < sig.size(); i++) {
blocks[i] = Lists.newLinkedList();
}
rotateBlock();
for (SignatureHolder child : signature.getChildHolders()) {
String innerClassName = child.getSignatureClass().getSimpleName();
JDefinedClass innerClazz = clazz._class(Modifier.FINAL + Modifier.PRIVATE, innerClassName);
innerClasses.put(innerClassName, new ClassGenerator<>(codeGenerator, mappingSet, child, eval, innerClazz, model));
}
}
示例2: buildTemplateConstraintValidator
import com.sun.codemodel.JDefinedClass; //導入方法依賴的package包/類
private JDefinedClass buildTemplateConstraintValidator(String name, JDefinedClass constraint, Class<?> param) {
try {
JClass cv = (JClass) codeModel._ref(ConstraintValidator.class);
cv = cv.narrow(constraint, (JClass) codeModel._ref(param));
JDefinedClass validator = constraint._class(JMod.STATIC | JMod.PUBLIC, name);
validator._implements(cv);
validator.method(JMod.PUBLIC, void.class, "initialize").param(constraint, "parameters");
JMethod isValid = validator.method(JMod.PUBLIC, boolean.class, "isValid");
isValid.param(Object.class, "value");
isValid.param(ConstraintValidatorContext.class, "context");
return validator;
} catch (JClassAlreadyExistsException e) {
throw new RuntimeException("Tried to create an already existing class: " + name, e);
}
}