Examples of AttributeAccessor


Examples of org.eclipse.persistence.mappings.AttributeAccessor

    else if (mapping.isCollectionMapping()) {
      return mapping.getContainerPolicy().getContainerClass();
    }

    // Property mapping
    AttributeAccessor accessor = mapping.getAttributeAccessor();

    // Attribute
    if (accessor.isInstanceVariableAttributeAccessor()) {
      InstanceVariableAttributeAccessor attributeAccessor = (InstanceVariableAttributeAccessor) accessor;
      Field field = attributeAccessor.getAttributeField();

      if (field == null) {
        try {
          field = mapping.getDescriptor().getJavaClass().getDeclaredField(attributeAccessor.getAttributeName());
        }
        catch (Exception e) {}
      }

      return field.getType();
    }

    // Property
    if (accessor.isMethodAttributeAccessor()) {
      MethodAttributeAccessor methodAccessor = (MethodAttributeAccessor) accessor;
      Method method = methodAccessor.getGetMethod();

      if (method == null) {
        try {
          method = mapping.getDescriptor().getJavaClass().getDeclaredMethod(methodAccessor.getGetMethodName());
        }
        catch (Exception e) {}
      }

      return method.getReturnType();
    }

    // Anything else
    return accessor.getAttributeClass();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.