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


Java JAnnotationUse.paramArray方法代码示例

本文整理汇总了Java中com.sun.codemodel.JAnnotationUse.paramArray方法的典型用法代码示例。如果您正苦于以下问题:Java JAnnotationUse.paramArray方法的具体用法?Java JAnnotationUse.paramArray怎么用?Java JAnnotationUse.paramArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sun.codemodel.JAnnotationUse的用法示例。


在下文中一共展示了JAnnotationUse.paramArray方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addJsonTypeInfo

import com.sun.codemodel.JAnnotationUse; //导入方法依赖的package包/类
private void addJsonTypeInfo(JDefinedClass klass, ObjectTypeDeclaration type) {
    if (!context.getConfig().isJacksonTypeInfo()) {
        return;
    }
    if (type.discriminator() == null) {
        return;
    }
    List<String> derivedTypes = context.getApiModel().findDerivedTypes(type.name());
    if (derivedTypes.isEmpty()) {
        return;
    }
    JAnnotationUse typeInfo = klass.annotate(JsonTypeInfo.class);
    typeInfo.param("use", Id.NAME);
    typeInfo.param("include", As.EXISTING_PROPERTY);
    typeInfo.param("property", type.discriminator());

    JAnnotationUse subTypes = klass.annotate(JsonSubTypes.class);
    JAnnotationArrayMember typeArray = subTypes.paramArray(VALUE);

    for (String derivedType : derivedTypes) {
        JDefinedClass subtype = pkg._getClass(derivedType);
        typeArray.annotate(Type.class).param(VALUE, subtype);
    }
}
 
开发者ID:ops4j,项目名称:org.ops4j.ramler,代码行数:25,代码来源:PojoGeneratingApiVisitor.java

示例2: addAnnotParam

import com.sun.codemodel.JAnnotationUse; //导入方法依赖的package包/类
/**
 * Calls the correct {@link JAnnotationUse} <code>param</code> method.
 * 
 * @param annot
 *            The annotation in which the parameter will be added.
 * @param key
 *            The parameter's key.
 * @param value
 *            The parameter's value.
 */
public static void addAnnotParam(JAnnotationUse annot, String key, Object value) {
    if (value == null) {
        // Null values not accepted
        throw new RuntimeException("Null values not supported as annotation parameters");
    } else if (value instanceof Boolean) {
        annot.param(key, (Boolean) value);
    } else if (value instanceof Integer) {
        annot.param(key, (Integer) value);
    } else if (value instanceof String) {
        annot.param(key, (String) value);
    } else if (value instanceof Class<?>) {
        annot.param(key, (Class<?>) value);
    } else if (value instanceof JType) {
        annot.param(key, (JType) value);
    } else if (value.getClass().isArray()) {
        Object[] valueArr = (Object[]) value;
        JAnnotationArrayMember aux = annot.paramArray(key);
        for (int i = 0; i < valueArr.length; ++i) {
            addAnnotArrayParam(aux, valueArr[i]);
        }
    } else {
        throw new RuntimeException("Impossible to construct annotation param for: " + value);
    }
}
 
开发者ID:hibernate,项目名称:beanvalidation-benchmark,代码行数:35,代码来源:Util.java

示例3: suppressWarnings

import com.sun.codemodel.JAnnotationUse; //导入方法依赖的package包/类
public static void suppressWarnings(JMethod method, String... values) {
    JAnnotationUse annotation = method.annotate(SuppressWarnings.class);
    JAnnotationArrayMember member = annotation.paramArray("value");
    for( String value : values ) {
        member.param(value);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:Models.java

示例4: run

import com.sun.codemodel.JAnnotationUse; //导入方法依赖的package包/类
@Override
public boolean run(final Outline outline, final Options options, final ErrorHandler errorHandler) {
	final JClass xmlNsClass = outline.getCodeModel().ref(XmlNs.class);
	final JClass xmlSchemaClass = outline.getCodeModel().ref(XmlSchema.class);

	for (PackageOutline packageOutline : outline.getAllPackageContexts()) {
		final JPackage p = packageOutline._package();

		// get the target namespaces of all schemas that bind to the current package
		final Set<String> packageNamespaces = getPackageNamespace(packageOutline);

		// is there any prefix binding defined for the current package ?
		final Model packageModel = getPackageModel((PackageOutlineImpl) packageOutline);
		final List<Pair> list = getPrefixBinding(packageModel, packageNamespaces);
		acknowledgePrefixAnnotations(packageModel);

		if (list == null || list.isEmpty()) {
			// no prefix binding, nothing to do
			continue;
		}

		// add XML namespace prefix annotations
		final JAnnotationUse xmlSchemaAnnotation = getOrAddXmlSchemaAnnotation(p, xmlSchemaClass);
		if (xmlSchemaAnnotation == null) {
			throw new RuntimeException("Unable to get/add 'XmlSchema' annotation to package [" + p.name() + "]");
		}

		final JAnnotationArrayMember members = xmlSchemaAnnotation.paramArray("xmlns");
		for (Pair pair : list) {
			addNamespacePrefix(xmlNsClass, members, pair.getNamespace(), pair.getPrefix());
		}
	}

	return true;
}
 
开发者ID:Siggen,项目名称:jaxb2-namespace-prefix,代码行数:36,代码来源:NamespacePrefixPlugin.java

示例5: renderClassLevelAnnotations

import com.sun.codemodel.JAnnotationUse; //导入方法依赖的package包/类
private void renderClassLevelAnnotations(JDefinedClass classModel, List<FieldModel> fields) throws Exception {
	JFieldRef constantsClass = classModel.staticRef(Util.CONSTANTS_CLASS_NAME);
	JFieldRef elementsClass = classModel.staticRef(Util.ELEMENTS_CLASS_NAME);
	JClass coreConstants = codeModel.ref(CoreConstants.class);
	JFieldRef commonElementsRef = coreConstants.staticRef("CommonElements");
	
	// XmlRootElement
	JAnnotationUse rootElementAnnotation = classModel.annotate(XmlRootElement.class);
	rootElementAnnotation.param("name", constantsClass.ref(Util.ROOT_ELEMENT_NAME_FIELD));
	
	// XmlAccessorType
	JAnnotationUse xmlAccessorTypeAnnotation = classModel.annotate(XmlAccessorType.class);
	xmlAccessorTypeAnnotation.param("value", XmlAccessType.NONE);
	
	// XmlType
	JAnnotationUse xmlTypeAnnotation = classModel.annotate(XmlType.class);
	xmlTypeAnnotation.param("name", constantsClass.ref(Util.TYPE_NAME_FIELD));
	JAnnotationArrayMember propOrderMember = xmlTypeAnnotation.paramArray("propOrder");
	for (FieldModel field : fields) {
		if (Util.isCommonElement(field.fieldName)) {
			propOrderMember.param(commonElementsRef.ref(Util.toConstantsVariable(field.fieldName)));
		} else {
			propOrderMember.param(elementsClass.ref(Util.toConstantsVariable(field.fieldName)));
		}
	}
	propOrderMember.param(commonElementsRef.ref("FUTURE_ELEMENTS"));
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:28,代码来源:ImmutableJaxbGenerator.java

示例6: testClassWithPersistenceContextWithWithOverwrittenConfiguration

import com.sun.codemodel.JAnnotationUse; //导入方法依赖的package包/类
@Test
public void testClassWithPersistenceContextWithWithOverwrittenConfiguration() throws Exception {
    // GIVEN
    final JCodeModel jCodeModel = new JCodeModel();
    final JPackage jp = jCodeModel.rootPackage();
    final JDefinedClass jClass = jp._class(JMod.PUBLIC, "ClassUnderTest");
    final JFieldVar ruleField = jClass.field(JMod.PUBLIC, JpaUnitRule.class, "rule");
    ruleField.annotate(Rule.class);
    final JInvocation instance = JExpr._new(jCodeModel.ref(JpaUnitRule.class)).arg(JExpr.direct("getClass()"));
    ruleField.init(instance);
    final JFieldVar emField = jClass.field(JMod.PRIVATE, EntityManager.class, "em");
    final JAnnotationUse jAnnotation = emField.annotate(PersistenceContext.class);
    jAnnotation.param("unitName", "test-unit-1");
    final JAnnotationArrayMember propArray = jAnnotation.paramArray("properties");
    propArray.annotate(PersistenceProperty.class).param("name", "javax.persistence.jdbc.url").param("value",
            "jdbc:h2:mem:test;DB_CLOSE_DELAY=-1");
    propArray.annotate(PersistenceProperty.class).param("name", "javax.persistence.jdbc.driver").param("value", "org.h2.Driver");
    propArray.annotate(PersistenceProperty.class).param("name", "javax.persistence.jdbc.password").param("value", "test");
    propArray.annotate(PersistenceProperty.class).param("name", "javax.persistence.jdbc.user").param("value", "test");
    final JMethod jMethod = jClass.method(JMod.PUBLIC, jCodeModel.VOID, "testMethod");
    jMethod.annotate(Test.class);

    buildModel(testFolder.getRoot(), jCodeModel);
    compileModel(testFolder.getRoot());

    final Class<?> cut = loadClass(testFolder.getRoot(), jClass.name());
    final BlockJUnit4ClassRunner runner = new BlockJUnit4ClassRunner(cut);

    final RunListener listener = mock(RunListener.class);
    final RunNotifier notifier = new RunNotifier();
    notifier.addListener(listener);

    // WHEN
    runner.run(notifier);

    // THEN
    final ArgumentCaptor<Description> descriptionCaptor = ArgumentCaptor.forClass(Description.class);
    verify(listener).testStarted(descriptionCaptor.capture());
    assertThat(descriptionCaptor.getValue().getClassName(), equalTo("ClassUnderTest"));
    assertThat(descriptionCaptor.getValue().getMethodName(), equalTo("testMethod"));

    verify(listener).testFinished(descriptionCaptor.capture());
    assertThat(descriptionCaptor.getValue().getClassName(), equalTo("ClassUnderTest"));
    assertThat(descriptionCaptor.getValue().getMethodName(), equalTo("testMethod"));
}
 
开发者ID:dadrus,项目名称:jpa-unit,代码行数:46,代码来源:JpaUnitRuleTest.java

示例7: testClassWithPersistenceContextWithWithOverwrittenConfiguration

import com.sun.codemodel.JAnnotationUse; //导入方法依赖的package包/类
@Test
public void testClassWithPersistenceContextWithWithOverwrittenConfiguration() throws Exception {
    // GIVEN
    final JCodeModel jCodeModel = new JCodeModel();
    final JPackage jp = jCodeModel.rootPackage();
    final JDefinedClass jClass = jp._class(JMod.PUBLIC, "ClassUnderTest");
    final JAnnotationUse jAnnotationUse = jClass.annotate(RunWith.class);
    jAnnotationUse.param("value", JpaUnitRunner.class);
    final JFieldVar emField = jClass.field(JMod.PRIVATE, EntityManager.class, "em");
    final JAnnotationUse jAnnotation = emField.annotate(PersistenceContext.class);
    jAnnotation.param("unitName", "test-unit-1");
    final JAnnotationArrayMember propArray = jAnnotation.paramArray("properties");
    propArray.annotate(PersistenceProperty.class).param("name", "javax.persistence.jdbc.url").param("value",
            "jdbc:h2:mem:test;DB_CLOSE_DELAY=-1");
    propArray.annotate(PersistenceProperty.class).param("name", "javax.persistence.jdbc.driver").param("value", "org.h2.Driver");
    propArray.annotate(PersistenceProperty.class).param("name", "javax.persistence.jdbc.password").param("value", "test");
    propArray.annotate(PersistenceProperty.class).param("name", "javax.persistence.jdbc.user").param("value", "test");
    final JMethod jMethod = jClass.method(JMod.PUBLIC, jCodeModel.VOID, "testMethod");
    jMethod.annotate(Test.class);

    buildModel(testFolder.getRoot(), jCodeModel);
    compileModel(testFolder.getRoot());

    final Class<?> cut = loadClass(testFolder.getRoot(), jClass.name());
    final JpaUnitRunner runner = new JpaUnitRunner(cut);

    final RunListener listener = mock(RunListener.class);
    final RunNotifier notifier = new RunNotifier();
    notifier.addListener(listener);

    // WHEN
    runner.run(notifier);

    // THEN
    final ArgumentCaptor<Description> descriptionCaptor = ArgumentCaptor.forClass(Description.class);
    verify(listener).testStarted(descriptionCaptor.capture());
    assertThat(descriptionCaptor.getValue().getClassName(), equalTo("ClassUnderTest"));
    assertThat(descriptionCaptor.getValue().getMethodName(), equalTo("testMethod"));

    verify(listener).testFinished(descriptionCaptor.capture());
    assertThat(descriptionCaptor.getValue().getClassName(), equalTo("ClassUnderTest"));
    assertThat(descriptionCaptor.getValue().getMethodName(), equalTo("testMethod"));
}
 
开发者ID:dadrus,项目名称:jpa-unit,代码行数:44,代码来源:JpaUnitRunnerTest.java

示例8: buildFieldsAndMethods

import com.sun.codemodel.JAnnotationUse; //导入方法依赖的package包/类
@Override
public void buildFieldsAndMethods(JDefinedClass jc) {
	
	// serial uuid
	JFieldVar jfSerial = jc.field(JMod.PUBLIC | JMod.STATIC | JMod.FINAL, long.class, "serialVersionUID");
	jfSerial.init(JExpr.lit(-4307963520301090920L));
	
	// individual
	JFieldVar jfIndividual = jc.field(JMod.PRIVATE , org.openhds.domain.model.Individual.class, "individual");
	jfIndividual.annotate(org.openhds.domain.constraint.Searchable.class);
	jfIndividual.annotate(org.openhds.domain.constraint.CheckEntityNotVoided.class);
	jfIndividual.annotate(org.openhds.domain.constraint.CheckIndividualNotUnknown.class);
	JAnnotationUse jfMotherCascade = jfIndividual.annotate(javax.persistence.ManyToOne.class);
	JAnnotationArrayMember motherArray = jfMotherCascade.paramArray("cascade");
	motherArray.param(javax.persistence.CascadeType.ALL);	
	JAnnotationUse jaMotherDesc = jfIndividual.annotate(org.openhds.domain.annotations.Description.class);
	jaMotherDesc.param("description", "Individual who deceased, identified by the external id.");
	
	// getter
	JMethod jmgIndividual = jc.method(JMod.PUBLIC, org.openhds.domain.model.Individual.class, "getIndividual");
	JBlock jmgIndividualBlock = jmgIndividual.body();
	jmgIndividualBlock._return(jfIndividual);
	
	// setter
	JMethod jmsIndividual = jc.method(JMod.PUBLIC, void.class, "setIndividual");
	JVar jvarIndividual = jmsIndividual.param(org.openhds.domain.model.Individual.class, "indiv");
	JBlock jmsIndividualBlock = jmsIndividual.body();
	jmsIndividualBlock.assign(jfIndividual, jvarIndividual);
			
	// visit
	JFieldVar jfVisit = jc.field(JMod.PRIVATE , org.openhds.domain.model.Visit.class, "visit");
	jfVisit.annotate(org.openhds.domain.constraint.Searchable.class);
	jfVisit.annotate(javax.persistence.ManyToOne.class);
	JAnnotationUse jaVisitDesc = jfVisit.annotate(org.openhds.domain.annotations.Description.class);
	jaVisitDesc.param("description", "Visit that is associated with the verbal autopsy, identified by the external id.");
	
	// getter
	JMethod jmgVisit = jc.method(JMod.PUBLIC, org.openhds.domain.model.Visit.class, "getVisit");
	JBlock jmgVisitBlock = jmgVisit.body();
	jmgVisitBlock._return(jfVisit);
	
	// setter
	JMethod jmsVisit = jc.method(JMod.PUBLIC, void.class, "setVisit");
	JVar jvarVisit = jmsVisit.param(org.openhds.domain.model.Visit.class, "vis");
	JBlock jmsVisitBlock = jmsVisit.body();
	jmsVisitBlock.assign(jfVisit, jvarVisit);
	
	// recordedDate
	JFieldVar jfRecordedDate = jc.field(JMod.PRIVATE , java.util.Calendar.class, "recordedDate");
	jfRecordedDate.annotate(javax.validation.constraints.Past.class);
	JAnnotationUse jaTemporal = jfRecordedDate.annotate(javax.persistence.Temporal.class);
	jaTemporal.param("value", javax.persistence.TemporalType.DATE);
	JAnnotationUse jaRecordedDateDesc = jfRecordedDate.annotate(org.openhds.domain.annotations.Description.class);
	jaRecordedDateDesc.param("description", "Date of interview for the verbal autopsy.");
	
	// getter
	JMethod jmgRecordedDate = jc.method(JMod.PUBLIC, java.util.Calendar.class, "getRecordedDate");
	JAnnotationUse jaXmlRecordedDate = jmgRecordedDate.annotate(javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter.class);
	jaXmlRecordedDate.param("value", CalendarAdapter.class);
	JBlock jmgRecordedDateBlock = jmgRecordedDate.body();
	jmgRecordedDateBlock._return(jfRecordedDate);
	
	// setter
	JMethod jmsRecordedDate = jc.method(JMod.PUBLIC, void.class, "setRecordedDate");
	JVar jvarRecordedDate = jmsRecordedDate.param(java.util.Calendar.class, "date");
	JBlock jmsRecordedDateBlock = jmsRecordedDate.body();
	jmsRecordedDateBlock.assign(jfRecordedDate, jvarRecordedDate);
}
 
开发者ID:OpenHDS,项目名称:openhds-server,代码行数:69,代码来源:AdultVPMTemplateBuilder.java

示例9: buildFieldsAndMethods

import com.sun.codemodel.JAnnotationUse; //导入方法依赖的package包/类
public void buildFieldsAndMethods(JDefinedClass jc) {
	
	// serial uuid
	JFieldVar jfSerial = jc.field(JMod.PUBLIC | JMod.STATIC | JMod.FINAL, long.class, "serialVersionUID");
	jfSerial.init(JExpr.lit(7646636209213391150L));
	
	// individual
	JFieldVar jfIndividual = jc.field(JMod.PRIVATE , org.openhds.domain.model.Individual.class, "individual");
	jfIndividual.annotate(org.openhds.domain.constraint.Searchable.class);
	jfIndividual.annotate(org.openhds.domain.constraint.CheckEntityNotVoided.class);
	jfIndividual.annotate(org.openhds.domain.constraint.CheckIndividualNotUnknown.class);
	JAnnotationUse jfMotherCascade = jfIndividual.annotate(javax.persistence.ManyToOne.class);
	JAnnotationArrayMember motherArray = jfMotherCascade.paramArray("cascade");
	motherArray.param(javax.persistence.CascadeType.ALL);	
	JAnnotationUse jaMotherDesc = jfIndividual.annotate(org.openhds.domain.annotations.Description.class);
	jaMotherDesc.param("description", "Individual who deceased, identified by the external id.");
	
	// getter
	JMethod jmgIndividual = jc.method(JMod.PUBLIC, org.openhds.domain.model.Individual.class, "getIndividual");
	JBlock jmgIndividualBlock = jmgIndividual.body();
	jmgIndividualBlock._return(jfIndividual);
	
	// setter
	JMethod jmsIndividual = jc.method(JMod.PUBLIC, void.class, "setIndividual");
	JVar jvarIndividual = jmsIndividual.param(org.openhds.domain.model.Individual.class, "indiv");
	JBlock jmsIndividualBlock = jmsIndividual.body();
	jmsIndividualBlock.assign(jfIndividual, jvarIndividual);
			
	// visit
	JFieldVar jfVisit = jc.field(JMod.PRIVATE , org.openhds.domain.model.Visit.class, "visit");
	jfVisit.annotate(javax.persistence.ManyToOne.class);
	JAnnotationUse jaVisitDesc = jfVisit.annotate(org.openhds.domain.annotations.Description.class);
	jaVisitDesc.param("description", "Visit that is associated with the verbal autopsy, identified by the external id.");
	
	// getter
	JMethod jmgVisit = jc.method(JMod.PUBLIC, org.openhds.domain.model.Visit.class, "getVisit");
	JBlock jmgVisitBlock = jmgVisit.body();
	jmgVisitBlock._return(jfVisit);
	
	// setter
	JMethod jmsVisit = jc.method(JMod.PUBLIC, void.class, "setVisit");
	JVar jvarVisit = jmsVisit.param(org.openhds.domain.model.Visit.class, "vis");
	JBlock jmsVisitBlock = jmsVisit.body();
	jmsVisitBlock.assign(jfVisit, jvarVisit);
	
	// recordedDate
	JFieldVar jfDeathDate = jc.field(JMod.PRIVATE , java.util.Calendar.class, "recordedDate");
	JAnnotationUse jaPast = jfDeathDate.annotate(javax.validation.constraints.Past.class);
	jaPast.param("message", "Death date should be in the past");
	JAnnotationUse jaTemporal = jfDeathDate.annotate(javax.persistence.Temporal.class);
	jaTemporal.param("value", javax.persistence.TemporalType.DATE);
	JAnnotationUse jaDeathDateDesc = jfDeathDate.annotate(org.openhds.domain.annotations.Description.class);
	jaDeathDateDesc.param("description", "Date of the Death.");
	
	// getter
	JMethod jmgDeathDate = jc.method(JMod.PUBLIC, java.util.Calendar.class, "getRecordedDate");
	JAnnotationUse jaXmlDeathDate = jmgDeathDate.annotate(javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter.class);
	jaXmlDeathDate.param("value", CalendarAdapter.class);
	JBlock jmgDeathDateBlock = jmgDeathDate.body();
	jmgDeathDateBlock._return(jfDeathDate);
	
	// setter
	JMethod jmsDeathDate = jc.method(JMod.PUBLIC, void.class, "setRecordedDate");
	JVar jvarDeathDate = jmsDeathDate.param(java.util.Calendar.class, "date");
	JBlock jmsDeathDateBlock = jmsDeathDate.body();
	jmsDeathDateBlock.assign(jfDeathDate, jvarDeathDate);
	
}
 
开发者ID:OpenHDS,项目名称:openhds-server,代码行数:69,代码来源:PostNeoNatalVPMTemplateBuilder.java

示例10: buildFieldsAndMethods

import com.sun.codemodel.JAnnotationUse; //导入方法依赖的package包/类
@Override
public void buildFieldsAndMethods(JDefinedClass jc) {
	
	// serial uuid
	JFieldVar jfSerial = jc.field(JMod.PUBLIC | JMod.STATIC | JMod.FINAL, long.class, "serialVersionUID");
	jfSerial.init(JExpr.lit(5627673295092064030L));
	
	// individual
	JFieldVar jfIndividual = jc.field(JMod.PRIVATE , org.openhds.domain.model.Individual.class, "individual");
	jfIndividual.annotate(org.openhds.domain.constraint.Searchable.class);
	jfIndividual.annotate(org.openhds.domain.constraint.CheckEntityNotVoided.class);
	jfIndividual.annotate(org.openhds.domain.constraint.CheckIndividualNotUnknown.class);
	JAnnotationUse jfMotherCascade = jfIndividual.annotate(javax.persistence.ManyToOne.class);
	JAnnotationArrayMember motherArray = jfMotherCascade.paramArray("cascade");
	motherArray.param(javax.persistence.CascadeType.ALL);	
	JAnnotationUse jaMotherDesc = jfIndividual.annotate(org.openhds.domain.annotations.Description.class);
	jaMotherDesc.param("description", "Individual who deceased, identified by the external id.");
	
	// getter
	JMethod jmgIndividual = jc.method(JMod.PUBLIC, org.openhds.domain.model.Individual.class, "getIndividual");
	JBlock jmgIndividualBlock = jmgIndividual.body();
	jmgIndividualBlock._return(jfIndividual);
	
	// setter
	JMethod jmsIndividual = jc.method(JMod.PUBLIC, void.class, "setIndividual");
	JVar jvarIndividual = jmsIndividual.param(org.openhds.domain.model.Individual.class, "indiv");
	JBlock jmsIndividualBlock = jmsIndividual.body();
	jmsIndividualBlock.assign(jfIndividual, jvarIndividual);
			
	// visit
	JFieldVar jfVisit = jc.field(JMod.PRIVATE , org.openhds.domain.model.Visit.class, "visit");
	jfVisit.annotate(org.openhds.domain.constraint.Searchable.class);
	jfVisit.annotate(javax.persistence.ManyToOne.class);
	JAnnotationUse jaVisitDesc = jfVisit.annotate(org.openhds.domain.annotations.Description.class);
	jaVisitDesc.param("description", "Visit that is associated with the verbal autopsy, identified by the external id.");
	
	// getter
	JMethod jmgVisit = jc.method(JMod.PUBLIC, org.openhds.domain.model.Visit.class, "getVisit");
	JBlock jmgVisitBlock = jmgVisit.body();
	jmgVisitBlock._return(jfVisit);
	
	// setter
	JMethod jmsVisit = jc.method(JMod.PUBLIC, void.class, "setVisit");
	JVar jvarVisit = jmsVisit.param(org.openhds.domain.model.Visit.class, "vis");
	JBlock jmsVisitBlock = jmsVisit.body();
	jmsVisitBlock.assign(jfVisit, jvarVisit);
	
	// recordedDate
	JFieldVar jfRecordedDate = jc.field(JMod.PRIVATE , java.util.Calendar.class, "recordedDate");
	jfRecordedDate.annotate(javax.validation.constraints.Past.class);
	JAnnotationUse jaTemporal = jfRecordedDate.annotate(javax.persistence.Temporal.class);
	jaTemporal.param("value", javax.persistence.TemporalType.DATE);
	JAnnotationUse jaRecordedDateDesc = jfRecordedDate.annotate(org.openhds.domain.annotations.Description.class);
	jaRecordedDateDesc.param("description", "Date of interview for the verbal autopsy.");
	
	// getter
	JMethod jmgRecordedDate = jc.method(JMod.PUBLIC, java.util.Calendar.class, "getRecordedDate");
	JAnnotationUse jaXmlRecordedDate = jmgRecordedDate.annotate(javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter.class);
	jaXmlRecordedDate.param("value", CalendarAdapter.class);
	JBlock jmgRecordedDateBlock = jmgRecordedDate.body();
	jmgRecordedDateBlock._return(jfRecordedDate);
	
	// setter
	JMethod jmsRecordedDate = jc.method(JMod.PUBLIC, void.class, "setRecordedDate");
	JVar jvarRecordedDate = jmsRecordedDate.param(java.util.Calendar.class, "date");
	JBlock jmsRecordedDateBlock = jmsRecordedDate.body();
	jmsRecordedDateBlock.assign(jfRecordedDate, jvarRecordedDate);
}
 
开发者ID:OpenHDS,项目名称:openhds-server,代码行数:69,代码来源:NeoNatalVPMTemplateBuilder.java


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