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

com.google.cloud.tools.opensource.classpath.SymbolReferenceSet Maven / Gradle / Ivy

/*
 * Copyright 2018 Google LLC.
 *
 * 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.cloud.tools.opensource.classpath;

import com.google.auto.value.AutoValue;
import com.google.common.collect.ImmutableSet;

/**
 * A set of symbol references in a file (jar file or class file). The references are from constant
 * pool of class file(s).
 *
 * @see Java
 *     Virtual Machine Specification: The Constant Pool
 */
@AutoValue
abstract class SymbolReferenceSet {
  /**
   * Returns class references from the file.
   */
  abstract ImmutableSet getClassReferences();

  /**
   * Returns method references from the file.
   */
  abstract ImmutableSet getMethodReferences();

  /**
   * Returns field references from the file.
   */
  abstract ImmutableSet getFieldReferences();

  static Builder builder() {
    return new AutoValue_SymbolReferenceSet.Builder();
  }

  @AutoValue.Builder
  abstract static class Builder {
    abstract Builder setClassReferences(Iterable classReferences);
    abstract Builder setFieldReferences(Iterable fieldReferences);
    abstract Builder setMethodReferences(Iterable methodReferences);
    abstract ImmutableSet.Builder classReferencesBuilder();
    abstract ImmutableSet.Builder methodReferencesBuilder();
    abstract ImmutableSet.Builder fieldReferencesBuilder();

    abstract SymbolReferenceSet build();

    Builder addAll(SymbolReferenceSet other) {
      classReferencesBuilder().addAll(other.getClassReferences());
      methodReferencesBuilder().addAll(other.getMethodReferences());
      fieldReferencesBuilder().addAll(other.getFieldReferences());
      return this;
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy