/** * Returns the {@link FullQualifiedName} for this type kind. * * @return {@link FullQualifiedName} */ public FullQualifiedName getFullQualifiedName() { return new FullQualifiedName(EdmPrimitiveType.EDM_NAMESPACE, toString()); }
/** * Returns the {@link FullQualifiedName} for this type kind. * * @return {@link FullQualifiedName} */ public FullQualifiedName getFullQualifiedName() { return new FullQualifiedName(EdmPrimitiveType.EDM_NAMESPACE, toString()); }
@Override public BuilderImpl setType(final EdmPrimitiveTypeKind type) { if (type == EdmPrimitiveTypeKind.Stream) { throw new IllegalArgumentException(String.format( "Cannot build a primitive value for %s", EdmPrimitiveTypeKind.Stream.toString())); } if (type == EdmPrimitiveTypeKind.Geography || type == EdmPrimitiveTypeKind.Geometry) { throw new IllegalArgumentException( type + "is not an instantiable type. " + "An entity can declare a property to be of type Geometry. " + "An instance of an entity MUST NOT have a value of type Geometry. " + "Each value MUST be of some subtype."); } instance.typeKind = type == null ? EdmPrimitiveTypeKind.String : type; instance.type = EdmPrimitiveTypeFactory.getInstance(instance.typeKind); return this; }
@Override public BuilderImpl setType(final EdmPrimitiveTypeKind type) { if (type == EdmPrimitiveTypeKind.Stream) { throw new IllegalArgumentException(String.format( "Cannot build a primitive value for %s", EdmPrimitiveTypeKind.Stream.toString())); } if (type == EdmPrimitiveTypeKind.Geography || type == EdmPrimitiveTypeKind.Geometry) { throw new IllegalArgumentException( type + "is not an instantiable type. " + "An entity can declare a property to be of type Geometry. " + "An instance of an entity MUST NOT have a value of type Geometry. " + "Each value MUST be of some subtype."); } instance.typeKind = type == null ? EdmPrimitiveTypeKind.String : type; instance.type = EdmPrimitiveTypeFactory.getInstance(instance.typeKind); return this; }
private static EdmTypeInfo guessPrimitiveType(final EdmEnabledODataClient client, final Class<?> clazz) { EdmPrimitiveTypeKind bckCandidate = null; for (EdmPrimitiveTypeKind kind : EdmPrimitiveTypeKind.values()) { final Class<?> target = EdmPrimitiveTypeFactory.getInstance(kind).getDefaultType(); if (clazz.equals(target)) { return new EdmTypeInfo.Builder().setEdm(client.getCachedEdm()).setTypeExpression(kind.toString()).build(); } else if (target.isAssignableFrom(clazz)) { bckCandidate = kind; } else if (target == Timestamp.class && kind == EdmPrimitiveTypeKind.DateTimeOffset) { bckCandidate = kind; } } if (bckCandidate == null) { throw new IllegalArgumentException(clazz.getSimpleName() + " is not a simple type"); } else { return new EdmTypeInfo.Builder().setEdm(client.getCachedEdm()).setTypeExpression(bckCandidate.toString()).build(); } }
private static EdmTypeInfo guessPrimitiveType(final EdmEnabledODataClient client, final Class<?> clazz) { EdmPrimitiveTypeKind bckCandidate = null; for (EdmPrimitiveTypeKind kind : EdmPrimitiveTypeKind.values()) { final Class<?> target = EdmPrimitiveTypeFactory.getInstance(kind).getDefaultType(); if (clazz.equals(target)) { return new EdmTypeInfo.Builder().setEdm(client.getCachedEdm()).setTypeExpression(kind.toString()).build(); } else if (target.isAssignableFrom(clazz)) { bckCandidate = kind; } else if (target == Timestamp.class && kind == EdmPrimitiveTypeKind.DateTimeOffset) { bckCandidate = kind; } } if (bckCandidate == null) { throw new IllegalArgumentException(clazz.getSimpleName() + " is not a simple type"); } else { return new EdmTypeInfo.Builder().setEdm(client.getCachedEdm()).setTypeExpression(bckCandidate.toString()).build(); } }
@Override public void visit(Literal obj) { try { String odataType = ODataTypeManager.odataType(obj.getType()).toString(); if (currentExpression != null) { //TODO: this is an attempt at contextually figuring out the type, but it //may not be sufficient in all cases odataType = odataType(currentExpression.getNativeType(), currentExpression.getRuntimeType()); } this.filter.append(ODataTypeManager.convertToODataURIValue(obj.getValue(), odataType)); } catch (EdmPrimitiveTypeException e) { this.exceptions.add(new TranslatorException(e)); } }