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

io.opentelemetry.javaagent.tooling.field.FieldAccessorInterfaces 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.getFieldAccessorInterfaceName;

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

final class FieldAccessorInterfaces {

  // field-accessor-interface-name -> fields-accessor-interface-dynamic-type
  private final Map> fieldAccessorInterfaces;

  FieldAccessorInterfaces(Map> fieldAccessorInterfaces) {
    this.fieldAccessorInterfaces = fieldAccessorInterfaces;
  }

  TypeDescription find(String typeName, String fieldTypeName) {
    String accessorInterfaceName = getFieldAccessorInterfaceName(typeName, fieldTypeName);
    DynamicType.Unloaded type = fieldAccessorInterfaces.get(accessorInterfaceName);
    if (type == null) {
      throw new IllegalStateException(
          "Couldn't find field accessor interface named " + accessorInterfaceName);
    }
    return type.getTypeDescription();
  }

  Collection> getAllInterfaces() {
    return fieldAccessorInterfaces.values();
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy