本文整理汇总了Java中com.sun.codemodel.JAnnotationUse.param方法的典型用法代码示例。如果您正苦于以下问题:Java JAnnotationUse.param方法的具体用法?Java JAnnotationUse.param怎么用?Java JAnnotationUse.param使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.codemodel.JAnnotationUse
的用法示例。
在下文中一共展示了JAnnotationUse.param方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: apply
import com.sun.codemodel.JAnnotationUse; //导入方法依赖的package包/类
@Override
public JFieldVar apply(String nodeName, JsonNode node, JFieldVar field, Schema currentSchema) {
if (ruleFactory.getGenerationConfig().isIncludeJsr303Annotations()
&& (node.has("minItems") || node.has("maxItems"))) {
JAnnotationUse annotation = field.annotate(Size.class);
if (node.has("minItems")) {
annotation.param("min", node.get("minItems").asInt());
}
if (node.has("maxItems")) {
annotation.param("max", node.get("maxItems").asInt());
}
}
return field;
}
示例2: 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);
}
}
示例3: apply
import com.sun.codemodel.JAnnotationUse; //导入方法依赖的package包/类
@Override
public JFieldVar apply(String nodeName, JsonNode node, JFieldVar field, Schema currentSchema) {
if (ruleFactory.getGenerationConfig().isIncludeJsr303Annotations()
&& (node.has("minLength") || node.has("maxLength"))) {
JAnnotationUse annotation = field.annotate(Size.class);
if (node.has("minLength")) {
annotation.param("min", node.get("minLength").asInt());
}
if (node.has("maxLength")) {
annotation.param("max", node.get("maxLength").asInt());
}
}
return field;
}
示例4: 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);
}
}
示例5: addJsr303Annotations
import com.sun.codemodel.JAnnotationUse; //导入方法依赖的package包/类
private void addJsr303Annotations(final INamedParam parameter,
final JVar argumentVariable) {
if (isNotBlank(parameter.getPattern())) {
JAnnotationUse patternAnnotation = argumentVariable.annotate(Pattern.class);
patternAnnotation.param("regexp", parameter.getPattern());
}
final Integer minLength = parameter.getMinLength();
final Integer maxLength = parameter.getMaxLength();
if ((minLength != null) || (maxLength != null)) {
final JAnnotationUse sizeAnnotation = argumentVariable
.annotate(Size.class);
if (minLength != null) {
sizeAnnotation.param("min", minLength);
}
if (maxLength != null) {
sizeAnnotation.param("max", maxLength);
}
}
final BigDecimal minimum = parameter.getMinimum();
if (minimum != null) {
addMinMaxConstraint(parameter, "minimum", Min.class, minimum,
argumentVariable);
}
final BigDecimal maximum = parameter.getMaximum();
if (maximum != null) {
addMinMaxConstraint(parameter, "maximum", Max.class, maximum,
argumentVariable);
}
if (parameter.isRequired()) {
argumentVariable.annotate(NotNull.class);
}
}
示例6: testClassWithPersistenceContextWithKonfiguredUnitNameSpecified
import com.sun.codemodel.JAnnotationUse; //导入方法依赖的package包/类
@Test
public void testClassWithPersistenceContextWithKonfiguredUnitNameSpecified() 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 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"));
}
示例7: generateModel
import com.sun.codemodel.JAnnotationUse; //导入方法依赖的package包/类
@BeforeClass
public static void generateModel() throws Exception {
final JCodeModel jCodeModel = new JCodeModel();
final JPackage jp = jCodeModel.rootPackage();
final JDefinedClass jClass = jp._class(JMod.PUBLIC, "ClassUnderTest");
JAnnotationUse jAnnotationUse = jClass.annotate(InitialDataSets.class);
jAnnotationUse.param("value", "Script.file");
jClass.annotate(Cleanup.class);
final JFieldVar jField = jClass.field(JMod.PRIVATE, String.class, "testField");
jField.annotate(PersistenceContext.class);
final JMethod jMethod = jClass.method(JMod.PUBLIC, jCodeModel.VOID, "testMethod");
jAnnotationUse = jMethod.annotate(InitialDataSets.class);
jAnnotationUse.param("value", "InitialDataSets.file");
jAnnotationUse = jMethod.annotate(ApplyScriptsAfter.class);
jAnnotationUse.param("value", "ApplyScriptsAfter.file");
buildModel(testFolder.getRoot(), jCodeModel);
compileModel(testFolder.getRoot());
cut = loadClass(testFolder.getRoot(), jClass.name());
}
示例8: visitAttributePropertyInfo
import com.sun.codemodel.JAnnotationUse; //导入方法依赖的package包/类
public Void visitAttributePropertyInfo(
MAttributePropertyInfo<NType, NClass> info) {
JAnnotationUse annotation = this.annotatable
.annotate(XmlAttribute.class);
final String name = info.getAttributeName().getLocalPart();
final String namespace = info.getAttributeName().getNamespaceURI();
annotation.param("name", name);
// generate namespace property?
if (!namespace.equals("")) { // assume attributeFormDefault ==
// unqualified
annotation.param("namespace", namespace);
}
// TODO
// if(info.isRequired()) {
// xaw.required(true);
// }
return null;
}
示例9: buildClassAnnotations
import com.sun.codemodel.JAnnotationUse; //导入方法依赖的package包/类
public void buildClassAnnotations(JDefinedClass jc) {
// create Description annotation
JAnnotationUse jad = jc.annotate(org.openhds.domain.annotations.Description.class);
jad.param("description", "An Individual represents one who is a part of the study. " +
"Each Individual is identified by a uniquely generated external identifier which " +
"the system uses internally. Information about the Individual such as name, gender, " +
"date of birth, and parents are stored here. An Individual may be associated with many " +
"Residencies, Relationships, and Memberships.");
jc.annotate(org.openhds.domain.constraint.CheckMotherFatherNotIndividual.class);
// create Entity annotation
jc.annotate(javax.persistence.Entity.class);
JAnnotationUse jat = jc.annotate(javax.persistence.Table.class);
jat.param("name", "individual");
//XmlAnnotation
JAnnotationUse jxmlRoot = jc.annotate(javax.xml.bind.annotation.XmlRootElement.class);
jxmlRoot.param("name", "individual");
}
示例10: buildClassAnnotations
import com.sun.codemodel.JAnnotationUse; //导入方法依赖的package包/类
@Override
public void buildClassAnnotations(JDefinedClass jc) {
// create Description annotation
JAnnotationUse jad = jc.annotate(org.openhds.domain.annotations.Description.class);
jad.param("description", "A Vaccination is filled out for ever Pregnancy Outcome. It contains a list of " +
"dates in which a child has received various immunications.");
// create Entity annotation
jc.annotate(javax.persistence.Entity.class);
JAnnotationUse jat = jc.annotate(javax.persistence.Table.class);
jat.param("name", "vaccination");
JAnnotationUse jxmlRoot = jc.annotate(javax.xml.bind.annotation.XmlRootElement.class);
jxmlRoot.param("name", "vaccination");
}
示例11: buildClassAnnotations
import com.sun.codemodel.JAnnotationUse; //导入方法依赖的package包/类
@Override
public void buildClassAnnotations(JDefinedClass jc) {
// create Description annotation
JAnnotationUse jad = jc.annotate(org.openhds.domain.annotations.Description.class);
jad.param("description", "An InMigration represents a migration into the study area. " +
"It contains information about the Individual who is in-migrating to a particular " +
"Residency. It also contains information about the origin, date, and reason the " +
"Individual is migrating as well as the Visit that is associated with the migration.");
// create Entity annotation
jc.annotate(javax.persistence.Entity.class);
//create CheckDropdownMenuItemSelected constraint
jc.annotate(org.openhds.domain.constraint.CheckDropdownMenuItemSelected.class);
jc.annotate(org.openhds.domain.constraint.CheckInMigrationAfterDob.class);
JAnnotationUse jat = jc.annotate(javax.persistence.Table.class);
jat.param("name", "inmigration");
JAnnotationUse jxmlRoot = jc.annotate(javax.xml.bind.annotation.XmlRootElement.class);
jxmlRoot.param("name", "inmigration");
}
示例12: apply
import com.sun.codemodel.JAnnotationUse; //导入方法依赖的package包/类
@Override
public JFieldVar apply(String nodeName, JsonNode node, JFieldVar field, Schema currentSchema) {
if (ruleFactory.getGenerationConfig().isIncludeJsr303Annotations()
&& (node.has("minLength") || node.has("maxLength"))) {
JAnnotationUse annotation = field.annotate(Size.class);
if (node.has("minLength")) {
annotation.param("min", node.get("minLength").asInt());
}
if (node.has("maxLength")) {
annotation.param("max", node.get("maxLength").asInt());
}
}
return field;
}
示例13: buildClassAnnotations
import com.sun.codemodel.JAnnotationUse; //导入方法依赖的package包/类
@Override
public void buildClassAnnotations(JDefinedClass jc) {
// create Description annotation
JAnnotationUse jad = jc.annotate(org.openhds.domain.annotations.Description.class);
jad.param("description", "An OutMigration represents a migration out of the study area." +
"It contains information about the Individual who is out-migrating to a particular" +
"Residency. It also contains information about the destination, date, and reason the" +
"Individual is migrating as well as the Visit associated with the migration.");
// create Entity annotation
jc.annotate(javax.persistence.Entity.class);
JAnnotationUse jat = jc.annotate(javax.persistence.Table.class);
jat.param("name", "outmigration");
JAnnotationUse jxmlRoot = jc.annotate(javax.xml.bind.annotation.XmlRootElement.class);
jxmlRoot.param("name", "outmigration");
}
示例14: buildClassAnnotations
import com.sun.codemodel.JAnnotationUse; //导入方法依赖的package包/类
public void buildClassAnnotations(JDefinedClass jc) {
// create Description annotation
JAnnotationUse jad = jc.annotate(org.openhds.domain.annotations.Description.class);
jad.param("description", "A Visit represents a Field Worker's observation " +
"of a specific Location within the study area at a particular date. It " +
"can be identified by a uniquely generated identifier which the system " +
"uses internally.");
// create Entity annotation
jc.annotate(javax.persistence.Entity.class);
JAnnotationUse jat = jc.annotate(javax.persistence.Table.class);
jat.param("name", "visit");
jc.annotate(javax.xml.bind.annotation.XmlRootElement.class);
}
示例15: buildClassAnnotations
import com.sun.codemodel.JAnnotationUse; //导入方法依赖的package包/类
public void buildClassAnnotations(JDefinedClass jc) {
// create Description annotation
JAnnotationUse jad = jc.annotate(org.openhds.domain.annotations.Description.class);
jad.param("description", "A Social Group represents a distinct family within the " +
"study area. Social Groups are identified by a uniquely generated identifier " +
"which the system uses internally. A Social Group has one head of house which " +
"all Membership relationships are based on.");
// create Entity annotation
jc.annotate(javax.persistence.Entity.class);
JAnnotationUse jat = jc.annotate(javax.persistence.Table.class);
jat.param("name", "socialgroup");
//XmlAnnotation
JAnnotationUse jxmlRoot = jc.annotate(javax.xml.bind.annotation.XmlRootElement.class);
jxmlRoot.param("name", "socialgroup");
}