/** * 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; }
@Override public Type getType(Class<?> javaType) { // NOTE: Only entity types, complex types and enum types defined in this schema are searched here. // Primitive types are not handled here. Type definitions are not searched; they map to their corresponding // underlying primitive type, and there can potentially be multiple type definitions with the same underlying // primitive type, therefore it is not useful to find a type definition corresponding to a particular primitive // Java type. for (Type type : types.values()) { if (javaType.equals(type.getJavaType())) { return type; } } return null; }
public Builder addType(Type type) { this.typesBuilder.put(type.getName(), type); return this; }
/** * Write a {@code <category>} element for a given entity. * * @param entity The given entity. * @throws XMLStreamException If unable to write to stream */ void writeEntryCategory(Object entity) throws XMLStreamException { Type entityType = entityDataModel.getType(entity.getClass()); xmlWriter.writeStartElement(ATOM_CATEGORY); xmlWriter.writeAttribute(SCHEME, ODATA_SCHEME_NS); xmlWriter.writeAttribute(TERM, String.format("%s%s.%s", HASH, entityType.getNamespace(), entityType.getName())); xmlWriter.writeEndElement(); }
/** * 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; }
public B setType(Type type, boolean isCollectionForStructureProperty) { this.typeName = type.getFullyQualifiedName(); this.isCollection = isCollectionForStructureProperty; return self; }
if (elementType.getMetaType().equals(MetaType.PRIMITIVE)) { xmlWriter.writeAttribute(METADATA, odataMetadataNs, TYPE, HASH + COLLECTION + "(" + elementType.getName() + ")"); } else { xmlWriter.writeAttribute(METADATA, odataMetadataNs, TYPE, HASH + COLLECTION + "(" + elementType.getFullyQualifiedName() + ")"); switch (propertyType.getMetaType()) { case PRIMITIVE: PrimitiveType primitiveType = (PrimitiveType) propertyType; case ENUM: xmlWriter.writeAttribute(METADATA, odataMetadataNs, TYPE, HASH + propertyType.getFullyQualifiedName()); break; throw new UnsupportedOperationException("Unsupported meta type: " + propertyType.getMetaType());
throw new ODataUnmarshallingException("OData type not found: " + typeName); switch (type.getMetaType()) { case ENUM: case PRIMITIVE: if (isExtracted) { fieldValue = getAppropriateFieldValue(type.getJavaType(), String.valueOf(targetNode)); } else { if (map.get(targetNode) != null) { fieldValue = getAppropriateFieldValue(type.getJavaType(), String.valueOf(map.get(targetNode))); LOG.warn("Unsupported type {}.", type.getMetaType().name()); throw new UnsupportedOperationException("Unsupported type: " + typeName);
/** * 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; }
public B setType(Type type, boolean isCollectionForStructureProperty) { this.typeName = type.getFullyQualifiedName(); this.isCollection = isCollectionForStructureProperty; return self; }
if (elementType.getMetaType().equals(MetaType.PRIMITIVE)) { xmlWriter.writeAttribute(METADATA, odataMetadataNs, TYPE, HASH + COLLECTION + "(" + elementType.getName() + ")"); } else { xmlWriter.writeAttribute(METADATA, odataMetadataNs, TYPE, HASH + COLLECTION + "(" + elementType.getFullyQualifiedName() + ")"); switch (propertyType.getMetaType()) { case PRIMITIVE: PrimitiveType primitiveType = (PrimitiveType) propertyType; case ENUM: xmlWriter.writeAttribute(METADATA, odataMetadataNs, TYPE, HASH + propertyType.getFullyQualifiedName()); break; throw new UnsupportedOperationException("Unsupported meta type: " + propertyType.getMetaType());
throw new ODataUnmarshallingException("OData type not found: " + typeName); switch (type.getMetaType()) { case ENUM: case PRIMITIVE: if (isExtracted) { fieldValue = getAppropriateFieldValue(type.getJavaType(), String.valueOf(targetNode)); } else { if (map.get(targetNode) != null) { fieldValue = getAppropriateFieldValue(type.getJavaType(), String.valueOf(map.get(targetNode))); LOG.warn("Unsupported type {}.", type.getMetaType().name()); throw new UnsupportedOperationException("Unsupported type: " + typeName);
/** * Write a {@code <category>} element for a given entity. * * @param entity The given entity. * @throws XMLStreamException If unable to write to stream */ void writeEntryCategory(Object entity) throws XMLStreamException { Type entityType = entityDataModel.getType(entity.getClass()); xmlWriter.writeStartElement(ATOM_CATEGORY); xmlWriter.writeAttribute(SCHEME, ODATA_SCHEME_NS); xmlWriter.writeAttribute(TERM, String.format("%s%s.%s", HASH, entityType.getNamespace(), entityType.getName())); xmlWriter.writeEndElement(); }
/** * 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; }
/** * 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; }
@Override public String toString() { if (collection) { return "Collection(" + type.getFullyQualifiedName() + ")"; } else { return type.getFullyQualifiedName(); } } }
public Builder addType(Type type) { this.typesBuilder.put(type.getName(), type); return this; }
@Override public Type getType(Class<?> javaType) { // NOTE: Only entity types, complex types and enum types defined in this schema are searched here. // Primitive types are not handled here. Type definitions are not searched; they map to their corresponding // underlying primitive type, and there can potentially be multiple type definitions with the same underlying // primitive type, therefore it is not useful to find a type definition corresponding to a particular primitive // Java type. for (Type type : types.values()) { if (javaType.equals(type.getJavaType())) { return type; } } return null; }
/** * Checks if the specified OData type is a primitive 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 primitive type. */ public static PrimitiveType checkIsPrimitiveType(Type type) { if (!isPrimitiveType(type)) { throw new ODataSystemException("A primitive type is required, but '" + type.getFullyQualifiedName() + "' is not a primitive type: " + type.getMetaType()); } return (PrimitiveType) type; }
/** * 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; }