Exemplo n.º 1
0
  public JavaMetadataBean(JavaType annotation, Map<String, ? extends Object> attributes) {
    this.setAnnotation(annotation);
    this.setValues(Power.map(attributes));

    this.setCode(New.code(JavaMetadata.class));
    this.setExtraCode(New.code());
  }
  public JavaInstanceInitBean(JavaBody body) {
    this.setBody(body);

    this.setKind(JavaElementKind.INSTANCE_INIT);
    this.setCode(New.code(JavaInstanceInit.class));
    this.setExtraCode(New.code());
  }
  @Test
  public void testInstantiation() {
    JavaTypeVariable typeVar = New.typeVar();
    assertNotNull(typeVar);

    JavaTypeVariable typeVarLower = New.typeVarLowerBound(String.class);
    assertNotNull(typeVarLower);

    JavaTypeVariable typeVarUpper = New.typeVarUpperBound(Integer.class);
    assertNotNull(typeVarUpper);
  }
Exemplo n.º 4
0
  protected JavaType replaceTypeParts(
      JavaType type,
      List<? extends AbstractJavaStructure> typeParts,
      Transformation<String, String> replacement) {
    String fullType = type.getCanonicalName();

    for (AbstractJavaStructure typePart : typeParts) {
      String typeName = typePart.getType().getCanonicalName();
      Pattern p = Pattern.compile("^.*\\b(" + typeName + ")\\b.*$");

      Matcher m = p.matcher(fullType);
      while (m.find()) {
        String simpleTypeName = New.type(m.group(1)).getSimpleName().toString();
        fullType =
            fullType.substring(0, m.start(1))
                + replacement.transform(simpleTypeName)
                + fullType.substring(m.end(1));
        m = p.matcher(fullType);
      }
    }

    return New.type(fullType);
  }
Exemplo n.º 5
0
 public JavaArrayTypeBean(JavaType type) {
   // TODO Auto-generated constructor stub
   this.setCode(New.code(JavaArrayType.class));
   this.setExtraCode(New.code());
 }
Exemplo n.º 6
0
 protected JavaPackage getDestinationPackage() {
   if (destPkg == null) {
     destPkg = New.packagee(destPackage);
   }
   return destPkg;
 }
abstract class AbstractJavaExecutableAdapter extends JavaElementAdapter
    implements AbstractJavaExecutable {

  private static final long serialVersionUID = -5004287664697277125L;

  private final ExecutableElement executable;

  private final JavaBody body = New.body();

  public AbstractJavaExecutableAdapter(
      ExecutableElement executable, Elements elementUtils, Types typeUtils) {
    super(executable, elementUtils, typeUtils);
    this.executable = executable;
  }

  public PowerList<JavaTypeParameter> getTypeParameters() {
    return getElementsAdapters(executable.getTypeParameters(), JavaTypeParameter.class);
  }

  public JavaType getReturnType() {
    return getTypeAdapter(executable.getReturnType());
  }

  public PowerList<JavaParameter> getParameters() {
    return getElementsAdapters(executable.getParameters(), JavaParameter.class);
  }

  public Boolean isVarArgs() {
    return executable.isVarArgs();
  }

  public PowerList<JavaType> getThrownTypes() {
    PowerList<JavaType> adapters = Power.list();

    for (TypeMirror typeMirror : executable.getThrownTypes()) {
      adapters.add(getTypeAdapter(typeMirror));
    }

    return adapters;
  }

  @Override
  public JavaBody getBody() {
    return this.body;
  }

  @Override
  protected Class<? extends AbstractJavaExecutable> getAdaptedInterface() {
    return AbstractJavaExecutable.class;
  }

  @Override
  public AbstractJavaStructure getParent() {
    return super.retrieveParent();
  }

  @Override
  public AbstractJavaExecutable copy() {
    throw calculatedMethodException();
  }
}