Package net.karneim.pojobuilder.model

Examples of net.karneim.pojobuilder.model.TypeM


    Output output = underTest.analyze(input);

    // Then:
    assertThat(output).isNotNull();
    assertThat(output.getBuilderModel().getPojoType().getName()).isEqualTo(pojoClassname);
    TypeM builderType = output.getBuilderModel().getType();
    assertThat(builderType).isNotNull();
    assertThat(builderType.getName())
        .isEqualTo("net.karneim.pojobuilder.analysis.with.superclass.SubclassPojo1Builder");
    assertThat(output.getBuilderModel().getProperties()).hasSize(3);
    PropertyM nameProperty = output.getBuilderModel().getProperties().get(new Key("name", "java.lang.String"));
    assertThat(nameProperty).isNotNull();
    assertThat(nameProperty.getFieldAccess()).isNotNull();
View Full Code Here


    Output output = underTest.analyze(input);

    // Then:
    assertThat(output).isNotNull();
    assertThat(output.getBuilderModel().getPojoType().getName()).isEqualTo(pojoClassname);
    TypeM builderType = output.getBuilderModel().getType();
    assertThat(builderType).isNotNull();
    assertThat(builderType.getName())
        .isEqualTo("net.karneim.pojobuilder.analysis.with.superclass.SubclassPojo2Builder");
    assertThat(output.getBuilderModel().getProperties()).hasSize(3);
    PropertyM visibleMemberProperty = output.getBuilderModel().getProperties().get(new Key("visibleMember", "int"));
    assertThat(visibleMemberProperty).isNotNull();
    assertThat(visibleMemberProperty.getFieldAccess()).isNotNull();
View Full Code Here

    Output output = underTest.analyze(input);

    // Then:
    assertThat(output).isNotNull();
    assertThat(output.getBuilderModel().getPojoType().getName()).isEqualTo(pojoClassname);
    TypeM builderType = output.getBuilderModel().getType();
    assertThat(builderType).isNotNull();
    assertThat(builderType.getName())
        .isEqualTo("net.karneim.pojobuilder.analysis.with.superclass.SubclassPojo3Builder");
    assertThat(output.getBuilderModel().getProperties()).hasSize(1);
    PropertyM visibleMemberProperty = output.getBuilderModel().getProperties().get(new Key("visibleMember", "int"));
    assertThat(visibleMemberProperty).isNotNull();
    assertThat(visibleMemberProperty.getFieldAccess()).isNotNull();
View Full Code Here

    Output output = underTest.analyze(input);

    // Then:
    assertThat(output).isNotNull();
    assertThat(output.getBuilderModel().getPojoType().getName()).isEqualTo(pojoClassname);
    TypeM builderType = output.getBuilderModel().getType();
    assertThat(builderType).isNotNull();
    assertThat(builderType.getName()).isEqualTo("net.karneim.pojobuilder.analysis.with.generics.ContainerPojoBuilder");
    assertThat(builderType.getGenericType())
        .isEqualTo(
            "net.karneim.pojobuilder.analysis.with.generics.ContainerPojoBuilder<T extends net.karneim.pojobuilder.analysis.with.generics.ItemPojo & java.io.Serializable>");
    assertThat(output.getBuilderModel().getProperties()).hasSize(1);
    PropertyM nameProperty = output.getBuilderModel().getProperties().get(new Key("element", "T"));
    assertThat(nameProperty).isNotNull();
View Full Code Here

  }

  private void emitWithOptionalMethod(TypeM builderType, TypeM selfType, TypeM pojoType,
      PropertyM prop, TypeM optionalType) throws IOException {

    TypeM optionalParameterType = prop.getOptionalPropertyType(optionalType);
    if (optionalParameterType == null) {
      return;
    }

    String withMethodName = prop.getWithMethodName();
    String pojoTypeStr = writer.compressType(pojoType.getName());
    String optionalParameterTypeStr = optionalParameterType.getGenericTypeDeclaration();
    optionalParameterTypeStr = writer.compressType(optionalParameterTypeStr);

    // @formatter:off
    writer
        .emitEmptyLine()
View Full Code Here

  }

  @Test
  public void test() throws Exception {
    // Given:  @formatter:off
    TypeM pojoType = new TypeM("com.example.output", "Sample");
   
    BuilderM builder = new BuilderM();
    builder.setPojoType(pojoType);
   
    builder.setType(new TypeM("com.example.output","SampleBuilder"));
    builder.setSelfType(builder.getType());
    builder.setBaseType(new TypeM("com.example.base","BaseBuilder"));
    builder.setBuildMethod( new BuildMethodM());
   
    // When:
    underTest.generateSource(builder);
   
View Full Code Here

  }

  @Test
  public void test() throws Exception {
    // Given:  @formatter:off
    TypeM pojoType = new TypeM("com.example.output", "Sample");
   
    BuilderM builder = new BuilderM();
    builder.setPojoType(pojoType);
    builder.setProperties( new PropertyListM(
      new PropertyM("someBoolean", PrimitiveTypeM.BOOLEAN)
        .accessibleVia(new FieldAccessM(EnumSet.of(PUBLIC)).declaredIn(pojoType))
        .withMethodNamePattern("with*"),
      new PropertyM("someChar", PrimitiveTypeM.CHAR)
        .accessibleVia(new FieldAccessM(EnumSet.of(PRIVATE)).declaredIn(pojoType))
        .writableVia(new SetterMethodM("setSomeChar", EnumSet.of(PUBLIC)).declaredIn(pojoType))
        .readableVia(new MethodM("getSomeChar", EnumSet.of(PUBLIC)).declaredIn(pojoType))
        .withMethodNamePattern("with*"),
      new PropertyM("someString", new TypeM("java.lang","String"))
        .accessibleVia(new FieldAccessM(EnumSet.of(PUBLIC)))
        .writableVia(new SetterMethodM("setSomeString", EnumSet.of(PUBLIC)).declaredIn(pojoType))
        .readableVia(new MethodM("getSomeString", EnumSet.of(PUBLIC)).declaredIn(pojoType))
        .withMethodNamePattern("with*")
    ));       
    builder.setType(new TypeM("com.example.output","SampleBuilder"));
    builder.setSelfType(builder.getType());
    builder.setCopyMethod(new CopyMethodM("copy"));
    builder.setBuildMethod( new BuildMethodM());
   
    // Assume: properties are returned in insertion order
View Full Code Here

  }

  @Test
  public void test() throws Exception {
    // Given:  @formatter:off
    TypeM pojoType = new TypeM("com.example.output", "Sample");
   
    BuilderM builder = new BuilderM();
    builder.setPojoType(pojoType);
    builder.setType(new TypeM("com.example.output","SampleBuilder"));
    builder.setSelfType(builder.getType());
    builder.setBuildMethod( new BuildMethodM());

    // When:
    underTest.generateSource(builder);
View Full Code Here

  @Test
  public void testGenerateSourceWithMinimalManualBuilder() throws Exception {
    // Given:  @formatter:off
    ManualBuilderM builder = new ManualBuilderM();
    builder.setPojoType(new TypeM("com.example.output", "Sample"));
    builder.setType(new TypeM("com.example.output","SampleBuilder"));
    builder.setBaseType(new TypeM("com.example.output","AbstractSampleBuilder"));
   
    // When:
    underTest.generateSource(builder);
   
    // Then: @formatter:on
View Full Code Here

  @Test
  public void testGenerateSourceWithMinimalManualBuilderHavingTypeParameter() throws Exception {
    // Given:  @formatter:off
    ManualBuilderM builder = new ManualBuilderM();
    TypeVariableM T = new TypeVariableM("T")
      .whichExtends(new TypeM("java.lang","Number"));
    builder.setPojoType(new TypeM("com.example.output", "Sample")
      .withTypeParameter(T)
    );
    builder.setType(new TypeM("com.example.output","SampleBuilder")
      .withTypeParameter(T)
    );
    builder.setBaseType(new TypeM("com.example.output","AbstractSampleBuilder")
      .withTypeParameter(T)
    );
   
    // When:
    underTest.generateSource(builder);
View Full Code Here

TOP

Related Classes of net.karneim.pojobuilder.model.TypeM

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.