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

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

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

MetaClass.getPackageName介绍

暂无

代码示例

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

private static boolean isReloadable(final MetaClass clazz, final Set<String> reloadablePacakges) {
 for (final String packageName : reloadablePacakges) {
  if (clazz.getPackageName().startsWith(packageName))
   return true;
 }
 return false;
}

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

private static boolean isReloadable(final MetaClass clazz, final Set<String> reloadablePacakges) {
 for (final String packageName : reloadablePacakges) {
  if (clazz.getPackageName().startsWith(packageName))
   return true;
 }
 return false;
}

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

private static void _removeIfNotMatches(final Iterator<?> iterator, final MetaClass type, final Set<String> packages,
    final Pattern excludePattern) {
 if (packages == null || packages.contains(type.getPackageName())) {
  if (excludePattern != null && excludePattern.matcher(type.getFullyQualifiedName()).matches()) {
   iterator.remove();
  }
 }
 else {
  iterator.remove();
 }
}

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

private static void _removeIfNotMatches(final Iterator<?> iterator, final MetaClass type, final Set<String> packages,
    final Pattern excludePattern) {
 if (packages == null || packages.contains(type.getPackageName())) {
  if (excludePattern != null && excludePattern.matcher(type.getFullyQualifiedName()).matches()) {
   iterator.remove();
  }
 }
 else {
  iterator.remove();
 }
}

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

private String getPathRoot(final MetaClass bundleClass, final URL resource) {
 final String fullPath = resource.getPath();
 final String resourcePath = bundleClass.getAnnotation(Bundle.class).value();
 final String protocol = resource.getProtocol();
 final String relativePath;
 if (resourcePath.startsWith("/"))
  relativePath = resourcePath;
 else
  // Do NOT use File.separatorChar here: Url.getPath() always uses forward-slashes
  relativePath = bundleClass.getPackageName().replace('.', '/');
 final String pathRoot = fullPath.substring(0, fullPath.indexOf(relativePath));
 return protocol + ":" + pathRoot;
}

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

private Optional<String> getResolvedStyleSheetPath(final Optional<String> declaredStylesheetPath,
    final MetaClass declaringClass) {
 if (declaredStylesheetPath.isPresent()) {
  return declaredStylesheetPath;
 }
 else {
  final String simpleName = declaringClass.getName();
  final String unsuffixedPath = declaringClass.getPackageName().replace('.', '/') + "/" + simpleName;
  final boolean cssSheetExists = (Thread.currentThread().getContextClassLoader().getResource(unsuffixedPath + ".css") != null);
  if (cssSheetExists) {
   return Optional.of(unsuffixedPath + ".css");
  }
  final boolean lessSheetExists = (Thread.currentThread().getContextClassLoader().getResource(unsuffixedPath + ".less") != null);
  if (lessSheetExists) {
   return Optional.of(unsuffixedPath + ".less");
  }
  return Optional.empty();
 }
}

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

private String getPathRoot(final MetaClass bundleClass, final URL resource) {
 final String fullPath = resource.getPath();
 final String resourcePath = bundleClass.getAnnotation(Bundle.class).value();
 final String protocol = resource.getProtocol();
 final String relativePath;
 if (resourcePath.startsWith("/"))
  relativePath = resourcePath;
 else
  // Do NOT use File.separatorChar here: Url.getPath() always uses forward-slashes
  relativePath = bundleClass.getPackageName().replace('.', '/');
 final String pathRoot = fullPath.substring(0, fullPath.indexOf(relativePath));
 return protocol + ":" + pathRoot;
}

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

private Optional<String> getResolvedStyleSheetPath(final Optional<String> declaredStylesheetPath,
    final MetaClass declaringClass) {
 if (declaredStylesheetPath.isPresent()) {
  return declaredStylesheetPath;
 }
 else {
  final String simpleName = declaringClass.getName();
  final String unsuffixedPath = declaringClass.getPackageName().replace('.', '/') + "/" + simpleName;
  final boolean cssSheetExists = (Thread.currentThread().getContextClassLoader().getResource(unsuffixedPath + ".css") != null);
  if (cssSheetExists) {
   return Optional.of(unsuffixedPath + ".css");
  }
  final boolean lessSheetExists = (Thread.currentThread().getContextClassLoader().getResource(unsuffixedPath + ".less") != null);
  if (lessSheetExists) {
   return Optional.of(unsuffixedPath + ".less");
  }
  return Optional.empty();
 }
}

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

public static Optional<String> getTemplateStyleSheetPath(final MetaClass type) {
 final Templated anno = type.getAnnotation(Templated.class);
 if (anno.stylesheet().isEmpty()) {
  return Optional.empty();
 }
 else {
  final String rawPath = anno.stylesheet();
  final boolean absolute = rawPath.startsWith("/");
  if (absolute) {
   return Optional.of(rawPath.substring(1));
  } else {
   return Optional.of(type.getPackageName().replace('.', '/') + "/" + rawPath);
  }
 }
}

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

public static Optional<String> getTemplateStyleSheetPath(final MetaClass type) {
 final Templated anno = type.getAnnotation(Templated.class);
 if (anno.stylesheet().isEmpty()) {
  return Optional.empty();
 }
 else {
  final String rawPath = anno.stylesheet();
  final boolean absolute = rawPath.startsWith("/");
  if (absolute) {
   return Optional.of(rawPath.substring(1));
  } else {
   return Optional.of(type.getPackageName().replace('.', '/') + "/" + rawPath);
  }
 }
}

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

/**
 * @return True iff the given type is an interface extending {@code elemental.html.Element}.
 */
public static boolean isElementalIface(final MetaClass type) {
 if (!(type.isInterface() && type.getPackageName().startsWith("elemental."))) {
  return false;
 }
 final Queue<MetaClass> ifaces = new LinkedList<MetaClass>();
 ifaces.add(type);
 while (!ifaces.isEmpty()) {
  final MetaClass iface = ifaces.poll();
  if (iface.getFullyQualifiedName().equals("elemental.dom.Element")) {
   return true;
  } else {
   ifaces.addAll(Arrays.asList(iface.getInterfaces()));
  }
 }
 return false;
}

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

/**
 * @return True iff the given type is an interface extending {@code elemental.html.Element}.
 */
public static boolean isElementalIface(final MetaClass type) {
 if (!(type.isInterface() && type.getPackageName().startsWith("elemental."))) {
  return false;
 }
 final Queue<MetaClass> ifaces = new LinkedList<MetaClass>();
 ifaces.add(type);
 while (!ifaces.isEmpty()) {
  final MetaClass iface = ifaces.poll();
  if (iface.getFullyQualifiedName().equals("elemental.dom.Element")) {
   return true;
  } else {
   ifaces.addAll(Arrays.asList(iface.getInterfaces()));
  }
 }
 return false;
}

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

/**
 * Get the name of the {@link Template} HTML file of the given {@link MetaClass} component type
 */
public static String getTemplateFileName(final MetaClass type) {
 String resource = type.getFullyQualifiedName().replace('.', '/') + ".html";
 if (type.isAnnotationPresent(Templated.class)) {
  final String source = canonicalizeTemplateSourceSyntax(type, type.getAnnotation(Templated.class).value());
  final Matcher matcher = Pattern.compile("^([^#]+)#?.*$").matcher(source);
  if (matcher.matches()) {
   resource = (matcher.group(1) == null ? resource : matcher.group(1));
   if (resource.matches("\\S+\\.html")) {
    if (resource.startsWith("/")) {
     resource = resource.substring(1);
    }
    else {
     resource = type.getPackageName().replace('.', '/') + "/" + resource;
    }
   }
  }
 }
 return resource;
}

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

/**
 * Get the name of the {@link Template} HTML file of the given {@link MetaClass} component type
 */
public static String getTemplateFileName(final MetaClass type) {
 String resource = type.getFullyQualifiedName().replace('.', '/') + ".html";
 if (type.isAnnotationPresent(Templated.class)) {
  final String source = canonicalizeTemplateSourceSyntax(type, type.getAnnotation(Templated.class).value());
  final Matcher matcher = Pattern.compile("^([^#]+)#?.*$").matcher(source);
  if (matcher.matches()) {
   resource = (matcher.group(1) == null ? resource : matcher.group(1));
   if (resource.matches("\\S+\\.html")) {
    if (resource.startsWith("/")) {
     resource = resource.substring(1);
    }
    else {
     resource = type.getPackageName().replace('.', '/') + "/" + resource;
    }
   }
  }
 }
 return resource;
}

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

/**
 * Gets the bundle name from the @Bundle annotation.
 *
 * @param bundleAnnotatedClass
 */
private String getMessageBundlePath(final MetaClass bundleAnnotatedClass) {
 final Bundle annotation = bundleAnnotatedClass.getAnnotation(Bundle.class);
 final String name = annotation.value();
 if (name == null) {
  throw new GenerationException("@Bundle: bundle name must not be null].");
 }
 // Absolute path vs. relative path.
 if (name.startsWith("/")) {
  return name.substring(1);
 }
 else {
  final String packageName = bundleAnnotatedClass.getPackageName();
  return packageName.replace('.', '/') + "/" + name;
 }
}

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

/**
 * Gets the bundle name from the @Bundle annotation.
 *
 * @param bundleAnnotatedClass
 */
private String getMessageBundlePath(final MetaClass bundleAnnotatedClass) {
 final Bundle annotation = bundleAnnotatedClass.getAnnotation(Bundle.class);
 final String name = annotation.value();
 if (name == null) {
  throw new GenerationException("@Bundle: bundle name must not be null].");
 }
 // Absolute path vs. relative path.
 if (name.startsWith("/")) {
  return name.substring(1);
 }
 else {
  final String packageName = bundleAnnotatedClass.getPackageName();
  return packageName.replace('.', '/') + "/" + name;
 }
}

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

public static BuildMetaClass makeProxy(final MetaClass toProxy,
                    final String privateAccessorType,
                    final Map<String, ProxyProperty> proxyProperties,
                    final Map<MetaMethod, Map<WeaveType, Collection<Statement>>> weavingStatements) {
 return makeProxy(
   PrivateAccessUtil.condensify(toProxy.getPackageName()) + "_" + toProxy.getName() + "_proxy",
   toProxy,
   privateAccessorType, proxyProperties, weavingStatements);
}

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

public static BuildMetaClass makeProxy(final MetaClass toProxy,
                    final String privateAccessorType,
                    final Map<String, ProxyProperty> proxyProperties,
                    final Map<MetaMethod, Map<WeaveType, Collection<Statement>>> weavingStatements) {
 return makeProxy(
   PrivateAccessUtil.condensify(toProxy.getPackageName()) + "_" + toProxy.getName() + "_proxy",
   toProxy,
   privateAccessorType, proxyProperties, weavingStatements);
}

代码示例来源: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();
}

相关文章