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

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

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

MetaClass.isPrimitive介绍

暂无

代码示例

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

public static boolean isNumericallyCoercible(final MetaClass target, final MetaClass parm) {
 MetaClass boxedTarget = target.isPrimitive() ? target.asBoxed() : target;
 if (boxedTarget != null && Number_MetaClass.isAssignableFrom(target)) {
  if ((boxedTarget = parm.isPrimitive() ? parm.asBoxed() : parm) != null) {
   return Number_MetaClass.isAssignableFrom(boxedTarget);
  }
 }
 return false;
}

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

@Override
public void addDefinition(final MappingDefinition definition) {
 final String fqcn = definition.getMappingClass().getFullyQualifiedName();
 final String internalName = definition.getMappingClass().getInternalName();
 putDefinitionIfAbsent(fqcn, definition);
 if (definition.getMappingClass().isPrimitiveWrapper()) {
  putDefinitionIfAbsent(definition.getMappingClass().asUnboxed().getInternalName(), definition);
  putDefinitionIfAbsent(definition.getMappingClass().asUnboxed().getFullyQualifiedName(), definition);
 }
 if (!fqcn.equals(internalName) && definition.getMappingClass().isArray()
   && definition.getMappingClass().getOuterComponentType().isPrimitive()) {
  putDefinitionIfAbsent(internalName, definition);
 }
 if (log.isDebugEnabled())
  log.debug("loaded definition: " + fqcn);
}

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

public static boolean isNumericallyCoercible(final MetaClass target, final MetaClass parm) {
 MetaClass boxedTarget = target.isPrimitive() ? target.asBoxed() : target;
 if (boxedTarget != null && Number_MetaClass.isAssignableFrom(target)) {
  if ((boxedTarget = parm.isPrimitive() ? parm.asBoxed() : parm) != null) {
   return Number_MetaClass.isAssignableFrom(boxedTarget);
  }
 }
 return false;
}

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

@Override
public void addDefinition(final MappingDefinition definition) {
 final String fqcn = definition.getMappingClass().getFullyQualifiedName();
 final String internalName = definition.getMappingClass().getInternalName();
 putDefinitionIfAbsent(fqcn, definition);
 if (definition.getMappingClass().isPrimitiveWrapper()) {
  putDefinitionIfAbsent(definition.getMappingClass().asUnboxed().getInternalName(), definition);
  putDefinitionIfAbsent(definition.getMappingClass().asUnboxed().getFullyQualifiedName(), definition);
 }
 if (!fqcn.equals(internalName) && definition.getMappingClass().isArray()
   && definition.getMappingClass().getOuterComponentType().isPrimitive()) {
  putDefinitionIfAbsent(internalName, definition);
 }
 if (log.isDebugEnabled())
  log.debug("loaded definition: " + fqcn);
}

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

public static boolean canHandle(final MetaClass type, final String mimeType) {
 boolean canHandle = false;
 if (("text/plain".equals(mimeType) && type.asUnboxed().isPrimitive())
   || type.equals(MetaClassFactory.get(String.class))
   || type.equals(MetaClassFactory.get(Date.class))
   || type.isEnum()) {
  canHandle = true;
 }
 return canHandle;
}

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

private static void processEnvironmentConfigExtensions(final Set<MetaClass> exposedClasses) {
 final Collection<MetaClass> exts = ClassScanner.getTypesAnnotatedWith(EnvironmentConfigExtension.class, true);
 for (final MetaClass cls : exts) {
  try {
   final Class<? extends ExposedTypesProvider> providerClass = cls.asClass().asSubclass(ExposedTypesProvider.class);
   for (final MetaClass exposedType : providerClass.newInstance().provideTypesToExpose()) {
    if (exposedType.isPrimitive()) {
     exposedClasses.add(exposedType.asBoxed());
    }
    else if (exposedType.isConcrete()) {
     exposedClasses.add(exposedType);
    }
   }
  }
  catch (final Throwable e) {
   throw new RuntimeException("unable to load environment extension: " + cls.getFullyQualifiedName(), e);
  }
 }
}

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

private static void processEnvironmentConfigExtensions(final Set<MetaClass> exposedClasses) {
 final Collection<MetaClass> exts = ClassScanner.getTypesAnnotatedWith(EnvironmentConfigExtension.class, true);
 for (final MetaClass cls : exts) {
  try {
   final Class<? extends ExposedTypesProvider> providerClass = cls.asClass().asSubclass(ExposedTypesProvider.class);
   for (final MetaClass exposedType : providerClass.newInstance().provideTypesToExpose()) {
    if (exposedType.isPrimitive()) {
     exposedClasses.add(exposedType.asBoxed());
    }
    else if (exposedType.isConcrete()) {
     exposedClasses.add(exposedType);
    }
   }
  }
  catch (final Throwable e) {
   throw new RuntimeException("unable to load environment extension: " + cls.getFullyQualifiedName(), e);
  }
 }
}

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

private boolean needsLazyInit(MetaClass type) {
 MetaClass compType = type.getOuterComponentType().getErased();
 return (!compType.asUnboxed().isPrimitive() && !compType.equals(MetaClassFactory.get(String.class)) && !context
   .getDefinitionsFactory().hasBuiltInDefinition(compType));
}

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

private boolean needsLazyInit(MetaClass type) {
 MetaClass compType = type.getOuterComponentType().getErased();
 return (!compType.asUnboxed().isPrimitive() && !compType.equals(MetaClassFactory.get(String.class)) && !context
   .getDefinitionsFactory().hasBuiltInDefinition(compType));
}

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

@Override
public synchronized String getInternalName() {
 if (_internalNameCache != null)
  return _internalNameCache;
 String name = getFullyQualifiedName();
 String dimString = "";
 MetaClass type = this;
 if (isArray()) {
  type = type.getComponentType();
  int dim = 1;
  while (type.isArray()) {
   dim++;
   type = type.getComponentType();
  }
  for (int i = 0; i < dim; i++) {
   dimString += "[";
  }
  name = type.getFullyQualifiedName();
 }
 if (type.isPrimitive()) {
  name = getInternalPrimitiveNameFrom(name.trim());
 }
 else {
  name = "L".concat(getInternalPrimitiveNameFrom(name.trim()).replace('.', '/')).concat(";");
 }
 return _internalNameCache = dimString + name;
}

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

private boolean isVisibleType(final MetaClass type) {
 if (type.isArray()) {
  return isVisibleType(type.getComponentType());
 } else {
  return type.isPublic() || type.isProtected() || type.isPrimitive();
 }
}

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

@Override
public String getFullyQualifiedName() {
 if (fqcn != null)  {
  return fqcn;
 }
 if (isArray()) {
  if (getOuterComponentType().isPrimitive()) {
   fqcn = getInternalName();
  }
  else {
   fqcn = getInternalName().replace('/', '.');
  }
 }
 else {
  fqcn = getEnclosedMetaObject().getQualifiedBinaryName();
 }
 return fqcn;
}

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

@Override
public String getFullyQualifiedName() {
 if (fqcn != null)  {
  return fqcn;
 }
 if (isArray()) {
  if (getOuterComponentType().isPrimitive()) {
   fqcn = getInternalName();
  }
  else {
   fqcn = getInternalName().replace('/', '.');
  }
 }
 else {
  fqcn = getEnclosedMetaObject().getQualifiedBinaryName();
 }
 return fqcn;
}

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

private Statement defaultValueStatement(MetaClass type) {
 if (type.isPrimitive()) {
  if (type.asBoxed().isAssignableTo(Number.class)) {
   return Stmt.castTo(type, Stmt.load(0));
  }
  else if (type.isAssignableTo(boolean.class)) {
   return Stmt.load(false);
  }
  else {
   throw new UnsupportedOperationException("Don't know how to make a default value for @PageState field of type "
     + type.getFullyQualifiedName());
  }
 }
 else {
  return Stmt.load(null);
 }
}

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

public boolean isConcrete() {
 return !isInterface()
   && !isAbstract()
   && !isSynthetic()
   && !isAnonymousClass()
   && !isPrimitive()
   && !isArray()
   && !isAnnotation()
   && !isEnum();
}

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

private Statement defaultValueStatement(MetaClass type) {
 if (type.isPrimitive()) {
  if (type.asBoxed().isAssignableTo(Number.class)) {
   return Stmt.castTo(type, Stmt.load(0));
  }
  else if (type.isAssignableTo(boolean.class)) {
   return Stmt.load(false);
  }
  else {
   throw new UnsupportedOperationException("Don't know how to make a default value for @PageState field of type "
     + type.getFullyQualifiedName());
  }
 }
 else {
  return Stmt.load(null);
 }
}

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

public boolean isConcrete() {
 return !isInterface()
   && !isAbstract()
   && !isSynthetic()
   && !isAnonymousClass()
   && !isPrimitive()
   && !isArray()
   && !isAnnotation()
   && !isEnum();
}

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

private static Statement marshal(final MetaClass type, final Statement statement) {
 ContextualStatementBuilder s = null;
 if (type.isPrimitive()) {
  s = Stmt.nestedCall(Stmt.newObject(type.asBoxed()).withParameters(statement)).invoke("toString");
 }
 else if (type.getFullyQualifiedName().equals(Date.class.getName())) {
  s = Stmt.nestedCall(new TernaryStatement(Bool.isNull(statement), Stmt.load(""), Stmt.nestedCall(statement).invoke("toGMTString")));
 }
 else {
  s = Stmt.nestedCall(new TernaryStatement(Bool.isNull(statement), Stmt.load(""), Stmt.nestedCall(statement)));
  if (!type.equals(MetaClassFactory.get(String.class))) {
   s = s.invoke("toString");
  }
 }
 return s;
}

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

@Override
public String generate(final Context context) {
 final String stmt = statement.generate(context);
 if (!toType.isPrimitive() && !toType.isAssignableFrom(statement.getType())
     && !toType.isAssignableTo(statement.getType()) && !toType.isInterface()
     && !statement.getType().asBoxed().equals(toType)) {
  if (context.isPermissiveMode()) {
   return "(" + LoadClassReference.getClassReference(toType, context) + ") " + stmt;
  }
  else {
   throw new InvalidTypeException(statement.getType() + " cannot be cast to " + toType);
  }
 }
 else if (toType.isAssignableFrom(statement.getType()) && !statement.getType().equals(MetaClassFactory.get(NullType.class))) {
  return stmt;
 }
 else {
  return "(" + LoadClassReference.getClassReference(toType, context) + ") " + stmt;
 }
}

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

@Override
public String generate(final Context context) {
 final String stmt = statement.generate(context);
 if (!toType.isPrimitive() && !toType.isAssignableFrom(statement.getType())
     && !toType.isAssignableTo(statement.getType()) && !toType.isInterface()
     && !statement.getType().asBoxed().equals(toType)) {
  if (context.isPermissiveMode()) {
   return "(" + LoadClassReference.getClassReference(toType, context) + ") " + stmt;
  }
  else {
   throw new InvalidTypeException(statement.getType() + " cannot be cast to " + toType);
  }
 }
 else if (toType.isAssignableFrom(statement.getType()) && !statement.getType().equals(MetaClassFactory.get(NullType.class))) {
  return stmt;
 }
 else {
  return "(" + LoadClassReference.getClassReference(toType, context) + ") " + stmt;
 }
}

相关文章