下面列出了javax.persistence.AccessType#PROPERTY 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
protected static AccessType getAccessType(Class<?> containerJavaType, String propertyName) {
Field field = fieldOrNull( containerJavaType, propertyName );
AccessType fieldAccessType = getAccessTypeOrNull( field );
if ( fieldAccessType != null ) {
return fieldAccessType;
}
AccessType methodAccessType = getAccessTypeOrNull( getterMethodOrNull( containerJavaType, propertyName ) );
if ( methodAccessType != null ) {
return methodAccessType;
}
// No @Access on property or field; check to see if containerJavaType has an explicit @Access
AccessType classAccessType = getAccessTypeOrNull( containerJavaType );
if ( classAccessType != null ) {
return classAccessType;
}
return field != null ? AccessType.FIELD : AccessType.PROPERTY;
}
public static <T extends Annotation> T getAnnotation(CtClass ctClass, String attributeName, Class<T> annotation) {
AccessType classAccessType = getAccessTypeOrNull( ctClass );
CtField field = findFieldOrNull( ctClass, attributeName );
CtMethod getter = findGetterOrNull( ctClass, attributeName );
if ( classAccessType == AccessType.FIELD || ( field != null && getAccessTypeOrNull( field ) == AccessType.FIELD ) ) {
return field == null ? null : getAnnotationOrNull( field, annotation );
}
if ( classAccessType == AccessType.PROPERTY || ( getter != null && getAccessTypeOrNull( getter ) == AccessType.PROPERTY ) ) {
return getter == null ? null : getAnnotationOrNull( getter, annotation );
}
T found = ( getter == null ? null : getAnnotationOrNull( getter, annotation ) );
if ( found == null && field != null ) {
return getAnnotationOrNull( field, annotation );
}
return found;
}
@Access(AccessType.PROPERTY)
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
public long getId() {
return super.getId();
}
@Column(length = 1024)
@Access(AccessType.PROPERTY)
public String getMagFilmeAsString() {
StringBuffer res = new StringBuffer();
Set<Filme> set = getMagFilme();
if (set != null) {
for (Filme f : set) {
if (res.length() > 0) {
res.append(",");
}
res.append(f.name());
}
}
return res.toString();
}
@Access(AccessType.PROPERTY)
@Column(name = "networktype")
@Enumerated(EnumType.STRING)
public NetworkType getNetworkType() {
return super.getNetworkType();
}
@Access(AccessType.PROPERTY)
@Column(name = "allocation_state")
@Enumerated(value = EnumType.STRING)
public AllocationState getAllocationState() {
return super.getAllocationState();
}
@Override
@Access(AccessType.PROPERTY)
@Column(name = "created_by", insertable = true, updatable = false, nullable = false, length = 64)
public String getCreatedBy() {
return createdBy;
}
@Access(AccessType.PROPERTY)
@Column(name = "dhcp_provider")
public String getDhcpProvider() {
return super.getDhcpProvider();
}
@Access(AccessType.PROPERTY)
@Column(name = "dns2")
public String getDns2() {
return super.getDns2();
}
@Access(AccessType.PROPERTY)
@Column(name = "dns_provider")
public String getDnsProvider() {
return super.getDnsProvider();
}
@Access(AccessType.PROPERTY)
@Column(name = "domain_id")
public Long getDomainId() {
return super.getDomainId();
}
@Access(AccessType.PROPERTY)
public int getMonthlyFee() {
// (we want to have it in the DB also so we can query - see below)
return 0 + (isRetirementProtection() ? 1111 : 0) + (isLazinessProtection() ? 8888 : 0);
}
@Access(AccessType.PROPERTY)
@Column(name = "router_mac_address", updatable = false, nullable = false)
public String getRouterMacAddress() {
return super.getRouterMacAddress();
}
@Override
@Access(AccessType.PROPERTY)
@Column(name = "created_at", insertable = true, updatable = false, nullable = false)
public long getCreatedAt() {
return createdAt;
}
@Access(AccessType.PROPERTY)
@Column(name = "guest_network_cidr")
public String getGuestNetworkCidr() {
return super.getGuestNetworkCidr();
}
@Access(AccessType.PROPERTY)
@Column(name = "uuid")
public String getUuid() {
return super.getUuid();
}
@Access(AccessType.PROPERTY)
@Column(name = "internal_dns2")
public String getInternalDns2() {
return super.getInternalDns2();
}
@Override
@Access(AccessType.PROPERTY)
@Column(name = "last_modified_at", insertable = true, updatable = true, nullable = false)
public long getLastModifiedAt() {
return lastModifiedAt;
}
@Access(AccessType.PROPERTY)
@Column(name = "ip6_dns2")
public String getIp6Dns2() {
return super.getIp6Dns2();
}