Cleanup of splitmap package.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@1356955 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
335f3c4802
commit
60a3e7c07a
|
@ -38,10 +38,10 @@ import org.apache.commons.collections.set.UnmodifiableSet;
|
|||
* and/or {@link Get} but not {@link Map}.
|
||||
*
|
||||
* @since Commons Collections 4.0
|
||||
* @version $Revision$
|
||||
* @version $Id$
|
||||
*
|
||||
* @see Get
|
||||
* @see Put
|
||||
* @author Matt Benson
|
||||
*/
|
||||
public class SplitMapUtils {
|
||||
|
|
@ -20,21 +20,19 @@ import java.util.Collection;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.collections.Get;
|
||||
import org.apache.commons.collections.IterableGet;
|
||||
import org.apache.commons.collections.MapIterator;
|
||||
import org.apache.commons.collections.map.EntrySetToMapIteratorAdapter;
|
||||
|
||||
/**
|
||||
* {@link IterableGet} that uses a {@link Map}<K, V> for the {@link Get}<K, V>
|
||||
* implementation.
|
||||
* {@link IterableGet} that uses a {@link Map}<K, V> for the
|
||||
* {@link org.apache.commons.collections.Get Get}<K, V> implementation.
|
||||
*
|
||||
* @since Commons Collections 4.0
|
||||
* @version $Revision$
|
||||
*
|
||||
* @author Matt Benson
|
||||
* @version $Id$
|
||||
*/
|
||||
public class AbstractIterableGetMapDecorator<K, V> implements IterableGet<K, V> {
|
||||
|
||||
/** The map to decorate */
|
||||
protected transient Map<K, V> map;
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ import org.apache.commons.collections.Transformer;
|
|||
import org.apache.commons.collections.map.LinkedMap;
|
||||
|
||||
/**
|
||||
* Decorates another <code>Map</code> to transform objects that are added.
|
||||
* Decorates another {@link Map} to transform objects that are added.
|
||||
* <p>
|
||||
* The Map put methods and Map.Entry setValue method are affected by this class.
|
||||
* Thus objects must be removed or searched for using their transformed form.
|
||||
|
@ -53,15 +53,13 @@ import org.apache.commons.collections.map.LinkedMap;
|
|||
* generalizations.
|
||||
*
|
||||
* @since Commons Collections 4.0
|
||||
* @version $Revision$
|
||||
* @version $Id$
|
||||
*
|
||||
* @see SplitMapUtils#readableMap(Get)
|
||||
* @see SplitMapUtils#writableMap(Put)
|
||||
*
|
||||
* @author Stephen Colebourne
|
||||
* @author Matt Benson
|
||||
*/
|
||||
public class TransformedMap<J, K, U, V> extends AbstractIterableGetMapDecorator<K, V> implements
|
||||
Put<J, U>, Serializable {
|
||||
public class TransformedMap<J, K, U, V> extends AbstractIterableGetMapDecorator<K, V>
|
||||
implements Put<J, U>, Serializable {
|
||||
|
||||
/** Serialization version */
|
||||
private static final long serialVersionUID = 5966875321133456994L;
|
||||
|
@ -150,7 +148,7 @@ public class TransformedMap<J, K, U, V> extends AbstractIterableGetMapDecorator<
|
|||
* The transformer itself may throw an exception if necessary.
|
||||
*
|
||||
* @param object the object to transform
|
||||
* @throws the transformed object
|
||||
* @return the transformed object
|
||||
*/
|
||||
protected K transformKey(J object) {
|
||||
return keyTransformer.transform(object);
|
||||
|
@ -162,7 +160,7 @@ public class TransformedMap<J, K, U, V> extends AbstractIterableGetMapDecorator<
|
|||
* The transformer itself may throw an exception if necessary.
|
||||
*
|
||||
* @param object the object to transform
|
||||
* @throws the transformed object
|
||||
* @return the transformed object
|
||||
*/
|
||||
protected V transformValue(U object) {
|
||||
return valueTransformer.transform(object);
|
||||
|
@ -174,7 +172,7 @@ public class TransformedMap<J, K, U, V> extends AbstractIterableGetMapDecorator<
|
|||
* The transformer itself may throw an exception if necessary.
|
||||
*
|
||||
* @param map the map to transform
|
||||
* @throws the transformed object
|
||||
* @return the transformed object
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
protected Map<K, V> transformMap(Map<? extends J, ? extends U> map) {
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You 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.
|
||||
*/
|
||||
/**
|
||||
* The "split map" concept is that of an object that implements
|
||||
* the {@link org.apache.commons.collections.Put Put} and
|
||||
* {@link org.apache.commons.collections.Get Get} interfaces,
|
||||
* with <i>differing</i> generic types. This is like a pre-generics
|
||||
* {@link java.util.Map Map} whose input key/value constraints are
|
||||
* different than its output key/value constraints. While it would
|
||||
* be possible to declare a "split map" with matching input/output
|
||||
* key/value constraints, this would be a {@link java.util.Map Map}
|
||||
* and would therefore make little sense (any Commons Collections
|
||||
* {@link java.util.Map Map} implementation will also implement
|
||||
* {@link org.apache.commons.collections.Put Put} and
|
||||
* {@link org.apache.commons.collections.Get Get} with matching
|
||||
* generic parameters).
|
||||
* <p>
|
||||
* The following decorators are provided:
|
||||
* <ul>
|
||||
* <li>Transformed - transforms each element added
|
||||
* </ul>
|
||||
*
|
||||
* @version $Id$
|
||||
*/
|
||||
package org.apache.commons.collections.splitmap;
|
|
@ -1,39 +0,0 @@
|
|||
<!-- $Id$ -->
|
||||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You 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.
|
||||
-->
|
||||
<BODY>
|
||||
<p>The "split map" concept is that of an object that implements
|
||||
the {@link org.apache.commons.collections.Put Put} and
|
||||
{@link org.apache.commons.collections.Get Get} interfaces,
|
||||
with <i>differing</i> generic types. This is like a pre-generics
|
||||
{@link java.util.Map Map} whose input key/value constraints are
|
||||
different than its output key/value constraints. While it would
|
||||
be possible to declare a "split map" with matching input/output
|
||||
key/value constraints, this would be a {@link java.util.Map Map}
|
||||
and would therefore make little sense (any Commons Collections
|
||||
{@link java.util.Map Map} implementation will also implement
|
||||
{@link org.apache.commons.collections.Put Put} and
|
||||
{@link org.apache.commons.collections.Get Get} with matching
|
||||
generic parameters).
|
||||
|
||||
<p>
|
||||
The following decorators are provided:
|
||||
<ul>
|
||||
<li>Transformed - transforms each element added
|
||||
</ul>
|
||||
</pre>
|
||||
</BODY>
|
Loading…
Reference in New Issue