org.eclipse.emf.emfstore.internal.common
Class APIUtil

java.lang.Object
  extended by org.eclipse.emf.emfstore.internal.common.APIUtil

public final class APIUtil
extends Object

Convenience class for mapping internal and external types contained in lists onto each other.

Author:
ovonwesen, emueller, eneufeld

Method Summary
static
<T> List<T>
copy(List<T> toCopy)
          Copies the given list.
static
<T extends APIDelegate<U>,V,U extends V>
List<V>
mapToAPI(Class<V> apiClass, List<T> toCopy)
          Maps a list of a given internal type to its corresponding API type by copying it.
static
<V,U extends InternalAPIDelegator<U,T>,T extends APIDelegate<U>>
List<T>
mapToInternalAPI(Class<T> apiClass, List<V> toCopy)
          Maps a list of a given external API type to its corresponding internal type by copying it.
static
<IMPL extends InternalAPIDelegator<API,INT>,INT extends APIDelegate<API>,API>
List<API>
toExternal(List<INT> toCopy)
          Maps a list of a given internal API type to its external API counterpart by copying and mapping the entities.
static
<IMPL extends InternalAPIDelegator<API,INT>,INT extends APIDelegate<API>,API>
Set<API>
toExternal(Set<INT> toCopy)
          Maps a set of a given internal API type to its external API counterpart by copying and mapping the entities.
static
<IMPL extends InternalAPIDelegator<API,INT>,INT extends APIDelegate<API>,API,DESIRED>
List<INT>
toInternal(Class<DESIRED> cls, List<API> toCopy)
          Maps a list of a given internal API type to its external API counterpart by copying and mapping the entities.
static
<V,U extends InternalAPIDelegator<U,T>,T extends APIDelegate<U>>
T
toInternal(Class<T> apiClass, V element)
          Maps an given API type to its internal API counterpart.
static
<IMPL extends InternalAPIDelegator<API,INT>,INT extends APIDelegate<API>,API>
List<INT>
toInternal(List<API> toCopy)
          Maps a list of a given API type to its internal API counterpart by copying and mapping the entities.
static
<IMPL extends InternalAPIDelegator<API,INT>,INT extends APIDelegate<API>,API>
Set<INT>
toInternal(Set<API> toCopy)
          Maps a set of a given API type to its internal API counterpart by copying and mapping the entities.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

copy

public static <T> List<T> copy(List<T> toCopy)
Copies the given list.

Type Parameters:
T - the type of the instances the list is holding
Parameters:
toCopy - the list to be copied
Returns:
the copied list

toInternal

public static <IMPL extends InternalAPIDelegator<API,INT>,INT extends APIDelegate<API>,API> List<INT> toInternal(List<API> toCopy)
Maps a list of a given API type to its internal API counterpart by copying and mapping the entities.

Type Parameters:
INT - the internal API mapping to an API implementation class
API - the type of the API interface
IMPL - the type of the API implementation class
Parameters:
toCopy - the list to be copied and mapped to the internal API type
Returns:
the copied list with its elements mapped to their internal API type

toInternal

public static <IMPL extends InternalAPIDelegator<API,INT>,INT extends APIDelegate<API>,API,DESIRED> List<INT> toInternal(Class<DESIRED> cls,
                                                                                                                         List<API> toCopy)
Maps a list of a given internal API type to its external API counterpart by copying and mapping the entities.

Type Parameters:
DESIRED - the internal API type
INT - the internal API mapping to an API implementation class
API - the type of the API interface
IMPL - the type of the API implementation class
Parameters:
cls - the desired internal API type
toCopy - the list to be copied and mapped to the external API type
Returns:
the copied list with its elements mapped to their external API type

toExternal

public static <IMPL extends InternalAPIDelegator<API,INT>,INT extends APIDelegate<API>,API> List<API> toExternal(List<INT> toCopy)
Maps a list of a given internal API type to its external API counterpart by copying and mapping the entities.

Type Parameters:
INT - the internal API mapping to an API implementation class
API - the type of the API interface
IMPL - the type of the API implementation class
Parameters:
toCopy - the list to be copied and mapped to the external API type
Returns:
the copied list with its elements mapped to their external API type

toExternal

public static <IMPL extends InternalAPIDelegator<API,INT>,INT extends APIDelegate<API>,API> Set<API> toExternal(Set<INT> toCopy)
Maps a set of a given internal API type to its external API counterpart by copying and mapping the entities.

Type Parameters:
INT - the internal API mapping to an API implementation class
API - the type of the API interface
IMPL - the type of the API implementation class
Parameters:
toCopy - the set to be copied and mapped to the external API type
Returns:
the copied set with its elements mapped to their external API type

mapToAPI

public static <T extends APIDelegate<U>,V,U extends V> List<V> mapToAPI(Class<V> apiClass,
                                                                        List<T> toCopy)
Maps a list of a given internal type to its corresponding API type by copying it.

Type Parameters:
T - the internal API mapping to an API implementation class
V - the type of the API interface
U - the type of the API implementation class
Parameters:
apiClass - the desired API type
toCopy - the list to be copied
Returns:
the copied list with its elements mapped to their API type

mapToInternalAPI

public static <V,U extends InternalAPIDelegator<U,T>,T extends APIDelegate<U>> List<T> mapToInternalAPI(Class<T> apiClass,
                                                                                                        List<V> toCopy)
Maps a list of a given external API type to its corresponding internal type by copying it.

Type Parameters:
T - the internal API mapping to an API implementation class
V - the type of the API interface
U - the type of the API implementation class
Parameters:
apiClass - the desired API type
toCopy - the list to be copied
Returns:
the copied list with its elements mapped to their API type

toInternal

public static <IMPL extends InternalAPIDelegator<API,INT>,INT extends APIDelegate<API>,API> Set<INT> toInternal(Set<API> toCopy)
Maps a set of a given API type to its internal API counterpart by copying and mapping the entities.

Type Parameters:
INT - the internal API mapping to an API implementation class
API - the type of the API interface
IMPL - the type of the API implementation class
Parameters:
toCopy - the set to be copied and mapped to the internal API type
Returns:
the copied set with its elements mapped to their internal API type

toInternal

public static <V,U extends InternalAPIDelegator<U,T>,T extends APIDelegate<U>> T toInternal(Class<T> apiClass,
                                                                                            V element)
Maps an given API type to its internal API counterpart.

Type Parameters:
T - the internal API mapping to an API implementation class
V - the type of the API interface
U - the type of the API implementation class
Parameters:
apiClass - the desired API type
element - the type to be mapped
Returns:
the internal API type


Copyright © 2015. All Rights Reserved.