Java Code Examples for org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind#Byte
The following examples show how to use
org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind#Byte .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EdmEnumTypeImpl.java From olingo-odata4 with Apache License 2.0 | 6 votes |
public EdmEnumTypeImpl(final Edm edm, final FullQualifiedName enumName, final CsdlEnumType enumType) { super(edm, enumName, EdmTypeKind.ENUM, enumType); if (enumType.getUnderlyingType() == null) { underlyingType = EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Int32); } else { final EdmPrimitiveTypeKind underlyingTypeKind = EdmPrimitiveTypeKind.valueOfFQN(enumType.getUnderlyingType()); if (underlyingTypeKind == EdmPrimitiveTypeKind.Byte || underlyingTypeKind == EdmPrimitiveTypeKind.SByte || underlyingTypeKind == EdmPrimitiveTypeKind.Int16 || underlyingTypeKind == EdmPrimitiveTypeKind.Int32 || underlyingTypeKind == EdmPrimitiveTypeKind.Int64) { underlyingType = EdmPrimitiveTypeFactory.getInstance(underlyingTypeKind); } else { throw new EdmException("Not allowed as underlying type: " + underlyingTypeKind); } } this.enumType = enumType; this.enumName = enumName; }
Example 2
Source File: ExpressionParser.java From olingo-odata4 with Apache License 2.0 | 6 votes |
private EdmPrimitiveTypeKind determineIntegerType(final String intValueAsString) throws UriParserSyntaxException { EdmPrimitiveTypeKind typeKind = null; try { final long value = Long.parseLong(intValueAsString); if (value >= Byte.MIN_VALUE && value <= Byte.MAX_VALUE) { typeKind = EdmPrimitiveTypeKind.SByte; } else if (value >= 0 && value <= 255) { typeKind = EdmPrimitiveTypeKind.Byte; } else if (value >= Short.MIN_VALUE && value <= Short.MAX_VALUE) { typeKind = EdmPrimitiveTypeKind.Int16; } else if (value >= Integer.MIN_VALUE && value <= Integer.MAX_VALUE) { typeKind = EdmPrimitiveTypeKind.Int32; } else { typeKind = EdmPrimitiveTypeKind.Int64; } } catch (final NumberFormatException e) { // The number cannot be formatted wrongly because the tokenizer already checked the format // but it is too large for Long and therefore too large for Edm.Int64. typeKind = EdmPrimitiveTypeKind.Decimal; } return typeKind; }
Example 3
Source File: ODataJsonDeserializer.java From olingo-odata4 with Apache License 2.0 | 5 votes |
private boolean matchNumberCase(final JsonNode node, final EdmPrimitiveTypeKind primKind) { return node.isNumber() && (primKind == EdmPrimitiveTypeKind.Int16 || primKind == EdmPrimitiveTypeKind.Int32 || primKind == EdmPrimitiveTypeKind.Byte || primKind == EdmPrimitiveTypeKind.SByte || primKind == EdmPrimitiveTypeKind.Single || primKind == EdmPrimitiveTypeKind.Double); }