当前位置: 首页>>代码示例>>Java>>正文


Java TypeParameterElement.getBounds方法代码示例

本文整理汇总了Java中javax.lang.model.element.TypeParameterElement.getBounds方法的典型用法代码示例。如果您正苦于以下问题:Java TypeParameterElement.getBounds方法的具体用法?Java TypeParameterElement.getBounds怎么用?Java TypeParameterElement.getBounds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.lang.model.element.TypeParameterElement的用法示例。


在下文中一共展示了TypeParameterElement.getBounds方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: alligatorWithBounds

import javax.lang.model.element.TypeParameterElement; //导入方法依赖的package包/类
/**
 * The type parameters to place on the builder, with the "extends ..." bounds.
 */
String alligatorWithBounds() {
  List<TypeParameterElement> allParameters = allParameters();
  if (allParameters.isEmpty()) {
    return "";
  }

  StringBuilder alligator = new StringBuilder("<");
  String separator = "";
  for (TypeParameterElement param : allParameters) {
    alligator.append(separator);
    separator = ", ";
    alligator.append(param.toString());
    for (TypeMirror bound : param.getBounds()) {
      alligator.append(" extends ").append(bound);
    }
  }
  return alligator.append(">").toString();
}
 
开发者ID:google,项目名称:CallBuilder,代码行数:22,代码来源:CallBuilderProcessor.java

示例2: getChildInstanceOfClassFromGeneric

import javax.lang.model.element.TypeParameterElement; //导入方法依赖的package包/类
private Map<TypeParameterElement, TypeMirror> getChildInstanceOfClassFromGeneric(final TypeElement typeElement, final Class<?> aClass) {
	Map<TypeParameterElement, TypeMirror> result = new HashMap<>();
	for (TypeParameterElement element : typeElement.getTypeParameters()) {
		List<? extends TypeMirror> bounds = element.getBounds();
		for (TypeMirror bound : bounds) {
			if (bound instanceof DeclaredType && ((DeclaredType) bound).asElement() instanceof TypeElement) {
				Collection<TypeMirror> viewsType = getViewsType((TypeElement) ((DeclaredType) bound).asElement());
				boolean isViewType = false;
				for (TypeMirror viewType : viewsType) {
					if (((DeclaredType) viewType).asElement().toString().equals(aClass.getCanonicalName())) {
						isViewType = true;
					}
				}

				if (isViewType) {
					result.put(element, bound);
					break;
				}
			}
		}
	}

	return result;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:25,代码来源:PresenterInjectorRules.java

示例3: visitType

import javax.lang.model.element.TypeParameterElement; //导入方法依赖的package包/类
public Boolean visitType(TypeElement arg0, Void arg1) {
    for (TypeParameterElement e : arg0.getTypeParameters()) {
        if (stop) {
            return false;
        }
        
        for (TypeMirror b : e.getBounds()) {
            if (stop) {
                return false;
            }
            
            if (b.accept(this, arg1)) {
                return true;
            }
        }
    }

    TypeMirror superclass = arg0.getSuperclass();
    if (superclass.getKind() == TypeKind.DECLARED) {
        if (!((DeclaredType) superclass).asElement().getKind().isInterface()) {
            return false;
        }
    }

    return superclass.accept(this, arg1);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:ExportNonAccessibleElement.java

示例4: get

import javax.lang.model.element.TypeParameterElement; //导入方法依赖的package包/类
/**
 * Make a TypeVariableName for the given TypeMirror. This form is used internally to avoid
 * infinite recursion in cases like {@code Enum<E extends Enum<E>>}. When we encounter such a
 * thing, we will make a TypeVariableName without bounds and add that to the {@code typeVariables}
 * map before looking up the bounds. Then if we encounter this TypeVariable again while
 * constructing the bounds, we can just return it from the map. And, the code that put the entry
 * in {@code variables} will make sure that the bounds are filled in before returning.
 */
static com.wrmsr.wava.java.poet.TypeVariableName get(
        TypeVariable mirror, Map<TypeParameterElement, com.wrmsr.wava.java.poet.TypeVariableName> typeVariables)
{
    TypeParameterElement element = (TypeParameterElement) mirror.asElement();
    com.wrmsr.wava.java.poet.TypeVariableName typeVariableName = typeVariables.get(element);
    if (typeVariableName == null) {
        // Since the bounds field is public, we need to make it an unmodifiableList. But we control
        // the List that that wraps, which means we can change it before returning.
        List<TypeName> bounds = new ArrayList<>();
        List<TypeName> visibleBounds = Collections.unmodifiableList(bounds);
        typeVariableName = new com.wrmsr.wava.java.poet.TypeVariableName(element.getSimpleName().toString(), visibleBounds);
        typeVariables.put(element, typeVariableName);
        for (TypeMirror typeMirror : element.getBounds()) {
            bounds.add(TypeName.get(typeMirror, typeVariables));
        }
        bounds.remove(OBJECT);
    }
    return typeVariableName;
}
 
开发者ID:wrmsr,项目名称:wava,代码行数:28,代码来源:TypeVariableName.java

示例5: get

import javax.lang.model.element.TypeParameterElement; //导入方法依赖的package包/类
/**
 * Make a TypeVariableName for the given TypeMirror. This form is used internally to avoid
 * infinite recursion in cases like {@code Enum<E extends Enum<E>>}. When we encounter such a
 * thing, we will make a TypeVariableName without bounds and add that to the {@code typeVariables}
 * map before looking up the bounds. Then if we encounter this TypeVariable again while
 * constructing the bounds, we can just return it from the map. And, the code that put the entry
 * in {@code variables} will make sure that the bounds are filled in before returning.
 */
static TypeVariableName get(
        TypeVariable mirror, Map<TypeParameterElement, TypeVariableName> typeVariables) {
    TypeParameterElement element = (TypeParameterElement) mirror.asElement();
    TypeVariableName typeVariableName = typeVariables.get(element);
    if (typeVariableName == null) {
        // Since the bounds field is public, we need to make it an unmodifiableList. But we control
        // the List that that wraps, which means we can change it before returning.
        List<TypeName> bounds = new ArrayList<>();
        List<TypeName> visibleBounds = Collections.unmodifiableList(bounds);
        typeVariableName = new TypeVariableName(element.getSimpleName().toString(), visibleBounds);
        typeVariables.put(element, typeVariableName);
        for (TypeMirror typeMirror : element.getBounds()) {
            bounds.add(TypeName.get(typeMirror, typeVariables));
        }
        bounds.remove(OBJECT);
    }
    return typeVariableName;
}
 
开发者ID:flipkart-incubator,项目名称:Lyrics,代码行数:27,代码来源:TypeVariableName.java

示例6: get

import javax.lang.model.element.TypeParameterElement; //导入方法依赖的package包/类
/**
 * Make a TypeVariableName for the given TypeMirror. This form is used internally to avoid
 * infinite recursion in cases like {@code Enum<E extends Enum<E>>}. When we encounter such a
 * thing, we will make a TypeVariableName without bounds and add that to the {@code typeVariables}
 * map before looking up the bounds. Then if we encounter this TypeVariable again while
 * constructing the bounds, we can just return it from the map. And, the code that put the entry
 * in {@code variables} will make sure that the bounds are filled in before returning.
 */
static TypeVariableName get(
    TypeVariable mirror, Map<TypeParameterElement, TypeVariableName> typeVariables) {
  TypeParameterElement element = (TypeParameterElement) mirror.asElement();
  TypeVariableName typeVariableName = typeVariables.get(element);
  if (typeVariableName == null) {
    // Since the bounds field is public, we need to make it an unmodifiableList. But we control
    // the List that that wraps, which means we can change it before returning.
    List<TypeName> bounds = new ArrayList<>();
    List<TypeName> visibleBounds = Collections.unmodifiableList(bounds);
    typeVariableName = new TypeVariableName(element.getSimpleName().toString(), visibleBounds);
    typeVariables.put(element, typeVariableName);
    for (TypeMirror typeMirror : element.getBounds()) {
      bounds.add(TypeName.get(typeMirror, typeVariables));
    }
    bounds.remove(OBJECT);
  }
  return typeVariableName;
}
 
开发者ID:Ufkoku,项目名称:AndroidMVPHelper,代码行数:27,代码来源:TypeVariableName.java

示例7: addTo

import javax.lang.model.element.TypeParameterElement; //导入方法依赖的package包/类
@Override public void addTo(SourceBuilder source) {
  if (!typeParameters.isEmpty()) {
    String prefix = "<";
    for (Object typeParameter : typeParameters) {
      source.add("%s%s", prefix, typeParameter);
      if (typeParameter instanceof TypeParameterElement) {
        TypeParameterElement element = (TypeParameterElement) typeParameter;
        if (!extendsObject(element)) {
          String separator = " extends ";
          for (TypeMirror bound : element.getBounds()) {
            source.add("%s%s", separator, bound);
            separator = " & ";
          }
        }
      }
      prefix = ", ";
    }
    source.add(">");
  }
}
 
开发者ID:google,项目名称:FreeBuilder,代码行数:21,代码来源:ParameterizedType.java

示例8: visitTypeVariable

import javax.lang.model.element.TypeParameterElement; //导入方法依赖的package包/类
@Override public TypeKey visitTypeVariable(TypeVariable t, Set<TypeParameterElement> visited) {
  TypeParameterElement element = (TypeParameterElement) t.asElement();
  if (visited.contains(element)) {
    // This avoids infinite recursion with adapted types like <T extends Comparable<T>>.
    // It should probably check that T is bound correctly, but this is unlikely to be an issue
    // in the wild.
    return AnyKey.get(t.toString());
  }
  visited.add(element);
  ImmutableList.Builder<TypeKey> builder = ImmutableList.builder();
  for (TypeMirror bound : element.getBounds()) {
    TypeKey boundKey = bound.accept(this, visited);
    if (!boundKey.equals(OBJECT)) {
      builder.add(boundKey);
    }
  }
  ImmutableList<TypeKey> bounds = builder.build();
  if (bounds.size() == 0) {
    return AnyKey.get(t.toString());
  } else {
    return BoundedKey.get(t.toString(), bounds);
  }
}
 
开发者ID:grandstaish,项目名称:paperparcel,代码行数:24,代码来源:TypeKey.java

示例9: getBounds

import javax.lang.model.element.TypeParameterElement; //导入方法依赖的package包/类
private List<Type.Defined> getBounds(Type.Parameters parameters, TypeParameterElement p) {
  List<Type.Defined> bounds = new ArrayList<>();
  for (TypeMirror b : p.getBounds()) {
    bounds.add((Type.Defined) b.accept(converter, parameters));
  }
  return bounds;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:TypeExtractor.java

示例10: createHtmlHeader

import javax.lang.model.element.TypeParameterElement; //导入方法依赖的package包/类
private static String createHtmlHeader(boolean deprecated, TypeElement e) {
    StringBuilder sb = new StringBuilder();
    sb.append("<html>");
    if (deprecated) sb.append("<s>");
    sb.append(e.getSimpleName());
    if (deprecated) sb.append("</s>");
    List<? extends TypeParameterElement> typeParams = e.getTypeParameters();
    if (typeParams != null && !typeParams.isEmpty()) {
        sb.append("&lt;"); // NOI18N
        for(Iterator<? extends TypeParameterElement> it = typeParams.iterator(); it.hasNext();) {
            TypeParameterElement tp = it.next();
            sb.append(tp.getSimpleName());
            try {
                List<? extends TypeMirror> bounds = tp.getBounds();
                if (!bounds.isEmpty()) {
                    sb.append(translateToHTML(printBounds(bounds)));
                }
            }
            catch (NullPointerException npe) {
            }                    
            if (it.hasNext()) {
                sb.append(", "); // NOI18N
            }
        }
        sb.append("&gt;"); // NOI18N
    }
    return sb.toString();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:ElementNode.java

示例11: visitTypeParameter

import javax.lang.model.element.TypeParameterElement; //导入方法依赖的package包/类
@Override
public Tree visitTypeParameter(TypeParameterElement e, Void p) {
    List<ExpressionTree> bounds = new LinkedList<ExpressionTree>();

    for (TypeMirror b : e.getBounds()) {
        bounds.add((ExpressionTree) make.Type(b));
    }

    return make.TypeParameter(e.getSimpleName(), bounds);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:CodeGenerator.java

示例12: appendTypeParameterWithBounds

import javax.lang.model.element.TypeParameterElement; //导入方法依赖的package包/类
private void appendTypeParameterWithBounds(StringBuilder sb, TypeParameterElement typeParameter) {
    sb.append(typeParameter.getSimpleName());
    String sep = " extends ";
    for (TypeMirror bound : typeParameter.getBounds()) {
        if (!bound.toString().equals("java.lang.Object")) {
            sb.append(sep);
            sep = " & ";
            bound.accept(toStringTypeVisitor, sb);
        }
    }
}
 
开发者ID:ccheptea,项目名称:auto-value-node,代码行数:12,代码来源:TypeSimplifier.java

示例13: getBounds

import javax.lang.model.element.TypeParameterElement; //导入方法依赖的package包/类
public List<? extends TypeMirror> getBounds(TypeParameterElement tpe) {
    List<? extends TypeMirror> bounds = tpe.getBounds();
    if (!bounds.isEmpty()) {
        TypeMirror upperBound = bounds.get(bounds.size() - 1);
        if (ignoreBounds(upperBound)) {
            return Collections.emptyList();
        }
    }
    return bounds;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:Utils.java

示例14: visitTypeVariable

import javax.lang.model.element.TypeParameterElement; //导入方法依赖的package包/类
@Override
public Integer visitTypeVariable(TypeVariable t, Set<Element> visiting) {
    int result = hashKind(HASH_SEED, t);
    result *= HASH_MULTIPLIER;
    result += t.getLowerBound().accept(this, visiting);
    TypeParameterElement element = (TypeParameterElement) t.asElement();
    for (TypeMirror bound : element.getBounds()) {
        result *= HASH_MULTIPLIER;
        result += bound.accept(this, visiting);
    }
    return result;
}
 
开发者ID:foodora,项目名称:android-auto-mapper,代码行数:13,代码来源:MoreTypes.java

示例15: appendTypeParameterWithBounds

import javax.lang.model.element.TypeParameterElement; //导入方法依赖的package包/类
private void appendTypeParameterWithBounds(StringBuilder sb, TypeParameterElement typeParameter) {
  sb.append(typeParameter.getSimpleName());
  String sep = " extends ";
  for (TypeMirror bound : typeParameter.getBounds()) {
    if (!bound.toString().equals("java.lang.Object")) {
      sb.append(sep);
      sep = " & ";
      bound.accept(toStringTypeVisitor, sb);
    }
  }
}
 
开发者ID:sopak,项目名称:auto-value-step-builder,代码行数:12,代码来源:TypeSimplifier.java


注:本文中的javax.lang.model.element.TypeParameterElement.getBounds方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。