Package groovy.lang

Examples of groovy.lang.Closure.call()


            ((JSONArray)json).addAll( (Collection)model );
        }
        else if ( model instanceof Closure ) {
            Closure closure = (Closure)model;
            closure.setDelegate( new JsonGroovyBuilder() );
            json = (JSON)closure.call();
        }
        else if ( model instanceof String || model instanceof GString )
            json = model; // assume string is valid JSON already.
        else json = JSONObject.fromObject( model ); // Assume object is a JavaBean
View Full Code Here


        Closure guardExpr = cl.getGuard();
        if (null != guardExpr) {
          int noOfParams = guardExpr.getParameterTypes().length;
          Object guardResult;
          if (noOfParams == 2) {
            guardResult = guardExpr.call(new Object[]{result, meta});
          } else {
            guardResult = guardExpr.call(result);
          }
          if (null != guardResult) {
            if (guardResult instanceof Boolean) {
View Full Code Here

          int noOfParams = guardExpr.getParameterTypes().length;
          Object guardResult;
          if (noOfParams == 2) {
            guardResult = guardExpr.call(new Object[]{result, meta});
          } else {
            guardResult = guardExpr.call(result);
          }
          if (null != guardResult) {
            if (guardResult instanceof Boolean) {
              execute = (Boolean) guardResult;
            } else {
View Full Code Here

        }

        if (execute) {
          Closure callback = cl.getDelegate();
          if (callback.getParameterTypes().length == 2) {
            return callback.call(new Object[]{result, meta});
          } else {
            return callback.call(result);
          }
        }
      }
View Full Code Here

        if (execute) {
          Closure callback = cl.getDelegate();
          if (callback.getParameterTypes().length == 2) {
            return callback.call(new Object[]{result, meta});
          } else {
            return callback.call(result);
          }
        }
      }
      return null;
    }
View Full Code Here

      }
      for (GuardedClosure cl : callbacks.get(FAILED)) {
        boolean execute = true;
        Closure guardExpr = cl.getGuard();
        if (null != guardExpr) {
          Object guardResult = guardExpr.call(error);
          if (null != guardResult) {
            if (guardResult instanceof Boolean) {
              execute = (Boolean) guardResult;
            } else {
              execute = true;
View Full Code Here

          }
        }

        if (execute) {
          Closure callback = cl.getDelegate();
          return callback.call(error);
        }
      }
      return null;
    }
View Full Code Here

                    default:
                        throw new IllegalArgumentException(
                                "Response closure must accept one or two parameters" );
                    }

                    Object returnVal = responseClosure.call( closureArgs );
                    log.trace( "response handler result: " + returnVal );

                    return returnVal;
                }
                finally {
View Full Code Here

        Closure parser = parsers.getAt( responseContentType );
        if ( parser == null ) log.warn( "No parser found for content-type: "
            + responseContentType );
        else {
            log.debug( "Parsing response as: " + responseContentType );
            parsedData = parser.call( resp );
            if ( parsedData == null ) log.warn( "Parser returned null!" );
            else log.debug( "Parsed data to instance of: " + parsedData.getClass() );
        }
        return parsedData;
    }
View Full Code Here

            if ( encoder == null )
                throw new IllegalArgumentException(
                        "No encoder found for request content type " + getRequestContentType() );

            HttpEntity entity = encoder.getMaximumNumberOfParameters() == 2
                    ? (HttpEntity)encoder.call( new Object[] { body, this.getRequestContentType() } )
                    : (HttpEntity)encoder.call( body );

            ((HttpEntityEnclosingRequest)this.request).setEntity( entity );
        }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.