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

com.google.gwt.dev.javac.CachedGeneratorResultImpl 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.dev.javac;

import com.google.gwt.core.ext.CachedGeneratorResult;
import com.google.gwt.core.ext.linker.ArtifactSet;

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

/**
 * An implementation class to represent the cached results from a previous
 * generator invocation.
 */
public class CachedGeneratorResultImpl implements CachedGeneratorResult, Serializable {
  private final ArtifactSet artifacts;
  private final Map generatedUnitMap;
  private final String resultTypeName;
  private final long timeGenerated;
  private final Map clientDataMap;

  public CachedGeneratorResultImpl(String resultTypeName, ArtifactSet artifacts,
      Map generatedUnitMap, long timeGenerated,
      Map clientDataMap) {
    this.resultTypeName = resultTypeName;
    this.artifacts = new ArtifactSet(artifacts);
    this.generatedUnitMap = new HashMap(generatedUnitMap);
    this.timeGenerated = timeGenerated;
    assert clientDataMap instanceof Serializable;
    this.clientDataMap = clientDataMap;
  }

  public ArtifactSet getArtifacts() {
    return artifacts;
  }

  @Override
  public Object getClientData(String key) {
    if (clientDataMap == null) {
      return null;
    } else {
      return clientDataMap.get(key);
    }
  }

  public GeneratedUnit getGeneratedUnit(String typeName) {
    return generatedUnitMap.get(typeName);
  }

  public Collection getGeneratedUnits() {
    return generatedUnitMap.values();
  }

  @Override
  public String getResultTypeName() {
    return resultTypeName;
  }

  @Override
  public long getTimeGenerated() {
    return timeGenerated;
  }

  @Override
  public boolean isTypeCached(String typeName) {
    return generatedUnitMap.containsKey(typeName);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy