]>
git.argeo.org Git - gpl/argeo-slc.git/blob - org.argeo.slc.repo/src/org/eclipse/aether/DefaultSessionData.java
1 /*******************************************************************************
2 * Copyright (c) 2010, 2014 Sonatype, Inc.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
9 * Sonatype, Inc. - initial API and implementation
10 *******************************************************************************/
11 package org
.eclipse
.aether
;
13 import java
.util
.concurrent
.ConcurrentHashMap
;
14 import java
.util
.concurrent
.ConcurrentMap
;
17 * A simple session data storage backed by a thread-safe map.
19 public final class DefaultSessionData
20 implements SessionData
23 private final ConcurrentMap
<Object
, Object
> data
;
25 public DefaultSessionData()
27 data
= new ConcurrentHashMap
<Object
, Object
>();
30 public void set( Object key
, Object value
)
34 throw new IllegalArgumentException( "key must not be null" );
39 data
.put( key
, value
);
47 public boolean set( Object key
, Object oldValue
, Object newValue
)
51 throw new IllegalArgumentException( "key must not be null" );
54 if ( newValue
!= null )
56 if ( oldValue
== null )
58 return data
.putIfAbsent( key
, newValue
) == null;
60 return data
.replace( key
, oldValue
, newValue
);
64 if ( oldValue
== null )
66 return !data
.containsKey( key
);
68 return data
.remove( key
, oldValue
);
72 public Object
get( Object key
)
76 throw new IllegalArgumentException( "key must not be null" );
79 return data
.get( key
);