com.mysema.codegen.JavaWriter.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-22 转载在 其他  
字(10.6k)|赞(0)|评价(0)|浏览(72)

本文整理了Java中com.mysema.codegen.JavaWriter.<init>()方法的一些代码示例,展示了JavaWriter.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JavaWriter.<init>()方法的具体详情如下:
包路径:com.mysema.codegen.JavaWriter
类名称:JavaWriter
方法名:<init>

JavaWriter.<init>介绍

暂无

代码示例

代码示例来源:origin: querydsl/querydsl

private void write(Serializer serializer, String path, SerializerConfig serializerConfig,
    EntityType type) throws IOException {
  File targetFile = new File(targetFolder, path);
  generatedFiles.add(targetFile);
  Writer w = writerFor(targetFile);
  try {
    CodeWriter writer = createScalaSources ? new ScalaWriter(w) : new JavaWriter(w);
    serializer.serialize(type, serializerConfig, writer);
  } finally {
    w.close();
  }
}

代码示例来源:origin: querydsl/querydsl

@Test
public void supertypeSerializer() throws IOException {
  new SupertypeSerializer(typeMappings,Collections.<String>emptyList())
    .serialize(type, SimpleSerializerConfig.DEFAULT, new JavaWriter(writer));
}

代码示例来源:origin: querydsl/querydsl

@Test
public void embeddableSerializer() throws Exception {
  new EmbeddableSerializer(typeMappings,Collections.<String>emptyList())
    .serialize(type, SimpleSerializerConfig.DEFAULT, new JavaWriter(writer));
}

代码示例来源:origin: querydsl/querydsl

@Test
public void interfaces2() throws IOException {
  BeanSerializer serializer = new BeanSerializer();
  serializer.addInterface(Serializable.class);
  serializer.serialize(type, SimpleSerializerConfig.DEFAULT, new JavaWriter(writer));
  assertTrue(writer.toString().contains("public class DomainClass implements Serializable {"));
}

代码示例来源:origin: querydsl/querydsl

@Test
public void correct_imports() throws IOException {
  SimpleType type = new SimpleType(TypeCategory.ENTITY, "test.Entity", "test", "Entity",false,false);
  EntityType entityType = new EntityType(type);
  typeMappings.register(entityType, queryTypeFactory.create(entityType));
  serializer.serialize(entityType, SimpleSerializerConfig.DEFAULT, new JavaWriter(writer));
  assertTrue(writer.toString().contains("import test.Entity;"));
  assertTrue(writer.toString().contains("public class QEntity extends EntityPathBase<Entity> {"));
}

代码示例来源:origin: querydsl/querydsl

@Test
public void annotations() throws IOException {
  type.addAnnotation(new QueryEntityImpl());
  BeanSerializer serializer = new BeanSerializer();
  serializer.serialize(type, SimpleSerializerConfig.DEFAULT, new JavaWriter(writer));
  String str = writer.toString();
  assertTrue(str.contains("import com.querydsl.core.annotations.QueryEntity;"));
  assertTrue(str.contains("@QueryEntity"));
}

代码示例来源:origin: querydsl/querydsl

@Test
public void interfaces() throws IOException {
  BeanSerializer serializer = new BeanSerializer();
  serializer.addInterface(new ClassType(Serializable.class));
  serializer.serialize(type, SimpleSerializerConfig.DEFAULT, new JavaWriter(writer));
  assertTrue(writer.toString().contains("public class DomainClass implements Serializable {"));
}

代码示例来源:origin: querydsl/querydsl

@Test
public void correct_superclass() throws IOException {
  SimpleType type = new SimpleType(TypeCategory.ENTITY, "java.util.Locale", "java.util", "Locale",false,false);
  EntityType entityType = new EntityType(type);
  typeMappings.register(entityType, queryTypeFactory.create(entityType));
  serializer.serialize(entityType, SimpleSerializerConfig.DEFAULT, new JavaWriter(writer));
  assertTrue(writer.toString().contains("public class QLocale extends EntityPathBase<Locale> {"));
  CompileUtils.assertCompiles("QLocale", writer.toString());
}

代码示例来源:origin: querydsl/querydsl

@Test
public void no_package() throws IOException {
  SimpleType type = new SimpleType(TypeCategory.ENTITY, "Entity", "", "Entity",false,false);
  EntityType entityType = new EntityType(type);
  typeMappings.register(entityType, queryTypeFactory.create(entityType));
  serializer.serialize(entityType, SimpleSerializerConfig.DEFAULT, new JavaWriter(writer));
  assertTrue(writer.toString().contains("public class QEntity extends EntityPathBase<Entity> {"));
  CompileUtils.assertCompiles("QEntity", writer.toString());
}

代码示例来源:origin: querydsl/querydsl

@Test
public void no_package() throws IOException {
  SimpleType type = new SimpleType(TypeCategory.ENTITY, "Entity", "", "Entity",false,false);
  EntityType entityType = new EntityType(type);
  typeMappings.register(entityType, queryTypeFactory.create(entityType));
  serializer.serialize(entityType, SimpleSerializerConfig.DEFAULT, new JavaWriter(writer));
  assertTrue(writer.toString().contains("public class QEntity extends BeanPath<Entity> {"));
  CompileUtils.assertCompiles("QEntity", writer.toString());
}

代码示例来源:origin: querydsl/querydsl

@Test
public void correct_superclass() throws IOException {
  SimpleType type = new SimpleType(TypeCategory.ENTITY, "java.util.Locale", "java.util", "Locale",false,false);
  EntityType entityType = new EntityType(type);
  typeMappings.register(entityType, queryTypeFactory.create(entityType));
  serializer.serialize(entityType, SimpleSerializerConfig.DEFAULT, new JavaWriter(writer));
  assertTrue(writer.toString().contains("public class QLocale extends BeanPath<Locale> {"));
  CompileUtils.assertCompiles("QLocale", writer.toString());
}

代码示例来源:origin: querydsl/querydsl

@Test
public void delegates() throws IOException {
  SimpleType type = new SimpleType(TypeCategory.ENTITY, "Entity", "", "Entity",false,false);
  EntityType entityType = new EntityType(type);
  Delegate delegate = new Delegate(type, type, "test", Collections.<Parameter>emptyList(), Types.STRING);
  entityType.addDelegate(delegate);
  typeMappings.register(entityType, queryTypeFactory.create(entityType));
  serializer.serialize(entityType, SimpleSerializerConfig.DEFAULT, new JavaWriter(writer));
  assertTrue(writer.toString().contains("return Entity.test(this);"));
  CompileUtils.assertCompiles("QEntity", writer.toString());
}

代码示例来源:origin: querydsl/querydsl

@Test
public void delegates() throws IOException {
  SimpleType type = new SimpleType(TypeCategory.ENTITY, "Entity", "", "Entity",false,false);
  EntityType entityType = new EntityType(type);
  Delegate delegate = new Delegate(type, type, "test", Collections.<Parameter>emptyList(), Types.STRING);
  entityType.addDelegate(delegate);
  typeMappings.register(entityType, queryTypeFactory.create(entityType));
  serializer.serialize(entityType, SimpleSerializerConfig.DEFAULT, new JavaWriter(writer));
  assertTrue(writer.toString().contains("return Entity.test(this);"));
  CompileUtils.assertCompiles("QEntity", writer.toString());
}

代码示例来源:origin: querydsl/querydsl

@Test
public void javadocs_for_innerClass() throws IOException {
  EntityType entityType = new EntityType(new ClassType(Entity.class));
  typeMappings.register(entityType, queryTypeFactory.create(entityType));
  serializer.serialize(entityType, SimpleSerializerConfig.DEFAULT, new JavaWriter(writer));
  assertTrue(writer.toString().contains("QEntitySerializerTest_Entity is a Querydsl query type for Entity"));
  CompileUtils.assertCompiles("QEntitySerializerTest_Entity", writer.toString());
}

代码示例来源:origin: querydsl/querydsl

@Test
public void annotated_property() throws IOException {
  Property property = new Property(type, "entityField", type);
  property.addAnnotation(new QueryEntityImpl());
  type.addProperty(property);
  BeanSerializer serializer = new BeanSerializer();
  serializer.serialize(type, SimpleSerializerConfig.DEFAULT, new JavaWriter(writer));
  String str = writer.toString();
  assertTrue(str.contains("import com.querydsl.core.annotations.QueryEntity;"));
  assertTrue(str.contains("@QueryEntity"));
}

代码示例来源:origin: querydsl/querydsl

@Test
public void annotated_property_not_serialized() throws IOException {
  Property property = new Property(type, "entityField", type);
  property.addAnnotation(new QueryEntityImpl());
  type.addProperty(property);
  BeanSerializer serializer = new BeanSerializer(false);
  serializer.serialize(type, SimpleSerializerConfig.DEFAULT, new JavaWriter(writer));
  String str = writer.toString();
  assertFalse(str.contains("import com.querydsl.core.annotations.QueryEntity;"));
  assertFalse(str.contains("@QueryEntity"));
}

代码示例来源:origin: querydsl/querydsl

@Test
public void different_package() throws IOException {
  queryTypeFactory = new QueryTypeFactoryImpl("Q", "", ".gen");
  EntityType entityType = new EntityType(new ClassType(Entity.class));
  typeMappings.register(entityType, queryTypeFactory.create(entityType));
  serializer.serialize(entityType, SimpleSerializerConfig.DEFAULT, new JavaWriter(writer));
  assertTrue(writer.toString().contains("public class QEntitySerializerTest_Entity " +
      "extends EntityPathBase<EntitySerializerTest.Entity>"));
  CompileUtils.assertCompiles("QEntitySerializerTest_Entity", writer.toString());
}

代码示例来源:origin: querydsl/querydsl

@Test
public void empty() throws IOException {
  SimpleType type = new SimpleType(TypeCategory.ENTITY, "Entity", "", "Entity",false,false);
  EntityType entityType = new EntityType(type);
  typeMappings.register(entityType, queryTypeFactory.create(entityType));
  serializer.serialize(entityType, SimpleSerializerConfig.DEFAULT, new JavaWriter(writer));
  CompileUtils.assertCompiles("QEntity", writer.toString());
}

代码示例来源:origin: querydsl/querydsl

@Test
public void primitive_array() throws IOException {
  SimpleType type = new SimpleType(TypeCategory.ENTITY, "Entity", "", "Entity",false,false);
  EntityType entityType = new EntityType(type);
  entityType.addProperty(new Property(entityType, "bytes", new ClassType(byte[].class)));
  typeMappings.register(entityType, queryTypeFactory.create(entityType));
  serializer.serialize(entityType, SimpleSerializerConfig.DEFAULT, new JavaWriter(writer));
  assertTrue(writer.toString().contains("public final SimplePath<byte[]> bytes"));
  CompileUtils.assertCompiles("QEntity", writer.toString());
}

代码示例来源:origin: querydsl/querydsl

@Test
public void superType() throws IOException {
  EntityType superType = new EntityType(new SimpleType(TypeCategory.ENTITY, "Entity2", "", "Entity2",false,false));
  SimpleType type = new SimpleType(TypeCategory.ENTITY, "Entity", "", "Entity",false,false);
  EntityType entityType = new EntityType(type, Collections.singleton(new Supertype(superType, superType)));
  typeMappings.register(superType, queryTypeFactory.create(superType));
  typeMappings.register(entityType, queryTypeFactory.create(entityType));
  serializer.serialize(entityType, SimpleSerializerConfig.DEFAULT, new JavaWriter(writer));
  assertTrue(writer.toString().contains("public final QEntity2 _super = new QEntity2(this);"));
  //CompileUtils.assertCompiles("QEntity", writer.toString());
}

相关文章

微信公众号

最新文章

更多