/** * Returns {@code true} if the OData type is a structured type, {@code false} otherwise. * * @param type The OData type. * @return {@code true} if the OData type is a structured type, {@code false} otherwise. */ public static boolean isStructuredType(Type type) { MetaType metaType = type.getMetaType(); return metaType == MetaType.ENTITY || metaType == MetaType.COMPLEX; }
/** * Returns {@code true} if the OData type is a complex type, {@code false} otherwise. * * @param type The OData type. * @return {@code true} if the OData type is a complex type, {@code false} otherwise. */ public static boolean isComplexType(Type type) { return type.getMetaType() == MetaType.COMPLEX; }
/** * Returns {@code true} if the OData type is a primitive type, {@code false} otherwise. * * @param type The OData type. * @return {@code true} if the OData type is a primitive type, {@code false} otherwise. */ public static boolean isPrimitiveType(Type type) { return type.getMetaType() == MetaType.PRIMITIVE; }
/** * Returns {@code true} if the OData type is a primitive type, {@code false} otherwise. * * @param type The OData type. * @return {@code true} if the OData type is a primitive type, {@code false} otherwise. */ public static boolean isPrimitiveType(Type type) { return type.getMetaType() == MetaType.PRIMITIVE; }
/** * Returns {@code true} if the OData type is a structured type, {@code false} otherwise. * * @param type The OData type. * @return {@code true} if the OData type is a structured type, {@code false} otherwise. */ public static boolean isStructuredType(Type type) { MetaType metaType = type.getMetaType(); return metaType == MetaType.ENTITY || metaType == MetaType.COMPLEX; }
/** * Returns {@code true} if the OData type is an entity type, {@code false} otherwise. * * @param type The OData type. * @return {@code true} if the OData type is an entity type, {@code false} otherwise. */ public static boolean isEntityType(Type type) { return type.getMetaType() == MetaType.ENTITY; }
/** * Returns {@code true} if the OData type is a complex type, {@code false} otherwise. * * @param type The OData type. * @return {@code true} if the OData type is a complex type, {@code false} otherwise. */ public static boolean isComplexType(Type type) { return type.getMetaType() == MetaType.COMPLEX; }
/** * Returns {@code true} if the OData type is an entity type, {@code false} otherwise. * * @param type The OData type. * @return {@code true} if the OData type is an entity type, {@code false} otherwise. */ public static boolean isEntityType(Type type) { return type.getMetaType() == MetaType.ENTITY; }
/** * Check if the parsed OData URI is a query and it results in an entity or a collection of entities. * * @param uri The parsed OData URI. * @param entityDataModel The Entity Data Model. * @return {@code true} if it is about an entity query. */ protected boolean isEntityQuery(ODataUri uri, EntityDataModel entityDataModel) { return getTargetType(uri, entityDataModel).map(t -> t.getMetaType() == MetaType.ENTITY).orElse(false); }
/** * Check if the parsed OData URI is a query and it results in something that is not an entity or a collection of * entities; for example a primitive value, complex object, enum value or a collection of any of those. * * @param uri The parsed OData URI. * @param entityDataModel The entity data model * @return {@code true} if it is about an entity query. */ protected boolean isNonEntityQuery(ODataUri uri, EntityDataModel entityDataModel) { return getTargetType(uri, entityDataModel).map(t -> t.getMetaType() != MetaType.ENTITY).orElse(false); }
private EntityType getEntityType(Object entity) { final Type type = entityDataModel.getType(entity.getClass()); if (type.getMetaType() != ENTITY) { throw new UnsupportedOperationException("Unsupported type: " + type); } return (EntityType) type; } }
/** * Check if the parsed OData URI is a query and it results in something that is not an entity or a collection of * entities; for example a primitive value, complex object, enum value or a collection of any of those. * * @param uri The parsed OData URI. * @param entityDataModel The entity data model * @return {@code true} if it is about an entity query. */ protected boolean isNonEntityQuery(ODataUri uri, EntityDataModel entityDataModel) { return getTargetType(uri, entityDataModel).map(t -> t.getMetaType() != MetaType.ENTITY).orElse(false); }
private EntityType getEntityType(Object entity) { final Type type = entityDataModel.getType(entity.getClass()); if (type.getMetaType() != ENTITY) { throw new UnsupportedOperationException("Unsupported type: " + type); } return (EntityType) type; } }
/** * Check if the parsed OData URI is a query and it results in an entity or a collection of entities. * * @param uri The parsed OData URI. * @param entityDataModel The Entity Data Model. * @return {@code true} if it is about an entity query. */ protected boolean isEntityQuery(ODataUri uri, EntityDataModel entityDataModel) { return getTargetType(uri, entityDataModel).map(t -> t.getMetaType() == MetaType.ENTITY).orElse(false); }
/** * Checks if the specified OData type is a complex type and throws an exception if it is not. * * @param type The OData type. * @return The OData type. * @throws ODataSystemException If the OData type is not a complex type. */ public static ComplexType checkIsComplexType(Type type) { if (!isComplexType(type)) { throw new ODataSystemException("A complex type is required, but '" + type.getFullyQualifiedName() + "' is not a complex type: " + type.getMetaType()); } return (ComplexType) type; }
/** * Checks if the specified OData type is a complex type and throws an exception if it is not. * * @param type The OData type. * @return The OData type. * @throws ODataSystemException If the OData type is not a complex type. */ public static ComplexType checkIsComplexType(Type type) { if (!isComplexType(type)) { throw new ODataSystemException("A complex type is required, but '" + type.getFullyQualifiedName() + "' is not a complex type: " + type.getMetaType()); } return (ComplexType) type; }
/** * Checks if the specified OData type is a structured type and throws an exception if it is not. * * @param type The OData type. * @return The OData type. * @throws ODataSystemException If the OData type is not a structured type. */ public static StructuredType checkIsStructuredType(Type type) { if (!isStructuredType(type)) { throw new ODataSystemException("A structured type is required, but '" + type.getFullyQualifiedName() + "' is not a structured type: " + type.getMetaType()); } return (StructuredType) type; }
/** * Checks if the specified OData type is an entity type and throws an exception if it is not. * * @param type The OData type. * @return The OData type. * @throws ODataSystemException If the OData type is not an entity type. */ public static EntityType checkIsEntityType(Type type) { if (!isEntityType(type)) { throw new ODataSystemException("An entity type is required, but '" + type.getFullyQualifiedName() + "' is not an entity type: " + type.getMetaType()); } return (EntityType) type; }
private void validateEntityData(ODataRequest oDataRequest, ODataUri oDataUri, Object entityData) throws ODataException { Type targetType = getRequestType(oDataRequest, oDataUri); if (!MetaType.ENTITY.equals(targetType.getMetaType())) { throw new ODataBadRequestException("The body of the write request must contain a valid entity."); } WriteMethodUtil.validateProperties(entityData, entityDataModel); } }
private void validateEntityData(ODataRequest oDataRequest, ODataUri oDataUri, Object entityData) throws ODataException { Type targetType = getRequestType(oDataRequest, oDataUri); if (!MetaType.ENTITY.equals(targetType.getMetaType())) { throw new ODataBadRequestException("The body of the write request must contain a valid entity."); } WriteMethodUtil.validateProperties(entityData, entityDataModel); } }