io.undertow.util.Attachable Maven / Gradle / Ivy
Go to download
This artifact provides a single jar that contains all classes required to use remote EJB and JMS, including
all dependencies. It is intended for use by those not using maven, maven users should just import the EJB and
JMS BOM's instead (shaded JAR's cause lots of problems with maven, as it is very easy to inadvertently end up
with different versions on classes on the class path).
/*
* JBoss, Home of Professional Open Source.
* Copyright 2014 Red Hat, Inc., and individual contributors
* as indicated by the @author tags.
*
* 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 io.undertow.util;
import java.util.List;
/**
* A thing which can have named attachments.
*
* @author David M. Lloyd
*/
public interface Attachable {
/**
* Get an attachment value. If no attachment exists for this key, {@code null} is returned.
*
* @param key the attachment key
* @param the value type
* @return the value, or {@code null} if there is none
*/
T getAttachment(AttachmentKey key);
/**
* Gets a list attachment value. If not attachment exists for this key an empty list is returned
*
* @param the value type
* @param key the attachment key
* @return the value, or an empty list if there is none
*/
List getAttachmentList(AttachmentKey extends List> key);
/**
* Set an attachment value. If an attachment for this key was already set, return the original value. If the value being set
* is {@code null}, the attachment key is removed.
*
* @param key the attachment key
* @param value the new value
* @param the value type
* @return the old value, or {@code null} if there was none
*/
T putAttachment(AttachmentKey key, T value);
/**
* Remove an attachment, returning its previous value.
*
* @param key the attachment key
* @param the value type
* @return the old value, or {@code null} if there was none
*/
T removeAttachment(AttachmentKey key);
/**
* Add a value to a list-typed attachment key. If the key is not mapped, add such a mapping.
*
* @param key the attachment key
* @param value the value to add
* @param the list value type
*/
void addToAttachmentList(AttachmentKey> key, T value);
}