org.jboss.errai.codegen.meta.MetaClass.getCanonicalName()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(13.4k)|赞(0)|评价(0)|浏览(76)

本文整理了Java中org.jboss.errai.codegen.meta.MetaClass.getCanonicalName()方法的一些代码示例,展示了MetaClass.getCanonicalName()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MetaClass.getCanonicalName()方法的具体详情如下:
包路径:org.jboss.errai.codegen.meta.MetaClass
类名称:MetaClass
方法名:getCanonicalName

MetaClass.getCanonicalName介绍

暂无

代码示例

代码示例来源:origin: org.jboss.errai/errai-navigation

private boolean containsNonBlacklistedPages(final Collection<MetaClass> pages) {
 for (final MetaClass page : pages) {
  if (!BLACKLISTED_PAGES.contains(page.getCanonicalName())) {
   return true;
  }
 }
 return false;
}

代码示例来源:origin: errai/errai

private boolean containsNonBlacklistedPages(final Collection<MetaClass> pages) {
 for (final MetaClass page : pages) {
  if (!BLACKLISTED_PAGES.contains(page.getCanonicalName())) {
   return true;
  }
 }
 return false;
}

代码示例来源:origin: errai/errai

private String getImportForClass(final MetaClass clazz) {
 checkThread();
 String imp = null;
 final String fqcn = clazz.getCanonicalName();
 final int idx = fqcn.lastIndexOf('.');
 if (idx != -1) {
  imp = fqcn.substring(0, idx);
 }
 return imp;
}

代码示例来源:origin: org.jboss.errai/errai-codegen

private String getImportForClass(final MetaClass clazz) {
 checkThread();
 String imp = null;
 final String fqcn = clazz.getCanonicalName();
 final int idx = fqcn.lastIndexOf('.');
 if (idx != -1) {
  imp = fqcn.substring(0, idx);
 }
 return imp;
}

代码示例来源:origin: org.jboss.errai/errai-codegen

public static String createCallSignature(final MetaMethod m) {
 final StringBuilder append = new StringBuilder(m.getName()).append(':');
 for (final MetaParameter parm : m.getParameters()) {
  append.append(parm.getType().getCanonicalName()).append(':');
 }
 return append.toString();
}

代码示例来源:origin: errai/errai

public static String createCallSignature(final MetaMethod m) {
 final StringBuilder append = new StringBuilder(m.getName()).append(':');
 for (final MetaParameter parm : m.getParameters()) {
  append.append(parm.getType().getCanonicalName()).append(':');
 }
 return append.toString();
}

代码示例来源:origin: org.jboss.errai/errai-codegen

private static String _getClassReference(final MetaType metaClass, final Context context, final boolean typeParms) {
 final MetaClass erased;
 if (metaClass instanceof MetaClass) {
  erased = ((MetaClass) metaClass).getErased();
 }
 else {
  return "Object";
 }
 String fqcn = erased.getCanonicalName();
 final int idx = fqcn.lastIndexOf('.');
 if (idx != -1) {
  if ((context.isAutoImportActive() || "java.lang".equals(erased.getPackageName()))
      && !context.hasImport(erased)) {
   context.addImport(erased);
  }
  if (context.hasImport(erased)) {
   fqcn = fqcn.substring(idx + 1);
  }
 }
 final StringBuilder buf = new StringBuilder(fqcn);
 if (typeParms) {
  buf.append(getClassReferencesForParameterizedTypes(((MetaClass) metaClass).getParameterizedType(), context));
 }
 return buf.toString();
}

代码示例来源:origin: errai/errai

private static String _getClassReference(final MetaType metaClass, final Context context, final boolean typeParms) {
 final MetaClass erased;
 if (metaClass instanceof MetaClass) {
  erased = ((MetaClass) metaClass).getErased();
 }
 else {
  return "Object";
 }
 String fqcn = erased.getCanonicalName();
 final int idx = fqcn.lastIndexOf('.');
 if (idx != -1) {
  if ((context.isAutoImportActive() || "java.lang".equals(erased.getPackageName()))
      && !context.hasImport(erased)) {
   context.addImport(erased);
  }
  if (context.hasImport(erased)) {
   fqcn = fqcn.substring(idx + 1);
  }
 }
 final StringBuilder buf = new StringBuilder(fqcn);
 if (typeParms) {
  buf.append(getClassReferencesForParameterizedTypes(((MetaClass) metaClass).getParameterizedType(), context));
 }
 return buf.toString();
}

代码示例来源:origin: errai/errai

@Test
public void testGetFields() {
 final List<String> expectedFields = Lists.newLinkedList();
 expectedFields.add(Child.class.getCanonicalName() + "." + "childPublic");
 expectedFields.add(Parent.class.getCanonicalName() + "." + "parentPublic");
 final ArrayList<String> actualFields = new ArrayList<>();
 for (final MetaField field : getMetaClass(Child.class).getFields()) {
  actualFields.add(field.getDeclaringClass().getCanonicalName() + "." + field.getName());
 }
 Collections.sort(expectedFields);
 Collections.sort(actualFields);
 assertEquals(expectedFields.toString(), actualFields.toString());
}

代码示例来源:origin: errai/errai

@Test
public void testGetDeclaredFields() {
 final List<String> expectedFields = Lists.newLinkedList();
 expectedFields.add(Child.class.getCanonicalName() + "." + "childPrivate");
 expectedFields.add(Child.class.getCanonicalName() + "." + "childPackage");
 expectedFields.add(Child.class.getCanonicalName() + "." + "childProtected");
 expectedFields.add(Child.class.getCanonicalName() + "." + "childPublic");
 final ArrayList<String> actualFields = new ArrayList<>();
 for (final MetaField field : getMetaClass(Child.class).getDeclaredFields()) {
  actualFields.add(field.getDeclaringClass().getCanonicalName() + "." + field.getName());
 }
 Collections.sort(expectedFields);
 Collections.sort(actualFields);
 assertEquals(expectedFields.toString(), actualFields.toString());
}

代码示例来源:origin: errai/errai

@Test
public void testNamingMethods() throws Exception {
 final MetaClass child = getMetaClass(Child.class);
 assertEquals(Child.class.getSimpleName(), child.getName());
 assertEquals(Child.class.getName(), child.getFullyQualifiedName());
 assertEquals(Child.class.getName(), child.getCanonicalName());
 assertEquals("L" + Child.class.getName().replace('.', '/') + ";", child.getInternalName());
}

代码示例来源:origin: errai/errai

@Test
 public void testGetDeclaredFields() {
  final ClassStructureBuilder<?> classBuilder = ClassBuilder
    .define("Child", Parent.class)
    .publicScope()
    .body()
    .privateField("childPrivate", int.class).finish()
    .packageField("childPackage", int.class).finish()
    .protectedField("childProtected", int.class).finish()
    .publicField("childPublic", int.class).finish();
  final MetaClass child = classBuilder.getClassDefinition();
  final ArrayList<String> fields = new ArrayList<String>();
  for (MetaField field : child.getDeclaredFields()) {
   fields.add(field.getDeclaringClass().getCanonicalName() + "." + field.getName());
  }

  final List<String> expectedFields = Lists.newLinkedList();
  expectedFields.add(child.getCanonicalName() + "." + "childPrivate");
  expectedFields.add(child.getCanonicalName() + "." + "childPackage");
  expectedFields.add(child.getCanonicalName() + "." + "childProtected");
  expectedFields.add(child.getCanonicalName() + "." + "childPublic");

  Collections.sort(fields);
  Collections.sort(expectedFields);

  assertEquals(expectedFields.toString(), fields.toString());
 }
}

代码示例来源:origin: errai/errai

@Test
public void testGetFields() {
 final ClassStructureBuilder<?> classBuilder = ClassBuilder
   .define("Child", Parent.class)
   .publicScope()
   .body()
   .privateField("childPrivate", int.class).finish()
   .packageField("childPackage", int.class).finish()
   .protectedField("childProtected", int.class).finish()
   .publicField("childPublic", int.class).finish();
 final MetaClass child = classBuilder.getClassDefinition();
 final ArrayList<String> fields = new ArrayList<String>();
 for (MetaField field : child.getFields()) {
  fields.add(field.getDeclaringClass().getCanonicalName() + "." + field.getName());
 }
 final List<String> expectedFields = Lists.newLinkedList();
 expectedFields.add(child.getCanonicalName() + "." + "childPublic");
 expectedFields.add(Parent.class.getCanonicalName() + "." + "parentPublic");
 Collections.sort(fields);
 Collections.sort(expectedFields);
 assertEquals(expectedFields.toString(), fields.toString());
}

代码示例来源:origin: org.jboss.errai/errai-codegen-gwt

@Override
public void makeMethodAccessible(final ClassStructureBuilder<?> classBuilder,
                 final MetaMethod method,
                 final Modifier[] modifiers) {
 final MetaMethod erasedMethod = method.getDeclaringClass().getErased().getDeclaredMethod(method.getName(),
     getErasedParamterTypes(method));
 final List<Parameter> wrapperDefParms = new ArrayList<Parameter>();
 if (!erasedMethod.isStatic()) {
  wrapperDefParms.add(Parameter.of(erasedMethod.getDeclaringClass().getErased(), "instance"));
 }
 final List<Parameter> methodDefParms = DefParameters.from(erasedMethod).getParameters();
 wrapperDefParms.addAll(methodDefParms);
 Annotation[] annotations = NO_ANNOTATIONS;
 for (MetaParameter p : erasedMethod.getParameters()) {
  if (p.getType().getCanonicalName().equals("long")) {
   annotations = new Annotation[] { UNSAFE_NATIVE_LONG_ANNOTATION };
  }
 }
 if (erasedMethod.getReturnType().getCanonicalName().equals("long")) {
  annotations = new Annotation[] { UNSAFE_NATIVE_LONG_ANNOTATION };
 }
 classBuilder.publicMethod(erasedMethod.getReturnType(), PrivateAccessUtil.getPrivateMethodName(method))
     .annotatedWith(annotations)
     .parameters(DefParameters.fromParameters(wrapperDefParms))
     .modifiers(appendJsni(modifiers))
     .body()
     ._(StringStatement.of(JSNIUtil.methodAccess(erasedMethod)))
     .finish();
}

代码示例来源:origin: errai/errai

@Override
public void makeConstructorAccessible(final ClassStructureBuilder<?> classBuilder,
                   final MetaConstructor constructor) {
 final DefParameters methodDefParms = DefParameters.from(constructor);
 Annotation[] annotations = NO_ANNOTATIONS;
 for (MetaParameter p : constructor.getParameters()) {
  if (p.getType().getCanonicalName().equals("long")) {
   annotations = new Annotation[] { UNSAFE_NATIVE_LONG_ANNOTATION };
  }
 }
 classBuilder.publicMethod(constructor.getReturnType(), PrivateAccessUtil.getPrivateMethodName(constructor))
     .annotatedWith(annotations)
     .parameters(methodDefParms)
     .modifiers(Modifier.Static, Modifier.JSNI)
     .body()
     ._(StringStatement.of(JSNIUtil.methodAccess(constructor)))
     .finish();
}

代码示例来源:origin: org.jboss.errai/errai-codegen-gwt

@Override
public void makeConstructorAccessible(final ClassStructureBuilder<?> classBuilder,
                   final MetaConstructor constructor) {
 final DefParameters methodDefParms = DefParameters.from(constructor);
 Annotation[] annotations = NO_ANNOTATIONS;
 for (MetaParameter p : constructor.getParameters()) {
  if (p.getType().getCanonicalName().equals("long")) {
   annotations = new Annotation[] { UNSAFE_NATIVE_LONG_ANNOTATION };
  }
 }
 classBuilder.publicMethod(constructor.getReturnType(), PrivateAccessUtil.getPrivateMethodName(constructor))
     .annotatedWith(annotations)
     .parameters(methodDefParms)
     .modifiers(Modifier.Static, Modifier.JSNI)
     .body()
     ._(StringStatement.of(JSNIUtil.methodAccess(constructor)))
     .finish();
}

代码示例来源:origin: errai/errai

@Override
public void createReadableField(final MetaClass type,
                final ClassStructureBuilder<?> classBuilder,
                final MetaField field,
                final Modifier[] modifiers) {
 final MethodBlockBuilder<? extends ClassStructureBuilder<?>> instance =
     classBuilder.packageMethod(type, PrivateAccessUtil.getPrivateFieldAccessorName(field));
 if (!field.isStatic()) {
  instance.parameters(DefParameters.fromParameters(Parameter.of(field.getDeclaringClass().getErased(), "instance")));
 }
 if (type.getCanonicalName().equals("long")) {
  instance.annotatedWith(UNSAFE_NATIVE_LONG_ANNOTATION);
 }
 instance.modifiers(appendJsni(modifiers))
     .body()
     ._(StringStatement.of("return " + JSNIUtil.fieldAccess(field)))
     .finish();
}

代码示例来源:origin: org.jboss.errai/errai-codegen-gwt

@Override
public void createReadableField(final MetaClass type,
                final ClassStructureBuilder<?> classBuilder,
                final MetaField field,
                final Modifier[] modifiers) {
 final MethodBlockBuilder<? extends ClassStructureBuilder<?>> instance =
     classBuilder.packageMethod(type, PrivateAccessUtil.getPrivateFieldAccessorName(field));
 if (!field.isStatic()) {
  instance.parameters(DefParameters.fromParameters(Parameter.of(field.getDeclaringClass().getErased(), "instance")));
 }
 if (type.getCanonicalName().equals("long")) {
  instance.annotatedWith(UNSAFE_NATIVE_LONG_ANNOTATION);
 }
 instance.modifiers(appendJsni(modifiers))
     .body()
     ._(StringStatement.of("return " + JSNIUtil.fieldAccess(field)))
     .finish();
}

代码示例来源:origin: errai/errai

@Override
public void createWritableField(final MetaClass type,
                final ClassStructureBuilder<?> classBuilder,
                final MetaField field,
                final Modifier[] modifiers)  {
 final MethodCommentBuilder<? extends ClassStructureBuilder<?>> methodBuilder =
     classBuilder.packageMethod(void.class, PrivateAccessUtil.getPrivateFieldAccessorName(field));
 if (type.getCanonicalName().equals("long")) {
  methodBuilder.annotatedWith(UNSAFE_NATIVE_LONG_ANNOTATION);
 }
 if (!field.isStatic()) {
  methodBuilder
      .parameters(DefParameters.fromParameters(Parameter.of(field.getDeclaringClass().getErased(), "instance"),
          Parameter.of(type, "value")));
 } else {
  methodBuilder
      .parameters(DefParameters.fromParameters(Parameter.of(type, "value")));
 }
 methodBuilder.modifiers(appendJsni(modifiers))
     .body()
     ._(StringStatement.of(JSNIUtil.fieldAccess(field) + " = value"))
     .finish();
}

代码示例来源:origin: org.jboss.errai/errai-codegen-gwt

@Override
public void createWritableField(final MetaClass type,
                final ClassStructureBuilder<?> classBuilder,
                final MetaField field,
                final Modifier[] modifiers)  {
 final MethodCommentBuilder<? extends ClassStructureBuilder<?>> methodBuilder =
     classBuilder.packageMethod(void.class, PrivateAccessUtil.getPrivateFieldAccessorName(field));
 if (type.getCanonicalName().equals("long")) {
  methodBuilder.annotatedWith(UNSAFE_NATIVE_LONG_ANNOTATION);
 }
 if (!field.isStatic()) {
  methodBuilder
      .parameters(DefParameters.fromParameters(Parameter.of(field.getDeclaringClass().getErased(), "instance"),
          Parameter.of(type, "value")));
 } else {
  methodBuilder
      .parameters(DefParameters.fromParameters(Parameter.of(type, "value")));
 }
 methodBuilder.modifiers(appendJsni(modifiers))
     .body()
     ._(StringStatement.of(JSNIUtil.fieldAccess(field) + " = value"))
     .finish();
}

相关文章