本文整理汇总了Java中javax.jdo.annotations.Unique类的典型用法代码示例。如果您正苦于以下问题:Java Unique类的具体用法?Java Unique怎么用?Java Unique使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Unique类属于javax.jdo.annotations包,在下文中一共展示了Unique类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shouldBuildEnhancedDDE
import javax.jdo.annotations.Unique; //导入依赖的package包/类
@Test
public void shouldBuildEnhancedDDE() throws Exception {
FieldDto strField = fieldDto("testStr", String.class);
FieldDto boolField = fieldDto("testBool", Boolean.class);
strField.setReadOnly(true);
boolField.setReadOnly(true);
fields.addAll(asList(
strField, boolField, fieldDto("fromUser", DateTime.class)
));
when(entity.getClassName()).thenReturn(EntBuilderTestClass.class.getName());
ClassData classData = entityBuilder.buildDDE(entity, fields, bundle);
Class<?> builtClass = MDSClassLoader.getStandaloneInstance()
.defineClass(classData.getClassName(), classData.getBytecode());
assertField(builtClass, "testStr", String.class, "defValForTestStr");
assertField(builtClass, "testBool", boolean.class, false, "is");
assertField(builtClass, "fromUser", DateTime.class);
// check annotations
assertNotNull(builtClass.getAnnotation(PersistenceCapable.class));
java.lang.reflect.Field field = builtClass.getDeclaredField("testStr");
assertNotNull(field.getAnnotation(Unique.class));
}
示例2: getDni
import javax.jdo.annotations.Unique; //导入依赖的package包/类
@javax.jdo.annotations.Column(allowsNull="false")
@Title(sequence="1")
@MemberOrder(sequence="1")
@Unique
public String getDni() {
return dni;
}
示例3: isFieldUnique
import javax.jdo.annotations.Unique; //导入依赖的package包/类
private boolean isFieldUnique(AccessibleObject field) {
return ReflectionsUtil.getAnnotationSelfOrAccessor(field, Unique.class) != null;
}
示例4: getNumeroMatricula
import javax.jdo.annotations.Unique; //导入依赖的package包/类
@javax.jdo.annotations.Column(allowsNull="false")
@MemberOrder(sequence="7")
@Unique //Indica que este campo debe ser unico
public String getNumeroMatricula() {
return numeroMatricula;
}