@Override
 public <T extends CtExecutable<R>> T addParameter(CtParameter<?> parameter) {
   if (parameters == CtElementImpl.<CtParameter<?>>emptyList()) {
     parameters = new ArrayList<CtParameter<?>>(PARAMETERS_CONTAINER_DEFAULT_CAPACITY);
   }
   parameter.setParent(this);
   parameters.add(parameter);
   return (T) this;
 }
Exemple #2
0
 @Override
 public <C extends CtExpression<T>> C addTypeCast(CtTypeReference<?> type) {
   if (typeCasts == CtElementImpl.<CtTypeReference<?>>emptyList()) {
     typeCasts = new ArrayList<CtTypeReference<?>>(CASTS_CONTAINER_DEFAULT_CAPACITY);
   }
   type.setParent(this);
   typeCasts.add(type);
   return (C) this;
 }
Exemple #3
0
 @Override
 public <C extends CtExpression<T>> C setTypeCasts(List<CtTypeReference<?>> casts) {
   if (this.typeCasts == CtElementImpl.<CtTypeReference<?>>emptyList()) {
     this.typeCasts = new ArrayList<CtTypeReference<?>>(CASTS_CONTAINER_DEFAULT_CAPACITY);
   }
   this.typeCasts.clear();
   for (CtTypeReference<?> cast : casts) {
     addTypeCast(cast);
   }
   return (C) this;
 }
Exemple #4
0
 @Override
 public <T extends CtBlock<R>> T insertBegin(CtStatementList statements) {
   if (getParent() != null && getParent() instanceof CtConstructor && getStatements().size() > 0) {
     CtStatement first = getStatements().get(0);
     if (first instanceof CtInvocation
         && ((CtInvocation<?>) first).getExecutable().getSimpleName().startsWith("<init>")) {
       first.insertAfter(statements);
       return (T) this;
     }
   }
   if (this.statements == CtElementImpl.<CtStatement>emptyList()) {
     this.statements =
         new ArrayList<CtStatement>(
             statements.getStatements().size() + BLOCK_STATEMENTS_CONTAINER_DEFAULT_CAPACITY);
   }
   this.statements.addAll(0, statements.getStatements());
   return (T) this;
 }
Exemple #5
0
 @Override
 public void removeStatement(CtStatement statement) {
   if (this.statements != CtElementImpl.<CtStatement>emptyList()) {
     this.statements.remove(statement);
   }
 }
Exemple #6
0
 private void ensureModifiableStatementsList() {
   if (this.statements == CtElementImpl.<CtStatement>emptyList()) {
     this.statements = new ArrayList<CtStatement>(BLOCK_STATEMENTS_CONTAINER_DEFAULT_CAPACITY);
   }
 }
 @Override
 public boolean removeParameter(CtParameter<?> parameter) {
   return parameters != CtElementImpl.<CtParameter<?>>emptyList() && parameters.remove(parameter);
 }