Package com.amazonaws.hal

Examples of com.amazonaws.hal.Link


            // If the method is not defined in ResourceInfo, we handle it below
        } catch (InvocationTargetException e) {
            throw e.getTargetException();
        }

        Link link;
        if ((link = method.getAnnotation(Link.class)) != null) {
            switch (link.method()) {
            case GET:
                if (List.class.isAssignableFrom(method.getReturnType())) {
                    //noinspection unchecked
                    return new HalLinkList(halResource, link.relation(),
                                           (Class) getCollectionType(method.getGenericReturnType(), 0, ResourceInfo.class),
                                           halClient);
                } else if (Map.class.isAssignableFrom(method.getReturnType())) {
                    //noinspection unchecked
                    return new HalLinkMap(halResource, link.relation(), link.keyField(),
                                          (Class) getCollectionType(method.getGenericReturnType(), 1, ResourceInfo.class),
                                          halClient);
                } else {
                    return halClient.getResource(halResource, method.getReturnType(),
                                                 getRelationHref(link, args == null ? EMPTY_ARGS : args, method.getParameterAnnotations()), false);
                }

            case POST:
                if (args == null) {
                    throw new IllegalArgumentException("POST operations require a representation argument.");
                }

                return halClient.postResource(method.getReturnType(),
                                              getRelationHref(link, args, method.getParameterAnnotations()), args[0]);

            case PUT:
                if (args == null) {
                    throw new IllegalArgumentException("PUT operations require a representation argument.");
                }

                return halClient.putResource(method.getReturnType(),
                                             getRelationHref(link, args, method.getParameterAnnotations()), args[0]);

            case DELETE:
                return halClient.deleteResource(method.getReturnType(),
                                                getRelationHref(link, args == null ? EMPTY_ARGS : args, method.getParameterAnnotations()));

            default:
                throw new UnsupportedOperationException("Unexpected HTTP method: " + link.method());
            }

        } else if (method.getName().startsWith("get")) {
            String propertyName = getPropertyName(method.getName());
            Object property = halResource.getProperty(propertyName);
View Full Code Here


            // If the method is not defined in ResourceInfo, we handle it below
        } catch (InvocationTargetException e) {
            throw e.getTargetException();
        }

        Link link;
        if ((link = method.getAnnotation(Link.class)) != null) {
            switch (link.method()) {
            case GET:
                if (List.class.isAssignableFrom(method.getReturnType())) {
                    //noinspection unchecked
                    return new HalLinkList(halResource, link.relation(), getCollectionType(method.getGenericReturnType(), 0, ResourceInfo.class), halClient);
                } else if (Map.class.isAssignableFrom(method.getReturnType())) {
                    //noinspection unchecked
                    return new HalLinkMap(halResource, link.relation(), link.keyField(), getCollectionType(method.getGenericReturnType(), 1, ResourceInfo.class), halClient);
                } else {
                    return halClient.getResource(halResource, method.getReturnType(), getRelationHref(link.relation(), args), false);
                }

            case POST:
                if (args == null) {
                    throw new IllegalArgumentException("POST operations require a representation argument.");
                }

                return halClient.postResource(method.getReturnType(), getRelationHref(link.relation(), args), args[0]);

            case PUT:
                if (args == null) {
                    throw new IllegalArgumentException("PUT operations require a representation argument.");
                }

                return halClient.putResource(method.getReturnType(), getRelationHref(link.relation(), args), args[0]);

            case DELETE:
                halClient.deleteResource(getRelationHref(link.relation(), args));

                break;

            default:
                throw new UnsupportedOperationException("Unexpected HTTP method: " + link.method());
            }

        } else if (method.getName().startsWith("get")) {
            return convert(method.getGenericReturnType(), halResource.getProperty(getPropertyName(method.getName())));
        } else if (method.getName().equals("toString") && args == null) {
View Full Code Here

            // If the method is not defined in ResourceInfo, we handle it below
        } catch (InvocationTargetException e) {
            throw e.getTargetException();
        }

        Link link;
        if ((link = method.getAnnotation(Link.class)) != null) {
            switch (link.method()) {
            case GET:
                if (List.class.isAssignableFrom(method.getReturnType())) {
                    //noinspection unchecked
                    return new HalLinkList(halResource, link.relation(),
                                           getCollectionType(method.getGenericReturnType(), 0, ResourceInfo.class),
                                           halClient);
                } else if (Map.class.isAssignableFrom(method.getReturnType())) {
                    //noinspection unchecked
                    return new HalLinkMap(halResource, link.relation(), link.keyField(),
                                          getCollectionType(method.getGenericReturnType(), 1, ResourceInfo.class),
                                          halClient);
                } else {
                    return halClient.getResource(halResource, method.getReturnType(),
                                                 getRelationHref(link, args, method.getParameterAnnotations()), false);
                }

            case POST:
                if (args == null) {
                    throw new IllegalArgumentException("POST operations require a representation argument.");
                }

                return halClient.postResource(method.getReturnType(),
                                              getRelationHref(link, args, method.getParameterAnnotations()), args[0]);

            case PUT:
                if (args == null) {
                    throw new IllegalArgumentException("PUT operations require a representation argument.");
                }

                return halClient.putResource(method.getReturnType(),
                                             getRelationHref(link, args, method.getParameterAnnotations()), args[0]);

            case DELETE:
                halClient.deleteResource(getRelationHref(link, args, method.getParameterAnnotations()));

                break;

            default:
                throw new UnsupportedOperationException("Unexpected HTTP method: " + link.method());
            }

        } else if (method.getName().startsWith("get")) {
            return convert(method.getGenericReturnType(), halResource.getProperty(getPropertyName(method.getName())));
        } else if (method.getName().equals("toString") && args == null) {
View Full Code Here

            // If the method is not defined in ResourceInfo, we handle it below
        } catch (InvocationTargetException e) {
            throw e.getTargetException();
        }

        Link link;
        if ((link = method.getAnnotation(Link.class)) != null) {
            switch (link.method()) {
            case GET:
                if (List.class.isAssignableFrom(method.getReturnType())) {
                    //noinspection unchecked
                    return new HalLinkList(halResource, link.relation(),
                                           getCollectionType(method.getGenericReturnType(), 0, ResourceInfo.class),
                                           halClient);
                } else if (Map.class.isAssignableFrom(method.getReturnType())) {
                    //noinspection unchecked
                    return new HalLinkMap(halResource, link.relation(), link.keyField(),
                                          getCollectionType(method.getGenericReturnType(), 1, ResourceInfo.class),
                                          halClient);
                } else {
                    return halClient.getResource(halResource, method.getReturnType(),
                                                 getRelationHref(link, args, method.getParameterAnnotations()), false);
                }

            case POST:
                if (args == null) {
                    throw new IllegalArgumentException("POST operations require a representation argument.");
                }

                return halClient.postResource(method.getReturnType(),
                                              getRelationHref(link, args, method.getParameterAnnotations()), args[0]);

            case PUT:
                if (args == null) {
                    throw new IllegalArgumentException("PUT operations require a representation argument.");
                }

                return halClient.putResource(method.getReturnType(),
                                             getRelationHref(link, args, method.getParameterAnnotations()), args[0]);

            case DELETE:
                return halClient.deleteResource(method.getReturnType(),
                                                getRelationHref(link, args, method.getParameterAnnotations()));

            default:
                throw new UnsupportedOperationException("Unexpected HTTP method: " + link.method());
            }

        } else if (method.getName().startsWith("get")) {
            return convert(method.getGenericReturnType(), halResource.getProperty(getPropertyName(method.getName())));
        } else if (method.getName().equals("toString") && args == null) {
View Full Code Here

TOP

Related Classes of com.amazonaws.hal.Link

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.