Java Code Examples for javax.annotation.Generated

The following are top voted examples for showing how to use javax.annotation.Generated. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: gw4e.project   File: JDTManager.java   Source Code and License 6 votes vote down vote up
/**
 * @param project
 * @param itype
 * @return
 * @throws JavaModelException
 */
private static IPath findPathInGeneratedAnnotation(IProject project, IType itype) throws JavaModelException {
	ICompilationUnit cu = itype.getCompilationUnit();
	List<IAnnotationBinding> annotations = resolveAnnotation(cu, Generated.class).getAnnotations();
	if ((annotations != null) && (annotations.size() > 0)) {
		IAnnotationBinding ab = annotations.get(0);
		IMemberValuePairBinding[] attributes = ab.getAllMemberValuePairs();
		for (int i = 0; i < attributes.length; i++) {
			IMemberValuePairBinding attribut = attributes[i];
			if (attribut.getName().equalsIgnoreCase("value")) {
				Object[] o = (Object[]) attribut.getValue();
				if (o != null && o.length > 0 && String.valueOf(o[0]).trim().length() > 0) {
					try {
						IPath p = ResourceManager.find(project, String.valueOf(o[0]).trim());
						return p;
					} catch (Exception e) {
						ResourceManager.logException(e);
						return null;
					}
				}
			}
		}
	}
	return null;
}
 
Example 2
Project: Jerkoff   File: PojoCreatorImpl.java   Source Code and License 6 votes vote down vote up
/**
 * genera classe di test per clazz
 * 
 * @param clazz
 * @param prop
 * @param mongo
 * @return
 */
@Override
public TypeSpec getTypeSpec(Class<?> clazz) {
	Builder classTestBuilder = TypeSpec.classBuilder(clazz.getSimpleName() + TEST);
	ClassName superClass = ClassName.get(
			PropertiesUtils.getRequiredProperty(prop, PropertiesUtils.TEST_BASE_PACKAGE),
			PropertiesUtils.getRequiredProperty(prop, PropertiesUtils.TEST_BASE_CLASS));
	classTestBuilder.superclass(superClass);
	classTestBuilder.addJavadoc("@author \n");
	classTestBuilder.addModifiers(Modifier.PUBLIC);
	AnnotationSpec.Builder annSpecBuilder = AnnotationSpec.builder(Generated.class);
	annSpecBuilder.addMember("value", "\"it.fratta.jerkoff.Generator\"");
	annSpecBuilder.addMember("date", "\"" + Calendar.getInstance().getTime().toString() + "\"");
	AnnotationSpec annGenSpec = annSpecBuilder.build();
	classTestBuilder.addAnnotation(annGenSpec);
	/*
	 * for spring test
	 */
	// FieldSpec.Builder spec = FieldSpec.builder(clazz,
	// getNewInstanceOfNoParameters(clazz), Modifier.PRIVATE);
	// spec.addAnnotation(Autowired.class);
	// classTestBuilder.addField(spec.build());
	addClassMethodsToBuilder(classTestBuilder, clazz);
	return classTestBuilder.build();
}
 
Example 3
Project: camunda-bpm-swagger   File: CamundaRestService.java   Source Code and License 6 votes vote down vote up
@SneakyThrows
public CamundaRestService(final ModelRepository repository, final Class<?> serviceInterfaceClass, final Class<?> serviceImplClass) {

  super(repository);

  if (!serviceInterfaceClass.isAssignableFrom(serviceImplClass)) {
    throw new IllegalStateException(String.format("%s does not implement %s", serviceImplClass, serviceInterfaceClass));
  }

  this.serviceInterfaceClass = serviceInterfaceClass;
  this.serviceImplClass = serviceImplClass;

  this.codeModel = new JCodeModel();
  this.codeModel._package(PACKAGE);
  this.definedClass = this.codeModel._class(getFullQualifiedName());
  this.definedClass.annotate(Generated.class).param("value", GenerateSwaggerServicesMojo.class.getCanonicalName());

  // add doc reference
  restService = new RestService();
  getModelRepository().addService(this.serviceInterfaceClass.getName(), restService);
}
 
Example 4
Project: aml   File: JavaWriter.java   Source Code and License 6 votes vote down vote up
public JDefinedClass defineClass(AbstractType t, ClassType type) {
	String fullyQualifiedName = nameGenerator.fullyQualifiedName(t);
	try {
		JDefinedClass _class = mdl._class(fullyQualifiedName, type);
		if (config.addGenerated) {
			_class.annotate(Generated.class).param("value", JavaWriter.class.getPackage().getName()).param("date",
					new Date().toString());
		}
		if (t.hasDirectMeta(Description.class)) {
			String description = t.oneMeta(Description.class).value();
			_class.javadoc().add(description);
		}
		return _class;
	} catch (JClassAlreadyExistsException e) {
		throw new IllegalStateException(e);
	}
}
 
Example 5
Project: bsoneer   File: BsoneeCodecProviderGenerator.java   Source Code and License 6 votes vote down vote up
public JavaFile getJavaFile() {
	ClassName bsoneerCodecProviderClassName = ClassName.get(basePackage, "BsoneeCodecProvider");

	TypeSpec.Builder codecProviderBuilder = TypeSpec.classBuilder(bsoneerCodecProviderClassName.simpleName())
	        .addJavadoc(ProcessorJavadocs.GENERATED_BY_BSONEER)
	        .addSuperinterface(CodeUtil.bsonCodecProviderTypeName())
	        .addModifiers(PUBLIC).addAnnotation(AnnotationSpec.builder(Generated.class)
	        		.addMember("value", "$S", BsonProcessor.class.getCanonicalName())
	        		.build());;

	addBaseConstructor(codecProviderBuilder);
	addGetCodecMethod(codecProviderBuilder);

	return JavaFile.builder(bsoneerCodecProviderClassName.packageName(), codecProviderBuilder.build())
			.addFileComment(ProcessorJavadocs.GENERATED_BY_BSONEER)
			.indent("\t")
			.build();
}
 
Example 6
Project: GreenDao-Migrator   File: BaseUtil.java   Source Code and License 5 votes vote down vote up
public static AnnotationSpec getGenerationDetails(Class className) {
    DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss", Locale.ENGLISH);
    return AnnotationSpec.builder(Generated.class)
            .addMember("value", "$S", className.getCanonicalName())
            .addMember("date", "$S", dateFormat.format(new Date()))
            .addMember("comments", "$S", "Auto Generated by GreenDAO Migrator. DO NOT EDIT.")
            .build();
}
 
Example 7
Project: json2java4idea   File: GeneratedAnnotationPolicyTest.java   Source Code and License 5 votes vote down vote up
@Test
public void applyShouldAddGeneratedAnnotation() throws Exception {
    // setup
    final TypeSpec.Builder builder = TypeSpec.classBuilder("Test");

    // exercise
    underTest.apply(builder);

    // verify
    assertThat(builder.build())
            .hasName("Test")
            .hasAnnotation(AnnotationSpec.builder(Generated.class)
                    .addMember("value", "$S", this.getClass().getCanonicalName())
                    .build());
}
 
Example 8
Project: AptSpring   File: ClassFileGsonDefinitionModelStore.java   Source Code and License 5 votes vote down vote up
@Override
public boolean store(DefinitionModel model) {
  String packageName = model.getSourcePackage();
  String className = model.getSourceClass() + "_" + FileStore.STANDARD.getPath();
  String data = getGson().toJson(model);
  
  FieldSpec fieldSpec = FieldSpec.builder(String.class, AptResourceLoader.FIELD_NAME)
      .addModifiers(Modifier.PRIVATE, Modifier.FINAL)
      .initializer("$S", data)
      .addAnnotation(AnnotationSpec.builder(SuppressWarnings.class).addMember("value", "$S", "unused").build())
      .build();

  TypeSpec classSpec = TypeSpec.classBuilder(className)
      .addModifiers(Modifier.PUBLIC)
      .addField(fieldSpec)
      .addAnnotation(AnnotationSpec.builder(Generated.class).addMember("value", "$S", "SpringApt").build())
      .build();
  
  JavaFile javaFile = JavaFile.builder(packageName, classSpec)
      .build();

  try {
    OutputStream stream = getDefinitionOutputStreamProvider().store(model);
    try {
      stream.write(javaFile.toString().getBytes(StandardCharsets.UTF_8));
    } finally {
      stream.close();
    }
    model.setSha256(bytesToHex(getSha256Digest().digest(data.getBytes(StandardCharsets.UTF_8))));
    return true;
  } catch (IOException ex) {
    throw new IllegalStateException("Could not store model to class", ex);
  }
}
 
Example 9
Project: kares   File: Guid.java   Source Code and License 5 votes vote down vote up
/**
 * Gets the value of the isPermaLink property.
 * 
 * @return
 *     possible object is
 *     {@link Boolean }
 *     
 */
@Generated(value = "com.sun.tools.internal.xjc.Driver", date = "2017-03-01T09:39:56+01:00", comments = "JAXB RI v2.2.8-b130911.1802")
public boolean isIsPermaLink() {
    if (isPermaLink == null) {
        return true;
    } else {
        return isPermaLink;
    }
}
 
Example 10
Project: kares   File: Rss.java   Source Code and License 5 votes vote down vote up
/**
 * Gets the value of the version property.
 * 
 * @return
 *     possible object is
 *     {@link BigDecimal }
 *     
 */
@Generated(value = "com.sun.tools.internal.xjc.Driver", date = "2017-03-01T09:39:56+01:00", comments = "JAXB RI v2.2.8-b130911.1802")
public BigDecimal getVersion() {
    if (version == null) {
        return new BigDecimal("2.0");
    } else {
        return version;
    }
}
 
Example 11
Project: EgTest   File: ClassWriter.java   Source Code and License 5 votes vote down vote up
private JavaFile createFileSpec() throws Exception {
    AnnotationSpec generated = AnnotationSpec.builder(Generated.class)
            .addMember("value", "$S", "com.vocalabs.egtest.EgTest")
            .build();
    TypeSpec.Builder typeSpecBuilder = TypeSpec.classBuilder(className)
            .addModifiers(Modifier.PUBLIC, Modifier.FINAL)
            .addAnnotation(generated);
    TestWriter.write(this, typeSpecBuilder);
    codeInjector.decorateClass(typeSpecBuilder);
    TypeSpec javaFileSpec = typeSpecBuilder.build();
    JavaFile.Builder fileBuilder = JavaFile.builder(codeInjector.getPackageName(), javaFileSpec);
    return fileBuilder.build();
}
 
Example 12
Project: Android-Job-Helper   File: BaseUtil.java   Source Code and License 5 votes vote down vote up
public static AnnotationSpec getGenerationDetails(Class className) {
    DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss", Locale.ENGLISH);
    return AnnotationSpec.builder(Generated.class)
            .addMember("value", "$S", className.getCanonicalName())
            .addMember("date", "$S", dateFormat.format(new Date()))
            .addMember("comments", "$S", "Auto Generated by GreenDAO Migrator. DO NOT EDIT.")
            .build();
}
 
Example 13
Project: preferencer   File: CodeGeneration.java   Source Code and License 5 votes vote down vote up
public static void addGeneratedAnnotation(ProcessingEnvironment processingEnvironment, TypeSpec.Builder builder) {
    Elements elements = processingEnvironment.getElementUtils();
    if (elements.getTypeElement(Generated.class.getCanonicalName()) != null) {
        builder.addAnnotation(AnnotationSpec.builder(Generated.class)
                .addMember("value", "$S", SharedPreferenceProcessor.class.getCanonicalName()).build());
    }
}
 
Example 14
Project: VoteFlow   File: ResultImpl.java   Source Code and License 5 votes vote down vote up
@Generated(value = "com.sun.tools.xjc.Driver", date = "2016-10-02T10:27:12+03:00", comments = "JAXB RI vhudson-jaxb-ri-2.2-147")
public List<Topic> getTopics() {
    if (topics == null) {
        topics = new ArrayList<Topic>();
    }
    return this.topics;
}
 
Example 15
Project: VoteFlow   File: ResultImpl.java   Source Code and License 5 votes vote down vote up
@Generated(value = "com.sun.tools.xjc.Driver", date = "2016-10-02T10:27:16+03:00", comments = "JAXB RI vhudson-jaxb-ri-2.2-147")
public List<Stage> getStages() {
    if (stages == null) {
        stages = new ArrayList<Stage>();
    }
    return this.stages;
}
 
Example 16
Project: VoteFlow   File: StageImpl.java   Source Code and License 5 votes vote down vote up
@Generated(value = "com.sun.tools.xjc.Driver", date = "2016-10-02T10:27:16+03:00", comments = "JAXB RI vhudson-jaxb-ri-2.2-147")
public List<Phase> getPhases() {
    if (phases == null) {
        phases = new ArrayList<Phase>();
    }
    return this.phases;
}
 
Example 17
Project: VoteFlow   File: ResultImpl.java   Source Code and License 5 votes vote down vote up
@Generated(value = "com.sun.tools.xjc.Driver", date = "2016-10-02T10:27:18+03:00", comments = "JAXB RI vhudson-jaxb-ri-2.2-147")
public List<Object> getContent() {
    if (content == null) {
        content = new ArrayList<Object>();
    }
    return this.content;
}
 
Example 18
Project: VoteFlow   File: ResultImpl.java   Source Code and License 5 votes vote down vote up
@Generated(value = "com.sun.tools.xjc.Driver", date = "2016-10-02T10:27:14+03:00", comments = "JAXB RI vhudson-jaxb-ri-2.2-147")
public List<Class> getClazzs() {
    if (clazzs == null) {
        clazzs = new ArrayList<Class>();
    }
    return this.clazzs;
}
 
Example 19
Project: VoteFlow   File: ResultImpl.java   Source Code and License 5 votes vote down vote up
@Generated(value = "com.sun.tools.xjc.Driver", date = "2016-10-02T10:27:19+03:00", comments = "JAXB RI vhudson-jaxb-ri-2.2-147")
public List<Period> getPeriods() {
    if (periods == null) {
        periods = new ArrayList<Period>();
    }
    return this.periods;
}
 
Example 20
Project: VoteFlow   File: PeriodImpl.java   Source Code and License 5 votes vote down vote up
@Generated(value = "com.sun.tools.xjc.Driver", date = "2016-10-02T10:27:19+03:00", comments = "JAXB RI vhudson-jaxb-ri-2.2-147")
public List<Session> getSessions() {
    if (sessions == null) {
        sessions = new ArrayList<Session>();
    }
    return this.sessions;
}
 
Example 21
Project: VoteFlow   File: ResultImpl.java   Source Code and License 5 votes vote down vote up
@Generated(value = "com.sun.tools.xjc.Driver", date = "2016-10-02T10:27:15+03:00", comments = "JAXB RI vhudson-jaxb-ri-2.2-147")
public List<Deputy> getDeputies() {
    if (deputies == null) {
        deputies = new ArrayList<Deputy>();
    }
    return this.deputies;
}
 
Example 22
Project: VoteFlow   File: DeputyImpl.java   Source Code and License 5 votes vote down vote up
@Generated(value = "com.sun.tools.xjc.Driver", date = "2016-10-02T10:27:15+03:00", comments = "JAXB RI vhudson-jaxb-ri-2.2-147")
public List<Faction> getFactions() {
    if (factions == null) {
        factions = new ArrayList<Faction>();
    }
    return this.factions;
}
 
Example 23
Project: Naviganto   File: RouteProcessor.java   Source Code and License 5 votes vote down vote up
private TypeSpec createRoute(TypeElement typeElement, ArrayList<MethodSpec> methods) {
    messager.printMessage(Diagnostic.Kind.NOTE, "Saving route file...");
    return TypeSpec.classBuilder(typeElement.getSimpleName() + "Route")
            .addAnnotation(AnnotationSpec.builder(Generated.class)
                    .addMember("value", "$S", this.getClass().getName())
                    .build())
            .addModifiers(Modifier.PUBLIC)
            .addSuperinterface(org.firezenk.naviganto.processor.interfaces.Routable.class)
            .addMethods(methods)
            .build();
}
 
Example 24
Project: listing   File: AnnotationTest.java   Source Code and License 5 votes vote down vote up
@Test
void singleElementAnnotation() {
  Class<Generated> type = Generated.class;
  Annotation tag = Annotation.of(type, "(-:");
  assertEquals("@" + type.getCanonicalName() + "(\"(-:\")", tag.list());
  Annotation tags = Annotation.of(type, "(", "-", ":");
  assertEquals("@" + type.getCanonicalName() + "({\"(\", \"-\", \":\"})", tags.list());
}
 
Example 25
Project: org.ops4j.ramler   File: GeneratorContext.java   Source Code and License 5 votes vote down vote up
/**
 * Adds the {@code @Generated} annotation to the given class.
 *
 * @param klass
 *            generated Java class
 */
public void annotateAsGenerated(JDefinedClass klass) {
    klass.annotate(Generated.class)
        .param("value", "org.ops4j.ramler")
        .param("date", ZonedDateTime.now().truncatedTo(SECONDS).format(ISO_OFFSET_DATE_TIME))
        .param("comments", "version " + Version.getRamlerVersion());
}
 
Example 26
Project: Mockery   File: BrewJavaFile.java   Source Code and License 5 votes vote down vote up
private TypeSpec classTest(ClassName className, List<MethodSpec> methodSpecs) {
  String methodName = Introspector
      .decapitalize(className.simpleName());

  MethodSpec abstractMethodInstanceToTest = methodBuilder(methodName)
      .addModifiers(Modifier.ABSTRACT, Modifier.PROTECTED)
      .returns(className)
      .build();

  FieldSpec exception = FieldSpec.builder(ExpectedException.class, "exception")
      .addAnnotation(Rule.class)
      .addModifiers(Modifier.PUBLIC, Modifier.FINAL)
      .initializer("$T.none()", ExpectedException.class)
      .build();

  return TypeSpec.classBuilder(className.simpleName() + "Test_")
      .addModifiers(Modifier.ABSTRACT, Modifier.PUBLIC)
      .addMethod(abstractMethodInstanceToTest)
      .addField(exception)
      .addAnnotation(AnnotationSpec.builder(Generated.class)
          .addMember("value", "$S", MockeryProcessor.class.getCanonicalName())
          .addMember("comments", "$S", CMessages.codeGenerateWarning())
          .build())
      .addAnnotation(AnnotationSpec.builder(RunWith.class)
          .addMember("value", "$T.class", OrderedRunner.class)
          .build())
      .addMethods(methodSpecs)
      .build();
}
 
Example 27
Project: soabase-halva   File: MasterProcessor.java   Source Code and License 5 votes vote down vote up
private void internalCreateSourceFile(String packageName, ClassName templateQualifiedClassName, ClassName generatedQualifiedClassName, String annotationType, TypeSpec.Builder builder, TypeElement element)
{
    AnnotationSpec generated = AnnotationSpec
        .builder(Generated.class)
        .addMember("value", "\"" + annotationType + "\"")
        .build();
    builder.addAnnotation(generated);

    TypeSpec classSpec = builder.build();
    JavaFile javaFile = JavaFile.builder(packageName, classSpec)
        .addFileComment("Auto generated from $L by Soabase " + annotationType + " annotation processor", templateQualifiedClassName)
        .indent("    ")
        .build();

    Filer filer = processingEnv.getFiler();
    try
    {
        JavaFileObject sourceFile = filer.createSourceFile(generatedQualifiedClassName.toString());
        try ( Writer writer = sourceFile.openWriter() )
        {
            javaFile.writeTo(writer);
        }
    }
    catch ( IOException e )
    {
        String message = "Could not create source file";
        if ( e.getMessage() != null )
        {
            message = message + ": " + e.getMessage();
        }
        processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, message, element);
    }
}
 
Example 28
Project: SparkBuilderGenerator   File: CompilationUnitModificationDomain.java   Source Code and License 5 votes vote down vote up
@Generated("SparkTools")
private CompilationUnitModificationDomain(Builder builder) {
    this.listRewrite = builder.listRewrite;
    this.astRewriter = builder.astRewriter;
    this.ast = builder.ast;
    this.originalType = builder.originalType;
    this.compilationUnit = builder.compilationUnit;
}
 
Example 29
Project: SparkBuilderGenerator   File: ConstructorParameterSetterBuilderField.java   Source Code and License 5 votes vote down vote up
@Generated("SparkTools")
private ConstructorParameterSetterBuilderField(Builder builder) {
    this.fieldType = builder.fieldType;
    this.originalFieldName = builder.originalFieldName;
    this.builderFieldName = builder.builderFieldName;
    this.index = builder.index;
}
 
Example 30
Project: SparkBuilderGenerator   File: ClassFieldSetterBuilderField.java   Source Code and License 5 votes vote down vote up
@Generated("SparkTools")
private ClassFieldSetterBuilderField(Builder builder) {
    this.fieldType = builder.fieldType;
    this.originalFieldName = builder.originalFieldName;
    this.builderFieldName = builder.builderFieldName;
    this.fieldDeclaration = builder.fieldDeclaration;
}
 
Example 31
Project: annotated-mvp   File: AnnotationProcessor.java   Source Code and License 5 votes vote down vote up
@Override
public Set<String> getSupportedAnnotationTypes()
{
    Set<String> supportedAnnotations = new HashSet<>();
    supportedAnnotations.add(Presenter.class.getCanonicalName());
    supportedAnnotations.add(View.class.getCanonicalName());
    supportedAnnotations.add(Provider.class.getCanonicalName());
    supportedAnnotations.add(Generated.class.getCanonicalName());
    return supportedAnnotations;
}
 
Example 32
Project: tiger   File: NewInjectorGenerator.java   Source Code and License 5 votes vote down vote up
private TypeSpec.Builder createInjectorTypeSpec(ComponentInfo component,
    ClassName injectorClassName) {
  ClassName cn = getInjectorNameOfScope(injectorClassName, component.getScope());
  // System.out.println("createPackagedInjectorTypeSpec. name: " +
  // Utilities.getClassCanonicalName(cn));
  TypeSpec.Builder typeSpecBuilder = TypeSpec.classBuilder(cn.simpleName())
      .addModifiers(Modifier.PUBLIC).addAnnotation(AnnotationSpec.builder(Generated.class)
          .addMember("value", "$S", GENERATOR_NAME).build());

  // Top level injector.
  ClassName topLevelInjectorClassName =
      ClassName.get(topLevelPackageString, getTopLevelInjectorName(component));
  typeSpecBuilder.addField(topLevelInjectorClassName, TOP_LEVEL_INJECTOR_FIELD, Modifier.PRIVATE);

  MethodSpec.Builder ctorSpec = MethodSpec.constructorBuilder().addModifiers(Modifier.PUBLIC)
      .addParameter(topLevelInjectorClassName, TOP_LEVEL_INJECTOR_FIELD);
  ctorSpec.addStatement("this.$N = $N", TOP_LEVEL_INJECTOR_FIELD, TOP_LEVEL_INJECTOR_FIELD);

  // Containing packaged injector.
  if (componentTree.get(component) != null) {
    ClassName containingInjectorClassName =
        getInjectorNameOfScope(injectorClassName, componentTree.get(component).getScope());
    typeSpecBuilder.addField(containingInjectorClassName, CONTAINING_PACKAGED_INJECTOR_FIELD,
        Modifier.PRIVATE);
    ctorSpec.addParameter(containingInjectorClassName, CONTAINING_PACKAGED_INJECTOR_FIELD);
    ctorSpec.addStatement("this.$N = $N", CONTAINING_PACKAGED_INJECTOR_FIELD,
        CONTAINING_PACKAGED_INJECTOR_FIELD);
  }

  typeSpecBuilder.addMethod(ctorSpec.build());

  return typeSpecBuilder;
}
 
Example 33
Project: intellij-ce-playground   File: JavaSuppressionUtil.java   Source Code and License 5 votes vote down vote up
static PsiElement getAnnotationMemberSuppressedIn(@NotNull PsiModifierListOwner owner, @NotNull String inspectionToolID) {
  final PsiAnnotation generatedAnnotation = AnnotationUtil.findAnnotation(owner, Generated.class.getName());
  if (generatedAnnotation != null) return generatedAnnotation;
  PsiModifierList modifierList = owner.getModifierList();
  Collection<String> suppressedIds = getInspectionIdsSuppressedInAnnotation(modifierList);
  for (String ids : suppressedIds) {
    if (SuppressionUtil.isInspectionToolIdMentioned(ids, inspectionToolID)) {
      return modifierList != null ? AnnotationUtil.findAnnotation(owner, SUPPRESS_INSPECTIONS_ANNOTATION_NAME) : null;
    }
  }
  return null;
}
 
Example 34
Project: zerobuilder   File: Messages.java   Source Code and License 5 votes vote down vote up
static List<AnnotationSpec> generatedAnnotations(Elements elements) {
  if (elements.getTypeElement("javax.annotation.Generated") != null) {
    return singletonList(AnnotationSpec.builder(Generated.class)
        .addMember("value", "$S", ZeroProcessor.class.getName())
        .addMember("comments", "$S", GENERATED_COMMENTS)
        .build());
  }
  return Collections.emptyList();

}
 
Example 35
Project: leishvl   File: GBReferenceXref.java   Source Code and License 5 votes vote down vote up
@Generated(value = "com.sun.tools.xjc.Driver", date = "2015-11-04T10:30:05+01:00", comments = "JAXB RI v2.2.11")
public GBReferenceXref withGBXref(Collection<GBXref> values) {
    if (values!= null) {
        getGBXref().addAll(values);
    }
    return this;
}
 
Example 36
Project: leishvl   File: GBSeqKeywords.java   Source Code and License 5 votes vote down vote up
@Generated(value = "com.sun.tools.xjc.Driver", date = "2015-11-04T10:30:05+01:00", comments = "JAXB RI v2.2.11")
public GBSeqKeywords withGBKeyword(Collection<GBKeyword> values) {
    if (values!= null) {
        getGBKeyword().addAll(values);
    }
    return this;
}
 
Example 37
Project: leishvl   File: Object.java   Source Code and License 5 votes vote down vote up
@Generated(value = "com.sun.tools.xjc.Driver", date = "2015-11-04T10:30:05+01:00", comments = "JAXB RI v2.2.11")
public Object withParam(Collection<Param> values) {
    if (values!= null) {
        getParam().addAll(values);
    }
    return this;
}
 
Example 38
Project: leishvl   File: OtherNames.java   Source Code and License 5 votes vote down vote up
@Generated(value = "com.sun.tools.xjc.Driver", date = "2015-11-04T10:30:06+01:00", comments = "JAXB RI v2.2.11")
public OtherNames withEquivalentNameOrSynonymOrAcronymOrMisspellingOrAnamorphOrIncludesOrCommonNameOrInpartOrMisnomerOrTeleomorphOrGenbankSynonymOrGenbankAnamorph(Collection<Object> values) {
    if (values!= null) {
        getEquivalentNameOrSynonymOrAcronymOrMisspellingOrAnamorphOrIncludesOrCommonNameOrInpartOrMisnomerOrTeleomorphOrGenbankSynonymOrGenbankAnamorph().addAll(values);
    }
    return this;
}
 
Example 39
Project: leishvl   File: GBFeatureIntervals.java   Source Code and License 5 votes vote down vote up
@Generated(value = "com.sun.tools.xjc.Driver", date = "2015-11-04T10:30:05+01:00", comments = "JAXB RI v2.2.11")
public GBFeatureIntervals withGBInterval(Collection<GBInterval> values) {
    if (values!= null) {
        getGBInterval().addAll(values);
    }
    return this;
}
 
Example 40
Project: Noopetal   File: ClassGenerationUtil.java   Source Code and License 5 votes vote down vote up
@NonNull
public static AnnotationSpec createGeneratedAnnotation(@NonNull Class<? extends Processor> processorClass) {
    return AnnotationSpec.builder(Generated.class)
                         .addMember("value",
                                    "\"$N\"",
                                    TypeSpec.classBuilder(processorClass.getCanonicalName()).build())
                         .build();
}
 
Example 41
Project: leishvl   File: GBSeqOtherSeqids.java   Source Code and License 5 votes vote down vote up
@Generated(value = "com.sun.tools.xjc.Driver", date = "2015-11-04T10:30:05+01:00", comments = "JAXB RI v2.2.11")
public GBSeqOtherSeqids withGBSeqid(Collection<GBSeqid> values) {
    if (values!= null) {
        getGBSeqid().addAll(values);
    }
    return this;
}
 
Example 42
Project: cf2pojo   File: GenerateTask.java   Source Code and License 4 votes vote down vote up
static CompilationUnit generateCompilationUnitFromCloudFormationSpec(CloudFormationSpecification spec,
    ArrayInitializerExpr jsonSubTypesArrayExpr) {
    if (spec.getResourceType().size() != 1) {
        throw new RuntimeException("Expected exactly 1 resource per file");
    }
    Map.Entry<String, ResourceTypeSpecification> resourceTypeNameAndSpec =
        spec.getResourceType().entrySet().iterator().next();

    // resourceCanonicalName is a name like "AWS::EC2::Instance", used in the JsonSubTypes.Type annotation and
    // Javadoc
    String resourceCanonicalName = resourceTypeNameAndSpec.getKey();

    // resourceClassName is a shortened form, like "EC2Instance", to serve as the name of the generated Java
    // class
    String resourceClassName = resourceCanonicalName.substring("AWS::".length()).replace("::", "");

    CompilationUnit compilationUnit = new CompilationUnit();
    compilationUnit.setPackageDeclaration("com.salesforce.cf2pojo.model")
        .addImport(JsonProperty.class);

    final ClassOrInterfaceDeclaration resourceClass = compilationUnit.addClass(resourceClassName);

    // The class declaration is something like "public class EC2Instance extends
    // ResourceBase<EC2Instance.Properties>"
    resourceClass.setName(resourceClassName).addModifier(Modifier.PUBLIC)
        .addExtendedType(String.format("ResourceBase<%s.Properties>", resourceClassName));

    // Add an @Generated annotation to the class
    final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX");
    resourceClass.addAndGetAnnotation(Generated.class)
        .addPair("value", surroundWithQuotes(GenerateTask.class.getCanonicalName()))
        .addPair("date", surroundWithQuotes(dateFormat.format(new Date())));

    // Add constructor that initializes the properties field to a new Properties object
    resourceClass.addConstructor(Modifier.PUBLIC).setBody(new BlockStmt(NodeList.nodeList(
        new ExpressionStmt(
            new AssignExpr(new NameExpr("properties"),
                new ObjectCreationExpr(null, JavaParser.parseClassOrInterfaceType("Properties"),
                    new NodeList<>()), AssignExpr.Operator.ASSIGN)))));

    // Generate the Properties nested class
    ResourceTypeSpecification resourceSpec = resourceTypeNameAndSpec.getValue();
    ClassOrInterfaceDeclaration resourcePropertiesClass = generatePropertiesClassFromTypeSpec("Properties",
        compilationUnit, resourceCanonicalName, resourceSpec);
    resourceClass.addMember(resourcePropertiesClass);

    // Add a @JsonSubTypes.Type annotation for this resource type to ResourceBase class
    jsonSubTypesArrayExpr.getValues().add(new NormalAnnotationExpr()
        .addPair("value", resourceClassName + ".class")
        .addPair("name", surroundWithQuotes(resourceCanonicalName))
        .setName("JsonSubTypes.Type"));

    // Generate nested classes for any subproperties of this resource type (e.g.,
    // "EC2Instance.BlockDeviceMapping").  These are found in the "PropertyTypes" section of the spec file.
    if (spec.getPropertyTypes() != null) {
        for (Map.Entry<String, PropertyTypeSpecification> propertyTypeSpecEntry :
            spec.getPropertyTypes().entrySet()) {
            String subpropertyClassName = substringAfterFinalPeriod(propertyTypeSpecEntry.getKey());

            ClassOrInterfaceDeclaration subpropertyClass = generatePropertiesClassFromTypeSpec(
                subpropertyClassName, compilationUnit, propertyTypeSpecEntry.getKey(),
                propertyTypeSpecEntry.getValue());

            // Add the generated subproperty class as a static nested class of the resource class
            resourceClass.addMember(subpropertyClass);
        }
    }

    return compilationUnit;
}
 
Example 43
Project: dataenum   File: SpecTypeFactory.java   Source Code and License 4 votes vote down vote up
public static TypeSpec create(OutputSpec spec) throws ParserException {
  List<TypeSpec> valueTypes = new ArrayList<>();
  List<MethodSpec> factoryMethods = new ArrayList<>();
  List<MethodSpec> isMethods = new ArrayList<>();
  List<MethodSpec> asMethods = new ArrayList<>();

  MatchMethods matchMethods = new MatchMethods(spec.outputValues());
  MapMethods mapMethods = new MapMethods(spec.outputValues());

  for (OutputValue value : spec.outputValues()) {
    valueTypes.add(ValueTypeFactory.create(value, spec, matchMethods, mapMethods));

    ValueMethods valueMethods = new ValueMethods(value);
    factoryMethods.add(valueMethods.createFactoryMethod(spec));
    isMethods.add(valueMethods.createIsMethod());
    asMethods.add(valueMethods.createAsMethod(spec));
  }

  TypeSpec.Builder enumBuilder =
      TypeSpec.classBuilder(spec.outputClass())
          .addAnnotation(
              AnnotationSpec.builder(Generated.class)
                  .addMember(
                      "value", CodeBlock.of("$S", DataEnumProcessor.class.getCanonicalName()))
                  .build())
          .addModifiers(Modifier.PUBLIC, Modifier.ABSTRACT)
          .addTypeVariables(spec.typeVariables());

  // Hide the constructor
  enumBuilder.addMethod(MethodSpec.constructorBuilder().addModifiers(Modifier.PRIVATE).build());

  enumBuilder.addTypes(valueTypes);
  enumBuilder.addMethods(factoryMethods);
  enumBuilder.addMethods(isMethods);
  enumBuilder.addMethods(asMethods);

  if (!Iterables.isEmpty(spec.outputValues())) {
    enumBuilder.addMethod(matchMethods.createAbstractFoldVoidMethod());
    enumBuilder.addMethod(mapMethods.createAbstractFoldMethod());
  }

  return enumBuilder.build();
}
 
Example 44
Project: json2java4idea   File: GeneratedAnnotationPolicy.java   Source Code and License 4 votes vote down vote up
@Override
public void apply(@Nonnull TypeSpec.Builder builder) {
    builder.addAnnotation(AnnotationSpec.builder(Generated.class)
            .addMember("value", "$S", klass.getCanonicalName())
            .build());
}
 
Example 45
Project: domino   File: DominoTypeBuilder.java   Source Code and License 4 votes vote down vote up
private static AnnotationSpec generatedAnnotation(Class<? extends Processor> processorClass) {
    return AnnotationSpec.builder(Generated.class)
            .addMember("value", "\"" + processorClass.getCanonicalName() + "\"")
            .build();
}
 
Example 46
Project: domino   File: GeneratedAnnotationBuilder.java   Source Code and License 4 votes vote down vote up
public static AnnotationSpec build(Class<? extends Processor> processorClass) {
    return AnnotationSpec.builder(Generated.class)
            .addMember("value", "\"" + processorClass.getCanonicalName() + "\"")
            .build();
}
 
Example 47
Project: gw4e.project   File: JDTManager.java   Source Code and License 4 votes vote down vote up
public static AnnotationParsing findAnnotationParsingInGeneratedAnnotation(ICompilationUnit cu, String attribut) {
	AnnotationParsing annoParsing = resolveAnnotation(cu, Generated.class, attribut);
	return annoParsing;
}
 
Example 48
Project: qualifier   File: StaticQualifierMetamodelProcessor.java   Source Code and License 4 votes vote down vote up
public void process(TypeElement beanElement) throws Exception {
    final TypeHelper beanHelper = new TypeHelper(processingEnv);

    // 'Class' refer full qualified name, 'Name' refer to simple class name
    final String beanName = beanElement.getSimpleName().toString();
    final ClassName beanClassName = ClassName.get(beanElement);
    final ClassName metamodelName = ClassName.bestGuess(getQualifierName(getFlatName(beanElement)));
    final Collection<Metamodel> qualifiers = getPropertyDescriptors(beanElement, beanHelper);

    // Qualifier Metamodel container (non instantiable)
    final TypeSpec.Builder container = TypeSpec.classBuilder(metamodelName.simpleName())
            .addOriginatingElement(beanElement)
            .addModifiers(PUBLIC, FINAL)
            .addAnnotation(AnnotationSpec.builder(SuppressWarnings.class)
                    .addMember("value", "$S", "unused")
                    .build())
            .addAnnotation(AnnotationSpec.builder(Generated.class)
                    .addMember("value", "$S", ClassName.get(StaticQualifierMetamodelProcessor.class))
                    .addMember("date", "$S", Instant.now())
                    .addMember("comments", "$S", "Enabled processor providers (" + getProviders().size() + "):\n"
                            + getProviders().stream()
                            .map(e -> e.getClass().getSimpleName())
                            .collect(joining("\n")))
                    .build())
            .addMethod(MethodSpec.constructorBuilder().addModifiers(PRIVATE).build());

    // Bean qualifier extensions
    getProviders().stream()
            .filter(QualifierProcessorServiceProvider::processable)
            .forEach(extension -> extension.processBean(container, beanName, qualifiers));

    // Emit qualifiers for each bean property
    for (Metamodel qualifier : qualifiers) {
        emitQualifier(beanElement, container, qualifier, metamodelName);
    }

    // All qualifiers instance
    {
        final TypeName valueType = qualifierType(beanClassName, WILDCARD);
        final TypeName mapType = ParameterizedTypeName.get(ClassName.get(Collection.class), valueType);
        container.addType(TypeSpec.classBuilder(PROPERTIES_HOLDER).addModifiers(PRIVATE, STATIC, FINAL)
                .addField(FieldSpec.builder(mapType, PROPERTIES_FIELD, PRIVATE, STATIC, FINAL)
                        .initializer("$[$T.<$T>asList($L)$]", Arrays.class, valueType, qualifiers.stream()
                                .filter(Metamodel::isProperty)
                                .map(p -> format("%1$s", toLower(p.name())))
                                .collect(joining(",\n", "\n", "")))
                        .build())
                .build());
    }

    JavaFile.builder(beanHelper.getPackageName(beanElement), container.build()).build()
            .writeTo(processingEnv.getFiler());
}
 
Example 49
Project: VoteFlow   File: TopicImpl.java   Source Code and License 4 votes vote down vote up
@Generated(value = "com.sun.tools.xjc.Driver", date = "2016-10-02T10:27:12+03:00", comments = "JAXB RI vhudson-jaxb-ri-2.2-147")
public BigInteger getId() {
    return id;
}
 
Example 50
Project: VoteFlow   File: TopicImpl.java   Source Code and License 4 votes vote down vote up
@Generated(value = "com.sun.tools.xjc.Driver", date = "2016-10-02T10:27:12+03:00", comments = "JAXB RI vhudson-jaxb-ri-2.2-147")
public String getName() {
    return name;
}
 
Example 51
Project: VoteFlow   File: StageImpl.java   Source Code and License 4 votes vote down vote up
@Generated(value = "com.sun.tools.xjc.Driver", date = "2016-10-02T10:27:16+03:00", comments = "JAXB RI vhudson-jaxb-ri-2.2-147")
public BigInteger getId() {
    return id;
}
 
Example 52
Project: VoteFlow   File: StageImpl.java   Source Code and License 4 votes vote down vote up
@Generated(value = "com.sun.tools.xjc.Driver", date = "2016-10-02T10:27:16+03:00", comments = "JAXB RI vhudson-jaxb-ri-2.2-147")
public String getName() {
    return name;
}
 
Example 53
Project: VoteFlow   File: InstanceImpl.java   Source Code and License 4 votes vote down vote up
@Generated(value = "com.sun.tools.xjc.Driver", date = "2016-10-02T10:27:16+03:00", comments = "JAXB RI vhudson-jaxb-ri-2.2-147")
public BigInteger getId() {
    return id;
}
 
Example 54
Project: VoteFlow   File: InstanceImpl.java   Source Code and License 4 votes vote down vote up
@Generated(value = "com.sun.tools.xjc.Driver", date = "2016-10-02T10:27:16+03:00", comments = "JAXB RI vhudson-jaxb-ri-2.2-147")
public String getName() {
    return name;
}
 
Example 55
Project: VoteFlow   File: InstanceImpl.java   Source Code and License 4 votes vote down vote up
@Generated(value = "com.sun.tools.xjc.Driver", date = "2016-10-02T10:27:16+03:00", comments = "JAXB RI vhudson-jaxb-ri-2.2-147")
public boolean isIsCurrent() {
    return isCurrent;
}
 
Example 56
Project: VoteFlow   File: PhaseImpl.java   Source Code and License 4 votes vote down vote up
@Generated(value = "com.sun.tools.xjc.Driver", date = "2016-10-02T10:27:16+03:00", comments = "JAXB RI vhudson-jaxb-ri-2.2-147")
public BigInteger getId() {
    return id;
}
 
Example 57
Project: VoteFlow   File: PhaseImpl.java   Source Code and License 4 votes vote down vote up
@Generated(value = "com.sun.tools.xjc.Driver", date = "2016-10-02T10:27:16+03:00", comments = "JAXB RI vhudson-jaxb-ri-2.2-147")
public String getName() {
    return name;
}
 
Example 58
Project: VoteFlow   File: PhaseImpl.java   Source Code and License 4 votes vote down vote up
@Generated(value = "com.sun.tools.xjc.Driver", date = "2016-10-02T10:27:16+03:00", comments = "JAXB RI vhudson-jaxb-ri-2.2-147")
public Instance getInstance() {
    return instance;
}
 
Example 59
Project: VoteFlow   File: VoteImpl.java   Source Code and License 4 votes vote down vote up
@Generated(value = "com.sun.tools.xjc.Driver", date = "2016-10-02T10:27:18+03:00", comments = "JAXB RI vhudson-jaxb-ri-2.2-147")
public BigInteger getId() {
    return id;
}
 
Example 60
Project: VoteFlow   File: VoteImpl.java   Source Code and License 4 votes vote down vote up
@Generated(value = "com.sun.tools.xjc.Driver", date = "2016-10-02T10:27:18+03:00", comments = "JAXB RI vhudson-jaxb-ri-2.2-147")
public String getSubject() {
    return subject;
}