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

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

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

MetaClass.getComponentType介绍

暂无

代码示例

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

@Override
public synchronized MetaClass getOuterComponentType() {
 if (_outerComponentCache != null)
  return _outerComponentCache;
 MetaClass c = this;
 while (c.isArray()) {
  c = c.getComponentType();
 }
 return _outerComponentCache = c;
}

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

@Override
public synchronized MetaClass getOuterComponentType() {
 if (_outerComponentCache != null)
  return _outerComponentCache;
 MetaClass c = this;
 while (c.isArray()) {
  c = c.getComponentType();
 }
 return _outerComponentCache = c;
}

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

/**
 * Checks whether the given class has been imported.
 *
 * @param clazz
 *     the class to check, must not be null.
 *
 * @return true if import exists, otherwise false.
 */
public boolean hasImport(MetaClass clazz) {
 checkThread();
 if (clazz.isArray()) {
  clazz = clazz.getComponentType();
 }
 return imports != null && imports.containsKey(clazz.getName()) &&
   imports.get(clazz.getName()).equals(getImportForClass(clazz));
}

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

/**
 * Checks whether the given class has been imported.
 *
 * @param clazz
 *     the class to check, must not be null.
 *
 * @return true if import exists, otherwise false.
 */
public boolean hasImport(MetaClass clazz) {
 checkThread();
 if (clazz.isArray()) {
  clazz = clazz.getComponentType();
 }
 return imports != null && imports.containsKey(clazz.getName()) &&
   imports.get(clazz.getName()).equals(getImportForClass(clazz));
}

代码示例来源: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: org.jboss.errai/errai-codegen

@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

/**
 * Imports the given class.
 *
 * @param clazz
 *     the class to import, must not be null. If it is an array type (of any number of dimensions), its non-array
 *     component type will be imported.
 *
 * @return the current context with the import added.
 */
public Context addImport(MetaClass clazz) {
 checkThread();
 initImports();
 while (clazz.isArray()) {
  clazz = clazz.getComponentType();
 }
 if (!imports.containsKey(clazz.getName())) {
  final String imp = getImportForClass(clazz);
  if (imp != null) {
   imports.put(clazz.getName(), imp);
  }
 }
 return this;
}

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

/**
 * Imports the given class.
 *
 * @param clazz
 *     the class to import, must not be null. If it is an array type (of any number of dimensions), its non-array
 *     component type will be imported.
 *
 * @return the current context with the import added.
 */
public Context addImport(MetaClass clazz) {
 checkThread();
 initImports();
 while (clazz.isArray()) {
  clazz = clazz.getComponentType();
 }
 if (!imports.containsKey(clazz.getName())) {
  final String imp = getImportForClass(clazz);
  if (imp != null) {
   imports.put(clazz.getName(), imp);
  }
 }
 return this;
}

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

private Variable createForEachLoopVar(Statement collection, String loopVarName, MetaClass providedLoopVarType, Context context) {
 // infer the loop variable type
 MetaClass loopVarType = MetaClassFactory.get(Object.class);
 final MetaParameterizedType parameterizedType = collection.getType().getParameterizedType();
 if (parameterizedType != null && parameterizedType.getTypeParameters().length != 0 && 
     parameterizedType.getTypeParameters()[0] instanceof MetaClass) {
  loopVarType = (MetaClass) parameterizedType.getTypeParameters()[0];
 }
 else if (collection.getType().getComponentType() != null) {
  loopVarType = collection.getType().getComponentType();
 }
 // try to use the provided loop variable type if possible (assignable from the inferred type)
 if (providedLoopVarType != null) {
  GenUtil.assertAssignableTypes(context, loopVarType, providedLoopVarType);
  loopVarType = providedLoopVarType;
 }
 final Variable loopVar = Variable.create(loopVarName, loopVarType);
 context.addVariable(loopVar);
 return loopVar;
}

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

private Variable createForEachLoopVar(Statement collection, String loopVarName, MetaClass providedLoopVarType, Context context) {
 // infer the loop variable type
 MetaClass loopVarType = MetaClassFactory.get(Object.class);
 final MetaParameterizedType parameterizedType = collection.getType().getParameterizedType();
 if (parameterizedType != null && parameterizedType.getTypeParameters().length != 0 && 
     parameterizedType.getTypeParameters()[0] instanceof MetaClass) {
  loopVarType = (MetaClass) parameterizedType.getTypeParameters()[0];
 }
 else if (collection.getType().getComponentType() != null) {
  loopVarType = collection.getType().getComponentType();
 }
 // try to use the provided loop variable type if possible (assignable from the inferred type)
 if (providedLoopVarType != null) {
  GenUtil.assertAssignableTypes(context, loopVarType, providedLoopVarType);
  loopVarType = providedLoopVarType;
 }
 final Variable loopVar = Variable.create(loopVarName, loopVarType);
 context.addVariable(loopVar);
 return loopVar;
}

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

final MetaClass actualParamType;
if (isVarArgs && !arguments[arguments.length - 1].isArray() && i >= parmTypes.length - 1)
 actualParamType = parmTypes[parmTypes.length - 1].getType().getComponentType();
else
 actualParamType = parmTypes[i].getType();

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

final MetaClass actualParamType;
if (isVarArgs && !arguments[arguments.length - 1].isArray() && i >= parmTypes.length - 1)
 actualParamType = parmTypes[parmTypes.length - 1].getType().getComponentType();
else
 actualParamType = parmTypes[i].getType();

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

@Override
public String generate(final Context context) {
 MetaClass referenceType = reference.getType();
 final Statement[] indexes = reference.getIndexes();
 if (indexes!=null) {
  for (final Statement index : indexes) {
   if (!referenceType.isArray())
    throw new InvalidTypeException("Variable is not a " + indexes.length + "-dimensional array!");
   referenceType = referenceType.getComponentType();
  } 
 }
 operator.assertCanBeApplied(referenceType);
 operator.assertCanBeApplied(statement.getType());
 return  reference.generate(context) + generateIndexes(context, indexes) +
   " " + operator.getCanonicalString() + " " + statement.generate(context);
}

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

@Override
public String generate(final Context context) {
 MetaClass referenceType = reference.getType();
 final Statement[] indexes = reference.getIndexes();
 if (indexes!=null) {
  for (final Statement index : indexes) {
   if (!referenceType.isArray())
    throw new InvalidTypeException("Variable is not a " + indexes.length + "-dimensional array!");
   referenceType = referenceType.getComponentType();
  } 
 }
 operator.assertCanBeApplied(referenceType);
 operator.assertCanBeApplied(statement.getType());
 return  reference.generate(context) + generateIndexes(context, indexes) +
   " " + operator.getCanonicalString() + " " + statement.generate(context);
}

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

MetaClass toMap = type;
while (toMap.isArray()) {
 toMap = toMap.getComponentType();

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

MetaClass toMap = type;
while (toMap.isArray()) {
 toMap = toMap.getComponentType();

相关文章