-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b258923
commit 989a3d0
Showing
25 changed files
with
184 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 0 additions & 47 deletions
47
...ylive-bootstrap-api/src/main/java/com/jd/live/agent/bootstrap/util/AttributeAccessor.java
This file was deleted.
Oops, something went wrong.
80 changes: 80 additions & 0 deletions
80
...trap/joylive-bootstrap-api/src/main/java/com/jd/live/agent/bootstrap/util/Attributes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
* Copyright © ${year} ${owner} (${email}) | ||
* | ||
* 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.jd.live.agent.bootstrap.util; | ||
|
||
import java.util.function.BiConsumer; | ||
|
||
/** | ||
* Provides a contract for setting and getting attributes generically. | ||
* This interface allows for the storage and retrieval of attributes. | ||
*/ | ||
public interface Attributes { | ||
|
||
/** | ||
* Retrieves an attribute by key. | ||
* | ||
* @param key The key of the attribute to retrieve. | ||
* @return The value of the attribute, or null if not found. | ||
*/ | ||
<T> T getAttribute(String key); | ||
|
||
/** | ||
* Sets or replaces an attribute with the specified key and value. | ||
* | ||
* @param key The key of the attribute. | ||
* @param value The value of the attribute. | ||
*/ | ||
void setAttribute(String key, Object value); | ||
|
||
/** | ||
* Removes an attribute by its key. | ||
* | ||
* @param key The key of the attribute to remove. | ||
* @return The removed attribute, or null if the attribute was not found. | ||
*/ | ||
<T> T removeAttribute(String key); | ||
|
||
/** | ||
* Checks if an attribute with the specified key exists. | ||
* <p>This method is used to determine whether an attribute is associated with the given key.</p> | ||
* | ||
* @param key The key of the attribute to check. Cannot be {@code null}. | ||
* @return {@code true} if an attribute with the specified key exists; {@code false} otherwise. | ||
*/ | ||
boolean hasAttribute(String key); | ||
|
||
/** | ||
* Performs the given action for each attribute in this instance until all attributes | ||
* have been processed or the action throws an exception. Actions are performed in | ||
* the order of attribute insertion when possible. | ||
* | ||
* @param consumer The action to be performed for each attribute | ||
*/ | ||
void attributes(BiConsumer<String, Object> consumer); | ||
|
||
/** | ||
* Copies all source from the provided Attributes instance into this one. | ||
* If an attribute with the same key already exists in this instance, its value | ||
* is replaced with the value from the provided Attributes instance. | ||
* | ||
* @param source the Attributes instance from which to copy source | ||
*/ | ||
default void copyAttribute(Attributes source) { | ||
if (source != null) { | ||
source.attributes(this::setAttribute); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.