Skip to content

Commit

Permalink
[GSCOLLECT-1503] Deprecate getKeyFunction() and getValueFunction() on…
Browse files Browse the repository at this point in the history
… AbstractImmutableEntry in favor of the same methods on Functions.

git-svn-id: svn+ssh://gscollections.svn.services.gs.com/svnroot/gscollections-svn/trunk@840 d5c9223b-1aff-41ac-aadd-f810b4a99ac4
  • Loading branch information
Donald Raab committed Mar 25, 2015
1 parent 32a41b2 commit b708ff1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2014 Goldman Sachs.
* Copyright 2015 Goldman Sachs.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -21,12 +21,11 @@

import com.gs.collections.api.block.function.Function;
import com.gs.collections.api.tuple.Pair;
import com.gs.collections.impl.block.factory.Functions;

public class AbstractImmutableEntry<K, V> implements Map.Entry<K, V>, Serializable
{
private static final long serialVersionUID = 1L;
private static final KeyFunction<?> TO_KEY = new KeyFunction<Object>();
private static final ValueFunction<?> TO_VALUE = new ValueFunction<Object>();
private static final PairFunction<?, ?> TO_PAIR = new PairFunction<Object, Object>();

protected final K key;
Expand All @@ -38,14 +37,22 @@ public AbstractImmutableEntry(K key, V value)
this.value = value;
}

/**
* @deprecated Since 6.2 - Use {@link Functions#getKeyFunction()} instead.
*/
@Deprecated
public static <K> Function<Map.Entry<K, ?>, K> getKeyFunction()
{
return (Function<Map.Entry<K, ?>, K>) (Function<?, ?>) TO_KEY;
return Functions.getKeyFunction();
}

/**
* @deprecated Since 6.2 - Use {@link Functions#getValueFunction()} instead.
*/
@Deprecated
public static <V> Function<Map.Entry<?, V>, V> getValueFunction()
{
return (Function<Map.Entry<?, V>, V>) (Function<?, ?>) TO_VALUE;
return Functions.getValueFunction();
}

public static <K, V> Function<Map.Entry<K, V>, Pair<K, V>> getPairFunction()
Expand Down Expand Up @@ -83,6 +90,10 @@ public String toString()
return this.key + "=" + this.value;
}

/**
* @deprecated Since 6.2 - Kept for serialization compatibility only.
*/
@Deprecated
private static class KeyFunction<K> implements Function<Map.Entry<K, ?>, K>
{
private static final long serialVersionUID = 1L;
Expand All @@ -93,6 +104,10 @@ public K valueOf(Map.Entry<K, ?> entry)
}
}

/**
* @deprecated Since 6.2 - Kept for serialization compatibility only.
*/
@Deprecated
private static class ValueFunction<V> implements Function<Map.Entry<?, V>, V>
{
private static final long serialVersionUID = 1L;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2011 Goldman Sachs.
* Copyright 2015 Goldman Sachs.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -21,26 +21,6 @@

public class AbstractImmutableEntrySerializationTest
{
@Test
public void getKeyFunction()
{
Verify.assertSerializedForm(
1L,
"rO0ABXNyAEBjb20uZ3MuY29sbGVjdGlvbnMuaW1wbC50dXBsZS5BYnN0cmFjdEltbXV0YWJsZUVu\n"
+ "dHJ5JEtleUZ1bmN0aW9uAAAAAAAAAAECAAB4cA==",
AbstractImmutableEntry.getKeyFunction());
}

@Test
public void getValueFunction()
{
Verify.assertSerializedForm(
1L,
"rO0ABXNyAEJjb20uZ3MuY29sbGVjdGlvbnMuaW1wbC50dXBsZS5BYnN0cmFjdEltbXV0YWJsZUVu\n"
+ "dHJ5JFZhbHVlRnVuY3Rpb24AAAAAAAAAAQIAAHhw",
AbstractImmutableEntry.getValueFunction());
}

@Test
public void getPairFunction()
{
Expand Down

0 comments on commit b708ff1

Please sign in to comment.