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

io.opentelemetry.javaagent.tooling.field.VirtualFieldImplementations Maven / Gradle / Ivy

There is a newer version: 2.12.0-alpha
Show newest version
/*
 * Copyright The OpenTelemetry Authors
 * SPDX-License-Identifier: Apache-2.0
 */

package io.opentelemetry.javaagent.tooling.field;

import static io.opentelemetry.javaagent.tooling.field.GeneratedVirtualFieldNames.getVirtualFieldImplementationClassName;

import java.util.Collection;
import java.util.Map;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.dynamic.DynamicType;

final class VirtualFieldImplementations {

  // context-store-type-name -> context-store-type-name-dynamic-type
  private final Map> virtualFieldImplementations;

  VirtualFieldImplementations(Map> virtualFieldImplementations) {
    this.virtualFieldImplementations = virtualFieldImplementations;
  }

  TypeDescription find(String typeName, String fieldTypeName) {
    String virtualFieldImplementationClassName =
        getVirtualFieldImplementationClassName(typeName, fieldTypeName);
    DynamicType.Unloaded type =
        virtualFieldImplementations.get(virtualFieldImplementationClassName);
    if (type == null) {
      throw new IllegalStateException(
          "Couldn't find VirtualField implementation class named "
              + virtualFieldImplementationClassName);
    }
    return type.getTypeDescription();
  }

  Collection> getAllClasses() {
    return virtualFieldImplementations.values();
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy