当前位置: 首页>>代码示例>>Java>>正文


Java ObjectMappable类代码示例

本文整理汇总了Java中com.hannesdorfmann.sqlbrite.objectmapper.annotation.ObjectMappable的典型用法代码示例。如果您正苦于以下问题:Java ObjectMappable类的具体用法?Java ObjectMappable怎么用?Java ObjectMappable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ObjectMappable类属于com.hannesdorfmann.sqlbrite.objectmapper.annotation包,在下文中一共展示了ObjectMappable类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: noPublicConstructor

import com.hannesdorfmann.sqlbrite.objectmapper.annotation.ObjectMappable; //导入依赖的package包/类
/**
 * Tests that fields with min default visibility work as expected
 */
@Test public void noPublicConstructor() {
  JavaFileObject file =
      JavaFileObjects.forSourceLines("test.PrivateConstructorClass",
          "package test;",
          "",
          "@"+ ObjectMappable.class.getCanonicalName(),
          "public class PrivateConstructorClass {",
          "   @"+ Column.class.getCanonicalName()+"(\"foo\")",
          "   String foo;",
          "",
          "private PrivateConstructorClass(){}",
          "}"
      );

  Truth.assertAbout(JavaSourceSubjectFactory.javaSource())
      .that(file)
      .processedWith(new ObjectMappableProcessor())
      .failsToCompile()
      .withErrorContaining("Class test.PrivateConstructorClass has Column annotated fields (incl. super class) and therefore must provide an public empty constructor (zero parameters)");
}
 
开发者ID:sockeqwe,项目名称:sqlbrite-dao,代码行数:24,代码来源:ObjectMappableProcessorNotValidAnnotatedClassTest.java

示例2: annotatedInterface

import com.hannesdorfmann.sqlbrite.objectmapper.annotation.ObjectMappable; //导入依赖的package包/类
@Ignore
@Test public void annotatedInterface() {
  JavaFileObject file =
      JavaFileObjects.forSourceLines("test.InterfaceNotValid",
          "package test;",
          "",
          "@"+ ObjectMappable.class.getCanonicalName(),
          "public interface InterfaceNotValid {}"
      );

  // TODO wtf? Why this doesn't throw a processing exception? Annotating an interface in real life throws this exception, so what's going wrong here?
  Truth.assertAbout(JavaSourceSubjectFactory.javaSource())
      .that(file)
      .processedWith(new ObjectMappableProcessor())
      .failsToCompile()
      .withErrorContaining("test.InterfaceNotValid is annotated with @ObjectMappable but only classes can be annotated with this annotation");

}
 
开发者ID:sockeqwe,项目名称:sqlbrite-dao,代码行数:19,代码来源:ObjectMappableProcessorNotValidAnnotatedClassTest.java

示例3: privateField

import com.hannesdorfmann.sqlbrite.objectmapper.annotation.ObjectMappable; //导入依赖的package包/类
@Test public void privateField() {
  JavaFileObject file =
      JavaFileObjects.forSourceLines("test.PrivateFieldClass",
          "package test;",
          "",
          "@"+ ObjectMappable.class.getCanonicalName(),
          "public class PrivateFieldClass {",
          "   @"+ Column.class.getCanonicalName()+"(\"foo\")",
          "   private String foo;",
          "}"
      );

  Truth.assertAbout(JavaSourceSubjectFactory.javaSource())
      .that(file)
      .processedWith(new ObjectMappableProcessor())
      .failsToCompile()
      .withErrorContaining("The field 'foo' in class PrivateFieldClass is private. A corresponding setter method with the name 'setFoo(java.lang.String)' is expected but haven't been found. Please add this setter method, If you have another setter method named differently please annotate your setter method with @Column");

}
 
开发者ID:sockeqwe,项目名称:sqlbrite-dao,代码行数:20,代码来源:ObjectMappableProcessorNotValidAnnotatedClassTest.java

示例4: privateSetter

import com.hannesdorfmann.sqlbrite.objectmapper.annotation.ObjectMappable; //导入依赖的package包/类
@Test public void privateSetter() {
  JavaFileObject file =
      JavaFileObjects.forSourceLines("test.PrivateFieldClass",
          "package test;",
          "",
          "@"+ ObjectMappable.class.getCanonicalName(),
          "public class PrivateFieldClass {",
          "   @"+ Column.class.getCanonicalName()+"(\"foo\")",
          "   private String foo;",
          "   private void setFoo(String foo){ this.foo = foo; }",
          "}"
      );

  Truth.assertAbout(JavaSourceSubjectFactory.javaSource())
      .that(file)
      .processedWith(new ObjectMappableProcessor())
      .failsToCompile()
      .withErrorContaining("Setter method setFoo in test.PrivateFieldClass annotated with @Column is not public. Only PUBLIC setter methods are supported");
}
 
开发者ID:sockeqwe,项目名称:sqlbrite-dao,代码行数:20,代码来源:ObjectMappableProcessorNotValidAnnotatedClassTest.java

示例5: privateSetter2

import com.hannesdorfmann.sqlbrite.objectmapper.annotation.ObjectMappable; //导入依赖的package包/类
@Test public void privateSetter2() {
  JavaFileObject file =
      JavaFileObjects.forSourceLines("test.PrivateFieldClass",
          "package test;",
          "",
          "@"+ ObjectMappable.class.getCanonicalName(),
          "public class PrivateFieldClass {",
          "   private String foo;",
          "   @"+ Column.class.getCanonicalName()+"(\"foo\")",
          "   private void setFoo(String foo){ this.foo = foo; }",
          "}"
      );

  Truth.assertAbout(JavaSourceSubjectFactory.javaSource())
      .that(file)
      .processedWith(new ObjectMappableProcessor())
      .failsToCompile()
      .withErrorContaining("Setter method setFoo in test.PrivateFieldClass annotated with @Column is not public. Only PUBLIC setter methods are supported");
}
 
开发者ID:sockeqwe,项目名称:sqlbrite-dao,代码行数:20,代码来源:ObjectMappableProcessorNotValidAnnotatedClassTest.java

示例6: setterUnsupportedType

import com.hannesdorfmann.sqlbrite.objectmapper.annotation.ObjectMappable; //导入依赖的package包/类
@Test public void setterUnsupportedType() {
  JavaFileObject file =
      JavaFileObjects.forSourceLines("test.SetterUnsupportedType",
          "package test;",
          "",
          "@"+ ObjectMappable.class.getCanonicalName(),
          "public class SetterUnsupportedType {",
          "   @"+ Column.class.getCanonicalName()+"(\"foo\")",
          "   public void setFoo(java.util.List foo){}",
          "}"
      );

  Truth.assertAbout(JavaSourceSubjectFactory.javaSource())
      .that(file)
      .processedWith(new ObjectMappableProcessor())
      .failsToCompile()
      .withErrorContaining("Unsupported type java.util.List as parameter in method setFoo(java.util.List)() in class test.SetterUnsupportedType annotated with @Column.");
}
 
开发者ID:sockeqwe,项目名称:sqlbrite-dao,代码行数:19,代码来源:ObjectMappableProcessorNotValidAnnotatedClassTest.java

示例7: setterUnsupportedTypeDerivedFromPrivateField

import com.hannesdorfmann.sqlbrite.objectmapper.annotation.ObjectMappable; //导入依赖的package包/类
@Test public void setterUnsupportedTypeDerivedFromPrivateField() {
  JavaFileObject file =
      JavaFileObjects.forSourceLines("test.SetterUnsupportedType",
          "package test;",
          "",
          "@"+ ObjectMappable.class.getCanonicalName(),
          "public class SetterUnsupportedType {",
          "   @"+ Column.class.getCanonicalName()+"(\"foo\")",
          "   private java.util.List foo;",

          "   public void setFoo(java.util.List foo){ this.foo = foo; }",
          "}"
      );

  Truth.assertAbout(JavaSourceSubjectFactory.javaSource())
      .that(file)
      .processedWith(new ObjectMappableProcessor())
      .failsToCompile()
      .withErrorContaining("Unsupported type java.util.List as parameter in method setFoo(java.util.List)() in class test.SetterUnsupportedType annotated with @Column.");
}
 
开发者ID:sockeqwe,项目名称:sqlbrite-dao,代码行数:21,代码来源:ObjectMappableProcessorNotValidAnnotatedClassTest.java

示例8: fieldUnsupportedType

import com.hannesdorfmann.sqlbrite.objectmapper.annotation.ObjectMappable; //导入依赖的package包/类
@Test public void fieldUnsupportedType() {
  JavaFileObject file =
      JavaFileObjects.forSourceLines("test.UnsupportedType",
          "package test;",
          "",
          "@"+ ObjectMappable.class.getCanonicalName(),
          "public class UnsupportedType {",
          "   @"+ Column.class.getCanonicalName()+"(\"foo\")",
          "   java.util.List foo;",
          "}"
      );

  Truth.assertAbout(JavaSourceSubjectFactory.javaSource())
      .that(file)
      .processedWith(new ObjectMappableProcessor())
      .failsToCompile()
      .withErrorContaining("Unsupported type for field foo in class test.UnsupportedType annotated with @Column. Don't know how to read the type java.util.List");
}
 
开发者ID:sockeqwe,项目名称:sqlbrite-dao,代码行数:19,代码来源:ObjectMappableProcessorNotValidAnnotatedClassTest.java

示例9: checkAndGetClass

import com.hannesdorfmann.sqlbrite.objectmapper.annotation.ObjectMappable; //导入依赖的package包/类
/**
 * Check the Element if it's a class and returns the corresponding TypeElement
 *
 * @param e The element to check
 * @return The {@link TypeElement} representing the annotated class
 * @throws ProcessingException If element is not a CLASS
 */
private TypeElement checkAndGetClass(Element e) throws ProcessingException {

  if (e.getKind() != ElementKind.CLASS) {
    throw new ProcessingException(e,
        "%s is annotated with @%s but only classes can be annotated with this annotation",
        e.toString(), ObjectMappable.class.getSimpleName());
  }

  return (TypeElement) e;
}
 
开发者ID:sockeqwe,项目名称:sqlbrite-dao,代码行数:18,代码来源:ObjectMappableProcessor.java

示例10: defaultFieldVisibility

import com.hannesdorfmann.sqlbrite.objectmapper.annotation.ObjectMappable; //导入依赖的package包/类
/**
 * Tests that fields with min default visibility work as expected
 */
@Test public void defaultFieldVisibility() {
  JavaFileObject file =
      JavaFileObjects.forSourceLines("test.DefaultFieldClass",
          "package test;",
          "",
          "@"+ ObjectMappable.class.getCanonicalName(),
          "public class DefaultFieldClass {",
          "   @"+ Column.class.getCanonicalName()+"(\"foo\")",
          "   String foo;",
          "",
          "   @"+ Column.class.getCanonicalName()+"(\"anInt\")",
          "   int anInt;",
          "",
          "   @"+ Column.class.getCanonicalName()+"(\"aLong\")",
          "   long aLong;",
          "",
          "   @"+ Column.class.getCanonicalName()+"(\"aShort\")",
          "   short aShort;",
          "",
          "   @"+ Column.class.getCanonicalName()+"(\"aFloat\")",
          "   float aFloat;",
          "",
          "   @"+ Column.class.getCanonicalName()+"(\"aDouble\")",
          "   double aDouble;",
          "",
          "   @"+ Column.class.getCanonicalName()+"(\"aBoolean\")",
          "   boolean aBoolean;",
          "",
          "   @"+ Column.class.getCanonicalName()+"(\"bytes\")",
          "   byte[] bytes;",
          "",
          "   @"+ Column.class.getCanonicalName()+"(\"aDate\")",
          "   java.util.Date aDate;",
          "}"
      );

  Truth.assertAbout(JavaSourceSubjectFactory.javaSource())
      .that(file)
      .processedWith(new ObjectMappableProcessor())
      .compilesWithoutError();
}
 
开发者ID:sockeqwe,项目名称:sqlbrite-dao,代码行数:45,代码来源:ObjectMappableProcessorValidAnnotatedClassTest.java

示例11: publicFieldVisibility

import com.hannesdorfmann.sqlbrite.objectmapper.annotation.ObjectMappable; //导入依赖的package包/类
/**
 * Tests that fields public visibility work as expected
 */
@Test public void publicFieldVisibility() {
  JavaFileObject file =
      JavaFileObjects.forSourceLines("test.PublicFieldClass",
          "package test;",
          "",
          "@"+ ObjectMappable.class.getCanonicalName(),
          "public class PublicFieldClass {",
          "   @"+ Column.class.getCanonicalName()+"(\"foo\")",
          "   public String foo;",
          "",
          "   @"+ Column.class.getCanonicalName()+"(\"anInt\")",
          "   public int anInt;",
          "",
          "   @"+ Column.class.getCanonicalName()+"(\"aLong\")",
          "   public long aLong;",
          "",
          "   @"+ Column.class.getCanonicalName()+"(\"aShort\")",
          "   public short aShort;",
          "",
          "   @"+ Column.class.getCanonicalName()+"(\"aFloat\")",
          "   public float aFloat;",
          "",
          "   @"+ Column.class.getCanonicalName()+"(\"aDouble\")",
          "   public double aDouble;",
          "",
          "   @"+ Column.class.getCanonicalName()+"(\"aBoolean\")",
          "   public boolean aBoolean;",
          "",
          "   @"+ Column.class.getCanonicalName()+"(\"bytes\")",
          "   public byte[] bytes;",
          "",
          "   @"+ Column.class.getCanonicalName()+"(\"aDate\")",
          "   public java.util.Date aDate;",
          "}"
      );

  Truth.assertAbout(JavaSourceSubjectFactory.javaSource())
      .that(file)
      .processedWith(new ObjectMappableProcessor())
      .compilesWithoutError();
}
 
开发者ID:sockeqwe,项目名称:sqlbrite-dao,代码行数:45,代码来源:ObjectMappableProcessorValidAnnotatedClassTest.java

示例12: publicSetterVisibility

import com.hannesdorfmann.sqlbrite.objectmapper.annotation.ObjectMappable; //导入依赖的package包/类
/**
 * Tests that fields public visibility work as expected
 */
@Test public void publicSetterVisibility() {
  JavaFileObject file =
      JavaFileObjects.forSourceLines("test.PublicSetterVisibility",
          "package test;",
          "",
          "@"+ ObjectMappable.class.getCanonicalName(),
          "public class PublicSetterVisibility {",
          "   @"+ Column.class.getCanonicalName()+"(\"foo\")",
          "   private String aString;",
          "",
          "   @"+ Column.class.getCanonicalName()+"(\"anInt\")",
          "   private int anInt;",
          "",
          "   @"+ Column.class.getCanonicalName()+"(\"aLong\")",
          "   private long aLong;",
          "",
          "   @"+ Column.class.getCanonicalName()+"(\"aShort\")",
          "   private short aShort;",
          "",
          "   @"+ Column.class.getCanonicalName()+"(\"aFloat\")",
          "   private float aFloat;",
          "",
          "   @"+ Column.class.getCanonicalName()+"(\"aDouble\")",
          "   private double aDouble;",
          "",
          "   @"+ Column.class.getCanonicalName()+"(\"aBoolean\")",
          "   private boolean aBoolean;",
          "",
          "   @"+ Column.class.getCanonicalName()+"(\"bytes\")",
          "   private byte[] bytes;",
          "",
          "   @"+ Column.class.getCanonicalName()+"(\"aDate\")",
          "   private java.util.Date aDate;",
          "",
          "public void setAString(String aString){this.aString = aString; }",
          "public void setAnInt(int p){this.anInt = p; }",
          "public void setALong(long p){this.aLong = p; }",
          "public void setAShort(short p){this.aShort = p; }",
          "public void setAFloat(float p){this.aFloat = p; }",
          "public void setADouble(double p){this.aDouble = p; }",
          "public void setABoolean(boolean p){this.aBoolean = p; }",
          "public void setBytes(byte[] p){this.bytes = p; }",
          "public void setADate(java.util.Date p){this.aDate = p; }",
          "}"
      );

  Truth.assertAbout(JavaSourceSubjectFactory.javaSource())
      .that(file)
      .processedWith(new ObjectMappableProcessor())
      .compilesWithoutError();
}
 
开发者ID:sockeqwe,项目名称:sqlbrite-dao,代码行数:55,代码来源:ObjectMappableProcessorValidAnnotatedClassTest.java


注:本文中的com.hannesdorfmann.sqlbrite.objectmapper.annotation.ObjectMappable类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。