private void bindMemberPermissions(Map<String, ParseTree> fieldPermissions, AccessibleObject field, Class<? extends Annotation> annotationClass) { Annotation annotation = field.getAnnotation(annotationClass); if (annotation != null) { ParseTree permissions = getPermissionExpressionTree(annotationClass, annotation); fieldPermissions.put(EntityBinding.getFieldName(field), permissions); } }
private void bindMemberPermissions(Map<String, ParseTree> fieldPermissions, AccessibleObject field, Class<? extends Annotation> annotationClass) { Annotation annotation = field.getAnnotation(annotationClass); if (annotation != null) { ParseTree permissions = getPermissionExpressionTree(annotationClass, annotation); fieldPermissions.put(EntityBinding.getFieldName(field), permissions); } }
/** * Bind an id field to an entity. * * @param cls Class type to bind fields * @param type JSON API type identifier * @param fieldOrMethod Field or method to bind */ private void bindEntityId(Class<?> cls, String type, AccessibleObject fieldOrMethod) { String fieldName = getFieldName(fieldOrMethod); Class<?> fieldType = getFieldType(fieldOrMethod); //Add id field to type map for the entity fieldsToTypes.put(fieldName, fieldType); //Set id field, type, and name idField = fieldOrMethod; idType = fieldType; idFieldName = fieldName; fieldsToValues.put(fieldName, fieldOrMethod); if (idField != null && !fieldOrMethod.equals(idField)) { throw new DuplicateMappingException(type + " " + cls.getName() + ":" + fieldName); } }
/** * Bind an id field to an entity. * * @param cls Class type to bind fields * @param type JSON API type identifier * @param fieldOrMethod Field or method to bind */ private void bindEntityId(Class<?> cls, String type, AccessibleObject fieldOrMethod) { String fieldName = getFieldName(fieldOrMethod); Class<?> fieldType = getFieldType(fieldOrMethod); //Add id field to type map for the entity fieldsToTypes.put(fieldName, fieldType); //Set id field, type, and name idField = fieldOrMethod; idType = fieldType; idFieldName = fieldName; fieldsToValues.put(fieldName, fieldOrMethod); if (idField != null && !fieldOrMethod.equals(idField)) { throw new DuplicateMappingException(type + " " + cls.getName() + ":" + fieldName); } }
/** * Bind an attribute or relationship. * * @param fieldOrMethod Field or method to bind */ private void bindAttrOrRelation(AccessibleObject fieldOrMethod) { boolean isRelation = RELATIONSHIP_TYPES.stream().anyMatch(fieldOrMethod::isAnnotationPresent); String fieldName = getFieldName(fieldOrMethod); Class<?> fieldType = getFieldType(fieldOrMethod); if (fieldName == null || "id".equals(fieldName) || "class".equals(fieldName) || OBJ_METHODS.contains(fieldOrMethod)) { return; // Reserved } if (fieldOrMethod instanceof Method) { Method method = (Method) fieldOrMethod; requestScopeableMethods.put(method, isRequestScopeableMethod(method)); } if (isRelation) { bindRelation(fieldOrMethod, fieldName, fieldType); } else { bindAttr(fieldOrMethod, fieldName, fieldType); } }
/** * Bind an attribute or relationship. * * @param fieldOrMethod Field or method to bind */ private void bindAttrOrRelation(AccessibleObject fieldOrMethod) { boolean isRelation = RELATIONSHIP_TYPES.stream().anyMatch(fieldOrMethod::isAnnotationPresent); String fieldName = getFieldName(fieldOrMethod); Class<?> fieldType = getFieldType(fieldOrMethod); if (fieldName == null || "id".equals(fieldName) || "class".equals(fieldName) || OBJ_METHODS.contains(fieldOrMethod)) { return; // Reserved } if (fieldOrMethod instanceof Method) { Method method = (Method) fieldOrMethod; requestScopeableMethods.put(method, isRequestScopeableMethod(method)); } if (isRelation) { bindRelation(fieldOrMethod, fieldName, fieldType); } else { bindAttr(fieldOrMethod, fieldName, fieldType); } }