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

com.google.gwt.core.ext.RebindResult Maven / Gradle / Ivy

There is a newer version: 2.10.0
Show newest version
/*
 * Copyright 2011 Google Inc.
 * 
 * Licensed 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 com.google.gwt.core.ext;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * A class for returning the result of a rebind operation.
 */
public class RebindResult {
  private final RebindMode rebindMode;
  private final String resultTypeName;
  private Map clientData;

  /**
   * Constructs a result using the provided rebindMode and resultTypeName.
   * 
   * @see RebindMode
   * 
   * @param rebindMode
   * @param resultType
   */
  public RebindResult(RebindMode rebindMode, String resultType) {
    this.rebindMode = rebindMode;
    this.resultTypeName = resultType;
  }

  /**
   * Returns a map containing all client data added to this result.
   * 
   * @return A map containing all client data added to this result. Returns
   *         null if no client data has been added.
   */
  public Map getClientDataMap() {
    return clientData;
  }

  /**
   * @return The rebind mode used to construct this result.
   */
  public RebindMode getRebindMode() {
    return rebindMode;
  }

  /**
   * @return The type name used to construct this result.
   */
  public String getResultTypeName() {
    return resultTypeName;
  }

  /**
   * Adds keyed, serializable data to a rebind result. This data will be made
   * available, as part of a {@link CachedGeneratorResult}, to subsequent
   * invocations of the same generator, when called under the same conditions
   * (e.g. for the same rebind rule and requested type name). A generator
   * implementation can use this to remember information needed for subsequent
   * regeneration, such as for making cache reuse decisions.
   * 
   * @see CachedGeneratorResult
   * @see GeneratorContext#getCachedGeneratorResult
   * 
   * @param key
   * @param data
   */
  public void putClientData(String key, Serializable data) {
    if (clientData == null) {
      clientData = new HashMap();
    }
    clientData.put(key, data);
  } 
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy