Line data Source code
1 : // Copyright (C) 2019 The Android Open Source Project 2 : // 3 : // Licensed under the Apache License, Version 2.0 (the "License"); 4 : // you may not use this file except in compliance with the License. 5 : // You may obtain a copy of the License at 6 : // 7 : // http://www.apache.org/licenses/LICENSE-2.0 8 : // 9 : // Unless required by applicable law or agreed to in writing, software 10 : // distributed under the License is distributed on an "AS IS" BASIS, 11 : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 : // See the License for the specific language governing permissions and 13 : // limitations under the License. 14 : 15 : package com.google.gerrit.server.logging; 16 : 17 : import com.google.auto.value.AutoValue; 18 : import com.google.gerrit.common.Nullable; 19 : import java.util.Optional; 20 : 21 : /** 22 : * Key-value pair for custom metadata that is provided by plugins. 23 : * 24 : * <p>PluginMetadata allows plugins to include custom metadata into the {@link Metadata} instances 25 : * that are provided as context for performance tracing. 26 : * 27 : * <p>Plugins should use PluginMetadata only for metadata kinds that are not known to Gerrit core 28 : * (metadata for which {@link Metadata} doesn't have a dedicated field). 29 : */ 30 : @AutoValue 31 0 : public abstract class PluginMetadata { 32 : public static PluginMetadata create(String key, @Nullable String value) { 33 0 : return new AutoValue_PluginMetadata(key, Optional.ofNullable(value)); 34 : } 35 : 36 : public abstract String key(); 37 : 38 : public abstract Optional<String> value(); 39 : }