Пример #1
0
 public Stream<MethodInfo> getMethodStream() {
   return type.get()
       .getMembers()
       .stream()
       .map(this::getMethodInfoWrapper)
       .filter(Objects::nonNull);
 }
Пример #2
0
 public Stream<FieldInfo> getFieldStream() {
   return type.get()
       .getMembers()
       .stream()
       .filter(x -> x instanceof FieldDeclaration)
       .map(x -> new FieldDeclarationWrapper((FieldDeclaration) x));
 }
Пример #3
0
 @Override
 public List<Type> getInterfaceTypes() {
   return type.get()
       .getImplements()
       .stream()
       .map(getContext()::resolve)
       .collect(Collectors.toList());
 }
Пример #4
0
  @Override
  public Type getSuperType() {
    val extends_ = type.get().getExtends();

    if (extends_ == null || extends_.isEmpty()) return null;

    return getContext().resolve(extends_.get(0));
  }
Пример #5
0
 @Override
 public void setName(String name) {
   String packageName = getPackageName();
   if (name.startsWith(packageName)) {
     type.get().setName(name.replace(packageName, ""));
   } else {
     throw new TransformationException("Name '" + name + "' must be in package: " + packageName);
   }
 }
Пример #6
0
  @Override
  public void remove(FieldInfo field) {
    FieldDeclarationWrapper fieldDeclarationWrapper =
        !(field instanceof FieldDeclarationWrapper)
            ? (FieldDeclarationWrapper) get(field)
            : (FieldDeclarationWrapper) field;

    if (fieldDeclarationWrapper == null)
      throw new TransformationException(
          "Field " + field + " can not be removed as it is not present");

    type.get().getMembers().remove(fieldDeclarationWrapper.declaration);
  }
Пример #7
0
  @Override
  public void remove(MethodInfo method) {
    MethodDeclarationWrapper methodDeclarationWrapper =
        !(method instanceof MethodDeclarationWrapper)
            ? (MethodDeclarationWrapper) get(method)
            : (MethodDeclarationWrapper) method;

    if (methodDeclarationWrapper == null)
      throw new TransformationException(
          "Method " + method + " can not be removed as it is not present");

    type.get().getMembers().remove(methodDeclarationWrapper.declaration);
  }
Пример #8
0
 @Override
 public void setAccessFlags(AccessFlags accessFlags) {
   type.get().setModifiers(accessFlags.access);
 }
Пример #9
0
 @Override
 public AccessFlags getAccessFlags() {
   return new AccessFlags(type.get().getModifiers());
 }
Пример #10
0
 private ResolutionContext getContextInternal() {
   return ResolutionContext.of(type.get());
 }
Пример #11
0
 private String getPackageNameInternal() {
   return NodeUtil.qualifiedName(
       NodeUtil.getParentNode(type.get(), CompilationUnit.class).getPackage().getName());
 }
Пример #12
0
 private List<Annotation> getAnnotationsInternal() {
   return getAnnotationsInternal(type.get().getAnnotations());
 }
Пример #13
0
 private void addMember(BodyDeclaration bodyDeclaration) {
   bodyDeclaration.setParentNode(type.get());
   type.get().getMembers().add(bodyDeclaration);
 }