示例#1
0
 /**
  * Checks if type has any descendants that are "buildable"
  *
  * @param item The type.
  * @return true if a buildable ancestor is found.
  */
 public static boolean hasBuildableDescendants(JavaType item) {
   if (item.getFullyQualifiedName().equals(Constants.OBJECT.getFullyQualifiedName())) {
     return false;
   }
   BuilderContext ctx = BuilderContextManager.getContext();
   BuildableRepository repository = ctx.getRepository();
   for (TypeElement element : repository.getBuildables()) {
     JavaType type = ctx.getStringJavaTypeFunction().apply(element.toString());
     if (isDescendant(type, item)) {
       return true;
     }
   }
   return false;
 }
示例#2
0
  /**
   * Finds all the descendants of a type that are buildable.
   *
   * @param item The type.
   * @return
   */
  public static Set<JavaType> getBuildableDescendants(JavaType item) {
    if (item.getFullyQualifiedName().equals(Constants.OBJECT.getFullyQualifiedName())) {
      return new LinkedHashSet<JavaType>();
    }

    Set<JavaType> result = new LinkedHashSet<JavaType>();
    BuilderContext ctx = BuilderContextManager.getContext();
    BuildableRepository repository = ctx.getRepository();
    for (TypeElement element : repository.getBuildables()) {
      JavaType type = ctx.getStringJavaTypeFunction().apply(element.toString());
      if (isDescendant(type, item)) {
        result.add(type);
      }
    }
    return result;
  }