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

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

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

MetaClass.isArray介绍

暂无

代码示例

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

public static int getArrayDimensions(final MetaClass type) {
 if (!type.isArray()) return 0;
 final String internalName = type.getInternalName();
 for (int i = 0; i < internalName.length(); i++) {
  if (internalName.charAt(i) != '[') return i;
 }
 return 0;
}

代码示例来源: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

public static int getArrayDimensions(final MetaClass type) {
 if (!type.isArray()) return 0;
 final String internalName = type.getInternalName();
 for (int i = 0; i < internalName.length(); i++) {
  if (internalName.charAt(i) != '[') return i;
 }
 return 0;
}

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

private static String getTypeName(final MetaClass type) {
 if (type.isArray()) {
  return type.getName().replace("[]", "_array");
 } else {
  return type.getName();
 }
}

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

private static String getTypeName(final MetaClass type) {
 if (type.isArray()) {
  return type.getName().replace("[]", "_array");
 } else {
  return type.getName();
 }
}

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

@Override
public boolean shouldUseObjectMarshaller(final MetaClass type) {
 final boolean hasPortableSubtypes = inheritanceMap.containsKey(type.getFullyQualifiedName());
 final MappingDefinition definition = getDefinition(type);
 final boolean hasMarshaller = definition != null;
 if (hasMarshaller) {
  if (definition.getClass().isAnnotationPresent(CustomMapping.class)
    || definition.getClientMarshallerClass() != null) {
   return false;
  }
 }
 final boolean isConcrete = !(type.isAbstract() || type.isInterface());
 if (!type.isArray() && !type.isEnum() && !isConcrete && !hasPortableSubtypes) {
  throw new IllegalStateException("A field of type " + type
    + " appears in a portable class, but " + type + " has no portable implementations.");
 }
 return (hasPortableSubtypes && !hasMarshaller) || (hasPortableSubtypes && hasMarshaller && isConcrete);
}

代码示例来源: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

public static void assertAssignableTypes(final Context context, final MetaClass from, final MetaClass to) {
 if (!to.asBoxed().isAssignableFrom(from.asBoxed())) {
  if (to.isArray() && from.isArray()
    && GenUtil.getArrayDimensions(to) == GenUtil.getArrayDimensions(from)
    && to.getOuterComponentType().isAssignableFrom(from.getOuterComponentType())) {
   return;
  }
  if (!context.isPermissiveMode()) {
   if (classAliases.contains(from.getFullyQualifiedName()) && classAliases.contains(to.getFullyQualifiedName())) {
    // handle convertibility between MetaClass API and java Class reference.
    return;
   }
   throw new InvalidTypeException(to.getFullyQualifiedName() + " is not assignable from "
     + from.getFullyQualifiedName());
  }
 }
}

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

public static void assertAssignableTypes(final Context context, final MetaClass from, final MetaClass to) {
 if (!to.asBoxed().isAssignableFrom(from.asBoxed())) {
  if (to.isArray() && from.isArray()
    && GenUtil.getArrayDimensions(to) == GenUtil.getArrayDimensions(from)
    && to.getOuterComponentType().isAssignableFrom(from.getOuterComponentType())) {
   return;
  }
  if (!context.isPermissiveMode()) {
   if (classAliases.contains(from.getFullyQualifiedName()) && classAliases.contains(to.getFullyQualifiedName())) {
    // handle convertibility between MetaClass API and java Class reference.
    return;
   }
   throw new InvalidTypeException(to.getFullyQualifiedName() + " is not assignable from "
     + from.getFullyQualifiedName());
  }
 }
}

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

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

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

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

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

public static String getVarName(final MetaClass clazz) {
 return clazz.isArray()
     ? getArrayVarName(clazz.getOuterComponentType().getFullyQualifiedName())
       + "_D" + GenUtil.getArrayDimensions(clazz)
     : getVarName(clazz.asBoxed().getFullyQualifiedName());
}

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

public static String getVarName(final MetaClass clazz) {
 return clazz.isArray()
     ? getArrayVarName(clazz.getOuterComponentType().getFullyQualifiedName())
       + "_D" + GenUtil.getArrayDimensions(clazz)
     : getVarName(clazz.asBoxed().getFullyQualifiedName());
}

代码示例来源: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-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-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

@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);
}

相关文章