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:
Thomas Neidhart 2012-07-03 21:24:25 +00:00
parent 335f3c4802
commit 60a3e7c07a
5 changed files with 53 additions and 57 deletions

View File

@ -38,10 +38,10 @@ import org.apache.commons.collections.set.UnmodifiableSet;
* and/or {@link Get} but not {@link Map}. * and/or {@link Get} but not {@link Map}.
* *
* @since Commons Collections 4.0 * @since Commons Collections 4.0
* @version $Revision$ * @version $Id$
*
* @see Get * @see Get
* @see Put * @see Put
* @author Matt Benson
*/ */
public class SplitMapUtils { public class SplitMapUtils {

View File

@ -20,21 +20,19 @@ import java.util.Collection;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import org.apache.commons.collections.Get;
import org.apache.commons.collections.IterableGet; import org.apache.commons.collections.IterableGet;
import org.apache.commons.collections.MapIterator; import org.apache.commons.collections.MapIterator;
import org.apache.commons.collections.map.EntrySetToMapIteratorAdapter; import org.apache.commons.collections.map.EntrySetToMapIteratorAdapter;
/** /**
* {@link IterableGet} that uses a {@link Map}<K, V> for the {@link Get}<K, V> * {@link IterableGet} that uses a {@link Map}<K, V> for the
* implementation. * {@link org.apache.commons.collections.Get Get}<K, V> implementation.
* *
* @since Commons Collections 4.0 * @since Commons Collections 4.0
* @version $Revision$ * @version $Id$
*
* @author Matt Benson
*/ */
public class AbstractIterableGetMapDecorator<K, V> implements IterableGet<K, V> { public class AbstractIterableGetMapDecorator<K, V> implements IterableGet<K, V> {
/** The map to decorate */ /** The map to decorate */
protected transient Map<K, V> map; protected transient Map<K, V> map;

View File

@ -27,7 +27,7 @@ import org.apache.commons.collections.Transformer;
import org.apache.commons.collections.map.LinkedMap; 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> * <p>
* The Map put methods and Map.Entry setValue method are affected by this class. * 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. * Thus objects must be removed or searched for using their transformed form.
@ -53,15 +53,13 @@ import org.apache.commons.collections.map.LinkedMap;
* generalizations. * generalizations.
* *
* @since Commons Collections 4.0 * @since Commons Collections 4.0
* @version $Revision$ * @version $Id$
*
* @see SplitMapUtils#readableMap(Get) * @see SplitMapUtils#readableMap(Get)
* @see SplitMapUtils#writableMap(Put) * @see SplitMapUtils#writableMap(Put)
*
* @author Stephen Colebourne
* @author Matt Benson
*/ */
public class TransformedMap<J, K, U, V> extends AbstractIterableGetMapDecorator<K, V> implements public class TransformedMap<J, K, U, V> extends AbstractIterableGetMapDecorator<K, V>
Put<J, U>, Serializable { implements Put<J, U>, Serializable {
/** Serialization version */ /** Serialization version */
private static final long serialVersionUID = 5966875321133456994L; 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. * The transformer itself may throw an exception if necessary.
* *
* @param object the object to transform * @param object the object to transform
* @throws the transformed object * @return the transformed object
*/ */
protected K transformKey(J object) { protected K transformKey(J object) {
return keyTransformer.transform(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. * The transformer itself may throw an exception if necessary.
* *
* @param object the object to transform * @param object the object to transform
* @throws the transformed object * @return the transformed object
*/ */
protected V transformValue(U object) { protected V transformValue(U object) {
return valueTransformer.transform(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. * The transformer itself may throw an exception if necessary.
* *
* @param map the map to transform * @param map the map to transform
* @throws the transformed object * @return the transformed object
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
protected Map<K, V> transformMap(Map<? extends J, ? extends U> map) { protected Map<K, V> transformMap(Map<? extends J, ? extends U> map) {

View File

@ -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;

View File

@ -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>