本文整理汇总了Java中japa.parser.ast.expr.NormalAnnotationExpr类的典型用法代码示例。如果您正苦于以下问题:Java NormalAnnotationExpr类的具体用法?Java NormalAnnotationExpr怎么用?Java NormalAnnotationExpr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NormalAnnotationExpr类属于japa.parser.ast.expr包,在下文中一共展示了NormalAnnotationExpr类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: visit
import japa.parser.ast.expr.NormalAnnotationExpr; //导入依赖的package包/类
@Override
public void visit(MethodDeclaration method, A result) {
if (CollectionUtils.isEmpty(method.getAnnotations())) {
return;
}
for (AnnotationExpr annotation : method.getAnnotations()) {
if (!annotation.getClass().equals(NormalAnnotationExpr.class)) {
continue;
}
NormalAnnotationExpr annot = (NormalAnnotationExpr) annotation;
if (annot.getName().toString().equals(SampleCode.class.getSimpleName())
&& !CollectionUtils.isEmpty(annot.getPairs())) {
for (MemberValuePair pair : annot.getPairs()) {
// get the 'api' parameter from the annotation to let us know which api this function belongs to
if (StringUtils.equals(pair.getName(), "api") && !StringUtils.isBlank(pair.getValue().toString())) {
result.put(getCacheRowKey(type, pair.getValue().toString().replace("\"", "")), stripTestPrefix(method.getName()),
stripCurlyBrackets(method.getBody().toString()));
return;
}
}
}
}
}
开发者ID:RapturePlatform,项目名称:Rapture,代码行数:24,代码来源:SampleCodeParser.java
示例2: getAnnotationNodes
import japa.parser.ast.expr.NormalAnnotationExpr; //导入依赖的package包/类
@Override
protected NodeData getAnnotationNodes(String enclosingClass, String fieldName, String mappedClass) {
final FieldDescriptor fd = OjbUtil.findFieldDescriptor(mappedClass, fieldName, descriptorRepositories);
if (fd != null) {
final Class<?> fc = ResolverUtil.getType(enclosingClass, fieldName);
if (isEnum(fc)) {
final Comment fixme = new BlockComment("\nFIXME:\n" +
"Enums must be annotated with the @Enumerated annotation.\n " +
"The @Enumerated annotation should set the EnumType.\n" +
"If the EnumType is not set, then the Enumerated annotation is defaulted to EnumType.ORDINAL.\n" +
"This conversion program cannot tell whether EnumType.ORDINAL is the appropriate EnumType.");
AnnotationExpr enumerated = new NormalAnnotationExpr(new NameExpr(SIMPLE_NAME), Collections.singletonList(new MemberValuePair("value", new NameExpr("EnumType."))));
enumerated.setComment(fixme);
return new NodeData(enumerated, new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false),
Collections.singletonList(new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), "TemporalType"), false, false)));
}
}
return null;
}
开发者ID:kuali,项目名称:kc-rice,代码行数:22,代码来源:EnumeratedResolver.java
示例3: getAnnotationNodes
import japa.parser.ast.expr.NormalAnnotationExpr; //导入依赖的package包/类
@Override
protected NodeData getAnnotationNodes(String enclosingClass, String fieldName, String mappedClass) {
final FieldDescriptor fd = OjbUtil.findFieldDescriptor(mappedClass, fieldName, descriptorRepositories);
if (fd != null) {
final boolean autoInc = fd.isAutoIncrement();
final String seqName = fd.getSequenceName();
if (autoInc && StringUtils.isBlank(seqName)) {
LOG.error(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " field has autoincrement set to true but sequenceName is blank.");
}
if (!autoInc && StringUtils.isNotBlank(seqName)) {
LOG.error(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " field has autoincrement set to false but sequenceName is " + seqName + ".");
}
if (autoInc || StringUtils.isNotBlank(seqName)) {
return new NodeData(new NormalAnnotationExpr(new NameExpr(SIMPLE_NAME), Collections.singletonList(new MemberValuePair("name", new StringLiteralExpr(upperCaseTableName ? seqName.toUpperCase() : seqName)))),
new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false));
}
}
return null;
}
开发者ID:kuali,项目名称:kc-rice,代码行数:22,代码来源:PortableSequenceGeneratorResolver.java
示例4: createJoinColumn
import japa.parser.ast.expr.NormalAnnotationExpr; //导入依赖的package包/类
private AnnotationExpr createJoinColumn(FieldDescriptor thisField, FieldDescriptor itemField) {
final List<MemberValuePair> pairs = new ArrayList<MemberValuePair>();
pairs.add(new MemberValuePair("name", new StringLiteralExpr(thisField.getColumnName())));
pairs.add(new MemberValuePair("referencedColumnName", new StringLiteralExpr(itemField.getColumnName())));
if (!isAnonymousFk(thisField)) {
pairs.add(new MemberValuePair("insertable", new BooleanLiteralExpr(false)));
pairs.add(new MemberValuePair("updatable", new BooleanLiteralExpr(false)));
}
// Per this page: https://forums.oracle.com/message/3923913
// the nullable attribute is a hint to the DDL generation, especially on fields like this.
// Commenting this flag out for now as it's just "noise" in the annotation definitions
// if (!isNullableFk(thisField)) {
// pairs.add(new MemberValuePair("nullable", new BooleanLiteralExpr(false)));
// }
return new NormalAnnotationExpr(new NameExpr("JoinColumn"), pairs);
}
开发者ID:kuali,项目名称:kc-rice,代码行数:19,代码来源:AbstractJoinColumnResolver.java
示例5: getAnnotationNodes
import japa.parser.ast.expr.NormalAnnotationExpr; //导入依赖的package包/类
@Override
protected NodeData getAnnotationNodes(String enclosingClass, String fieldName, String mappedClass) {
final FieldDescriptor fd = OjbUtil.findFieldDescriptor(mappedClass, fieldName, descriptorRepositories);
if (fd != null) {
final boolean autoInc = fd.isAutoIncrement();
final String seqName = fd.getSequenceName();
if (autoInc && StringUtils.isBlank(seqName)) {
LOG.error(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " field has autoincrement set to true but sequenceName is blank.");
}
if (!autoInc && StringUtils.isNotBlank(seqName)) {
LOG.error(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " field has autoincrement set to false but sequenceName is " + seqName + ".");
}
if (autoInc || StringUtils.isNotBlank(seqName)) {
return new NodeData(new NormalAnnotationExpr(new NameExpr(SIMPLE_NAME), Collections.singletonList(new MemberValuePair("generator", new StringLiteralExpr(upperCaseTableName ? seqName.toUpperCase() : seqName)))),
new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false));
}
}
return null;
}
开发者ID:kuali,项目名称:kc-rice,代码行数:22,代码来源:GeneratedValueResolver.java
示例6: resolve
import japa.parser.ast.expr.NormalAnnotationExpr; //导入依赖的package包/类
@Override
public NodeData resolve(Node node, String mappedClass) {
if (!(node instanceof ClassOrInterfaceDeclaration)) {
throw new IllegalArgumentException("this annotation belongs only on ClassOrInterfaceDeclaration");
}
final TypeDeclaration dclr = (TypeDeclaration) node;
if (!(dclr.getParentNode() instanceof CompilationUnit)) {
//handling nested classes
return null;
}
final String name = dclr.getName();
final String pckg = ((CompilationUnit) dclr.getParentNode()).getPackage().getName().toString();
final String enclosingClass = pckg + "." + name;
final ClassDescriptor cd = OjbUtil.findClassDescriptor(enclosingClass, descriptorRepositories);
if (cd != null) {
final String tableName = getMappedTable(enclosingClass);
if (tableName == null) {
LOG.error(ResolverUtil.logMsgForClass(enclosingClass, mappedClass) + " table could not be found");
return null;
}
return new NodeData(new NormalAnnotationExpr(new NameExpr(SIMPLE_NAME), Collections.singletonList(new MemberValuePair("name", new StringLiteralExpr(upperCaseTableName ? tableName.toUpperCase() : tableName)))),
new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false));
}
return null;
}
开发者ID:kuali,项目名称:kc-rice,代码行数:29,代码来源:TableResolver.java
示例7: getAnnotationNodes
import japa.parser.ast.expr.NormalAnnotationExpr; //导入依赖的package包/类
/** gets the annotation but also adds an import in the process if a Convert annotation is required. */
@Override
protected NodeData getAnnotationNodes(String enclosingClass, String fieldName, String mappedClass) {
final FieldDescriptor fd = OjbUtil.findFieldDescriptor(mappedClass, fieldName, descriptorRepositories);
if (fd != null) {
final FieldConversion fc = fd.getFieldConversion();
//in ojb all columns have at least the default field conversion
if (fc != null && FieldConversionDefaultImpl.class != fc.getClass()) {
LOG.info(enclosingClass + "." + fieldName + " for the mapped class " + mappedClass + " field has a converter " + fc.getClass().getName());
final String jpaConverter = getJpaConverterForOjbClass(fc.getClass().getName());
if (jpaConverter == null) {
LOG.error(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " field has a converter " + fc.getClass().getName()
+ " but a replacement converter was not configured, unable to set Convert class");
return new NodeData(new NormalAnnotationExpr(new NameExpr(SIMPLE_NAME), Collections.singletonList(new MemberValuePair("converter", new NameExpr(null)))),
new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false));
} else if ( StringUtils.isBlank(jpaConverter) ) {
LOG.info(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " field has a converter " + fc.getClass().getName()
+ " But no converter definition is needed due to default converter configuration." );
} else {
final String shortClassName = ClassUtils.getShortClassName(jpaConverter);
final String packageName = ClassUtils.getPackageName(jpaConverter);
return new NodeData(new NormalAnnotationExpr(new NameExpr(SIMPLE_NAME), Collections.singletonList(new MemberValuePair("converter", new NameExpr(shortClassName + ".class")))),
new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false),
Collections.singletonList(new ImportDeclaration(new QualifiedNameExpr(new NameExpr(packageName), shortClassName), false, false)));
}
}
}
return null;
}
开发者ID:kuali,项目名称:kc-rice,代码行数:32,代码来源:ConvertResolver.java
示例8: visit
import japa.parser.ast.expr.NormalAnnotationExpr; //导入依赖的package包/类
public R visit(NormalAnnotationExpr n, A arg) {
n.getName().accept(this, arg);
if (n.getPairs() != null) {
for (MemberValuePair m : n.getPairs()) {
m.accept(this, arg);
}
}
return null;
}
开发者ID:rfw,项目名称:genja,代码行数:10,代码来源:GenericVisitorAdapter.java
示例9: visit
import japa.parser.ast.expr.NormalAnnotationExpr; //导入依赖的package包/类
public Boolean visit(NormalAnnotationExpr n1, Node arg) {
NormalAnnotationExpr n2 = (NormalAnnotationExpr) arg;
if (!nodeEquals(n1.getName(), n2.getName())) {
return Boolean.FALSE;
}
if (!nodesEquals(n1.getPairs(), n2.getPairs())) {
return Boolean.FALSE;
}
return Boolean.TRUE;
}
开发者ID:rfw,项目名称:genja,代码行数:14,代码来源:EqualsVisitor.java
示例10: visit
import japa.parser.ast.expr.NormalAnnotationExpr; //导入依赖的package包/类
public void visit(NormalAnnotationExpr n, Object arg) {
printer.print("@");
n.getName().accept(this, arg);
printer.print("(");
if (n.getPairs() != null) {
for (Iterator<MemberValuePair> i = n.getPairs().iterator(); i.hasNext();) {
MemberValuePair m = i.next();
m.accept(this, arg);
if (i.hasNext()) {
printer.print(", ");
}
}
}
printer.print(")");
}
开发者ID:rfw,项目名称:genja,代码行数:16,代码来源:DumpVisitor.java
示例11: visit
import japa.parser.ast.expr.NormalAnnotationExpr; //导入依赖的package包/类
public void visit(NormalAnnotationExpr n, A arg) {
n.getName().accept(this, arg);
if (n.getPairs() != null) {
for (MemberValuePair m : n.getPairs()) {
m.accept(this, arg);
}
}
}
开发者ID:rfw,项目名称:genja,代码行数:9,代码来源:VoidVisitorAdapter.java
示例12: visit
import japa.parser.ast.expr.NormalAnnotationExpr; //导入依赖的package包/类
public Node visit(NormalAnnotationExpr n, A arg) {
n.setName((NameExpr) n.getName().accept(this, arg));
List<MemberValuePair> pairs = n.getPairs();
if (pairs != null) {
for (int i = 0; i < pairs.size(); i++) {
pairs.set(i, (MemberValuePair) pairs.get(i).accept(this, arg));
}
removeNulls(pairs);
}
return n;
}
开发者ID:rfw,项目名称:genja,代码行数:12,代码来源:ModifierVisitorAdapter.java
示例13: overwriteNormalAnnotation
import japa.parser.ast.expr.NormalAnnotationExpr; //导入依赖的package包/类
public static NormalAnnotationExpr overwriteNormalAnnotation(String aName, List<MemberValuePair> aValues,
BodyDeclaration aDeclaration) {
removeAnnotationFrom(aName, aDeclaration);
return addNormalAnnotationTo(aName, aValues, aDeclaration);
}
开发者ID:mirkosertic,项目名称:ERDesignerNG,代码行数:6,代码来源:OpenXavaASTHelper.java
示例14: getAnnotationNodes
import japa.parser.ast.expr.NormalAnnotationExpr; //导入依赖的package包/类
@Override
protected NodeData getAnnotationNodes(String enclosingClass, String fieldName, String mappedClass) {
final FieldDescriptor fd = OjbUtil.findFieldDescriptor(mappedClass, fieldName, descriptorRepositories);
if (fd != null) {
List<MemberValuePair> pairs = new ArrayList<MemberValuePair>();
final String access = fd.getAccess();
if ("readonly".equals(access)) {
pairs.add(new MemberValuePair("insertable", new BooleanLiteralExpr(false)));
pairs.add(new MemberValuePair("updatable", new BooleanLiteralExpr(false)));
} else if ("readwrite".equals(access)) {
LOG.debug(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " field access is readwrite keeping @Column attributes (insertable, updatable) at defaults");
} else if ("anonymous".equals(access)) {
LOG.error(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " field access is anonymous, the field should not exist in the java class as is the meaning anonymous access");
} else if (access == null) {
LOG.debug(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " field access is null keeping @Column attributes (insertable, updatable) at defaults");
} else {
LOG.error(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " field access is " + access + ", unsupported conversion to @Column attributes");
}
final String columnName = fd.getColumnName();
if (StringUtils.isNotBlank(columnName)) {
pairs.add(new MemberValuePair("name", new StringLiteralExpr(upperCaseTableName ? columnName.toUpperCase() : columnName)));
} else {
LOG.error(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " field column is blank");
}
/* don't bother with column type attribute...this is mostly taken care of automatically by JPA
final String columnType = fd.getColumnType();
if (StringUtils.isNotBlank(columnType)) {
LOG.error(enclosingClass + "." + fieldName + " for the mapped class " + mappedClass + " field column type is " + columnType + ", unsupported conversion to @Column attributes");
}
*/
final boolean required = fd.isRequired();
if (required) {
pairs.add(new MemberValuePair("nullable", new BooleanLiteralExpr(false)));
} else {
LOG.debug(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " field is nullable keeping @Column attribute (nullable) at default");
}
final int length = fd.getLength();
if (length > 0) {
pairs.add(new MemberValuePair("length", new IntegerLiteralExpr(String.valueOf(length))));
} else {
LOG.debug(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " field length is not set keeping @Column attribute (length) at default");
}
final int precision = fd.getPrecision();
if (precision > 0) {
pairs.add(new MemberValuePair("precision", new IntegerLiteralExpr(String.valueOf(precision))));
} else {
LOG.debug(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " field precision is not set keeping @Column attribute (precision) at default");
}
final int scale = fd.getScale();
if (scale > 0) {
pairs.add(new MemberValuePair("scale", new IntegerLiteralExpr(String.valueOf(scale))));
} else {
LOG.debug(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " field scale is not set keeping @Column attribute (scale) at default");
}
return new NodeData(new NormalAnnotationExpr(new NameExpr(SIMPLE_NAME), pairs),
new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false));
}
return null;
}
开发者ID:kuali,项目名称:kc-rice,代码行数:65,代码来源:ColumnResolver.java
示例15: getJoinColumns
import japa.parser.ast.expr.NormalAnnotationExpr; //导入依赖的package包/类
protected final List<Expression> getJoinColumns(String enclosingClass, String fieldName, String mappedClass) {
final ObjectReferenceDescriptor ord = OjbUtil.findObjectReferenceDescriptor(mappedClass, fieldName,
descriptorRepositories);
final List<Expression> joinColumns = new ArrayList<Expression>();
if (foundDescriptor(ord)) {
final Collection<String> fks = getForeignKeys(ord);
if (fks == null || fks.isEmpty()) {
LOG.error(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " field has a reference descriptor for " + fieldName
+ " but does not have any foreign keys configured");
return null;
}
final Collection<String> pks = OjbUtil.getPrimaryKeyNames(mappedClass, descriptorRepositories);
if (pks.size() == fks.size() && pks.containsAll(fks) && !pks.isEmpty()) {
final ClassDescriptor cd = OjbUtil.findClassDescriptor(mappedClass, descriptorRepositories);
final ClassDescriptor icd;
final String itemClassName = getItemClass(ord);
if (StringUtils.isBlank(itemClassName)) {
LOG.error(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " field has a reference descriptor for " + fieldName
+ " but does not class name attribute");
return null;
} else {
icd = OjbUtil.findClassDescriptor(itemClassName, descriptorRepositories);
}
final FieldDescriptor[] pfds = cd.getPkFields();
final FieldDescriptor[] ipfds = icd.getPkFields();
for (int i = 0; i < pfds.length; i++) {
final List<MemberValuePair> pairs = new ArrayList<MemberValuePair>();
pairs.add(new MemberValuePair("name", new StringLiteralExpr(pfds[i].getColumnName())));
pairs.add(new MemberValuePair("referencedColumnName", new StringLiteralExpr(ipfds[i].getColumnName())));
joinColumns.add(new NormalAnnotationExpr(new NameExpr("PrimaryKeyJoinColumn"), pairs));
}
if (isCascadeDelete(ord)) {
LOG.error(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " field has a reference descriptor set to cascade delete but JPA does not support that configuration with primary key join columns.");
}
if (isCascadePersist(ord)) {
LOG.error(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " field has a reference descriptor set to cascade persist but JPA does not support that configuration with primary key join columns.");
}
}
}
return joinColumns;
}
开发者ID:kuali,项目名称:kc-rice,代码行数:50,代码来源:AbstractPrimaryKeyJoinColumnResolver.java
示例16: visit
import japa.parser.ast.expr.NormalAnnotationExpr; //导入依赖的package包/类
@Override
public void visit(NormalAnnotationExpr n, Generator arg) {
throw new TransformException("don't know how to linearize");
}
开发者ID:rfw,项目名称:genja,代码行数:5,代码来源:LinearizeTransform.java
示例17: visit
import japa.parser.ast.expr.NormalAnnotationExpr; //导入依赖的package包/类
@Override
public Boolean visit(NormalAnnotationExpr n, Void arg) {
return false;
}
开发者ID:rfw,项目名称:genja,代码行数:5,代码来源:NodeAnnotator.java
示例18: visit
import japa.parser.ast.expr.NormalAnnotationExpr; //导入依赖的package包/类
@Override
public void visit(NormalAnnotationExpr n, Scope arg) {
super.visit(n, arg);
n.setData(arg);
}
开发者ID:rfw,项目名称:genja,代码行数:6,代码来源:ScopeCollector.java
示例19: visit
import japa.parser.ast.expr.NormalAnnotationExpr; //导入依赖的package包/类
@Override
public void visit(NormalAnnotationExpr n, Object arg) {
doTest(source, n);
super.visit(n, arg);
}
开发者ID:rfw,项目名称:genja,代码行数:6,代码来源:TestNodePositions.java
示例20: visitPre
import japa.parser.ast.expr.NormalAnnotationExpr; //导入依赖的package包/类
@Override
public void visitPre(NormalAnnotationExpr n, A arg) {
}
开发者ID:kuali,项目名称:kc-rice,代码行数:5,代码来源:VoidVisitorHelperBase.java
注:本文中的japa.parser.ast.expr.NormalAnnotationExpr类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论