All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.knightsoftnet.gwtp.spring.client.rest.helper.RestCallbackBuilder Maven / Gradle / Ivy

/*
 * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
 * agreements. See the NOTICE file distributed with this work for additional information regarding
 * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance with the License. You may obtain a
 * copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */

package de.knightsoftnet.gwtp.spring.client.rest.helper;

import de.knightsoftnet.gwtp.spring.client.session.Session;
import de.knightsoftnet.gwtp.spring.shared.models.User;

import com.google.gwt.user.client.rpc.AsyncCallback;

/**
 * Async callback implementation with error handling.
 *
 * @author Manfred Tremmel
 *
 */
public class RestCallbackBuilder {

  /**
   * create rest callback implementation.
   *
   * @param pcallbackOnSuccess on success callback
   * @param pcallbackOnFailure on failure callback
   * @param  rest result type
   * @return RestCallbackImpl
   */
  public static  AsyncCallback build(final AsyncCallbackOnSuccess pcallbackOnSuccess,
      final AsyncCallbackOnFailure pcallbackOnFailure) {
    return new AsyncCallback() {

      @Override
      public void onFailure(final Throwable pcaught) {
        pcallbackOnFailure.onFailure(pcaught);
      }

      @Override
      public void onSuccess(final R presult) {
        pcallbackOnSuccess.onSuccess(presult);
      }
    };
  }

  /**
   * create rest callback implementation.
   *
   * @param pview view of the
   * @param psession session
   * @param pcallbackOnSuccess on success callback
   * @param  view or widget which implements EditorWithErrorHandling interface
   * @param  rest result type
   * @param  http messages
   * @return RestCallbackImpl
   */
  public static  RestCallbackSimpleImpl build(final V pview, final Session psession,
          final AsyncCallbackOnSuccess pcallbackOnSuccess) {
    return new RestCallbackSimpleImpl<>(pview, psession, pcallbackOnSuccess);
  }

  /**
   * create rest callback implementation.
   *
   * @param pview view of the
   * @param psession session
   * @param pcallbackOnSuccess on success callback
   * @param phttpMessage http code messages to show
   * @param  view or widget which implements EditorWithErrorHandling interface
   * @param  rest result type
   * @param  http messages
   * @return RestCallbackImpl
   */
  public static  RestCallbackSimpleImpl build(final V pview, final Session psession,
          final AsyncCallbackOnSuccess pcallbackOnSuccess, final H phttpMessage) {
    return new RestCallbackSimpleImpl<>(pview, psession, phttpMessage, pcallbackOnSuccess);
  }

  /**
   * create rest callback implementation.
   *
   * @param pview view of the
   * @param pdata data given from server
   * @param psession session
   * @param pcallbackOnSuccess on success callback
   * @param 

presenter type * @param data type given to the server * @param view or widget which implements EditorWithErrorHandling interface * @param rest result type * @param http messages * @return RestCallbackImpl */ public static , R, // H extends HttpMessages> RestCallbackImpl build(final V pview, final D pdata, final Session psession, final AsyncCallbackOnSuccess pcallbackOnSuccess) { return new RestCallbackImpl<>(pview, pdata, psession, pcallbackOnSuccess); } /** * create rest callback implementation. * * @param pview view of the * @param pdata data given from server * @param psession session * @param phttpMessage http code messages to show * @param pcallbackOnSuccess on success callback * @param

presenter type * @param data type given to the server * @param view or widget which implements EditorWithErrorHandling interface * @param rest result type * @param http messages * @return RestCallbackImpl */ public static , R, // H extends HttpMessages> RestCallbackImpl build(final V pview, final D pdata, final Session psession, final H phttpMessage, final AsyncCallbackOnSuccess pcallbackOnSuccess) { return new RestCallbackImpl<>(pview, pdata, psession, phttpMessage, pcallbackOnSuccess); } /** * create login callback implementation. * * @param pview view of the * @param psession session * @param user data * @param view or widget which implements EditorWithErrorHandling interface * @param login messages * @param http messages * @return LoginCallback */ public static , // M extends LoginMessages, H extends HttpMessages> LoginCallback buildLoginCallback( final V pview, final Session psession) { return new LoginCallback<>(pview, psession); } /** * create login callback implementation. * * @param pview view of the * @param psession session * @param ploginErrorMessage error message to show * @param user data * @param view or widget which implements EditorWithErrorHandling interface * @param login messages * @param http messages * @return LoginCallback */ public static , // M extends LoginMessages, H extends HttpMessages> LoginCallback buildLoginCallback( final V pview, final Session psession, final M ploginErrorMessage) { return new LoginCallback<>(pview, psession, ploginErrorMessage); } /** * create login callback implementation. * * @param pview view of the * @param psession session * @param ploginErrorMessage error message to show * @param phttpMessage http code messages to show * @param user data * @param view or widget which implements EditorWithErrorHandling interface * @param login messages * @param http messages * @return LoginCallback */ public static , // M extends LoginMessages, H extends HttpMessages> LoginCallback buildLoginCallback( final V pview, final Session psession, final M ploginErrorMessage, final H phttpMessage) { return new LoginCallback<>(pview, psession, ploginErrorMessage, phttpMessage); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy