org.malai.mapping
Interface IMappingRegistry

All Known Implementing Classes:
MappingRegistry

public interface IMappingRegistry

Defines an interface for a registry that gathers modifications made to a listened objects.

This file is part of Malai.
Copyright (c) 2009-2012 Arnaud BLOUIN

Malai is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
Malai is distributed without any warranty; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

05/15/2010

Since:
0.2
Version:
0.2
Author:
Arnaud BLOUIN

Method Summary
 void addMapping(IMapping mapping)
          Adds a mapping to the registry.
<T> T
getSourceFromTarget(java.lang.Object target, java.lang.Class<T> sourceType)
           
<T> T
getTargetFromSource(java.lang.Object source, java.lang.Class<T> targetType)
           
 void initMappings()
          At start, mappings must be executed one time to initialise the mapping.
 void onListCleaned(java.lang.Object list)
          Executes the mapping when all the elements of the source were removed.
<T> void
onObjectAdded(IActiveList<T> list, T object, int index)
          Executes mappings related to the given list for the addition of an object.
 void onObjectModified(java.lang.Object object)
          Executes mappings related to the given list for the modification of an object.
<T> void
onObjectMoved(IActiveList<T> list, T object, int srcIndex, int targetIndex)
          Executes mappings related to the given list for the move of an object.
 void onObjectRemoved(IActiveList<?> list, java.lang.Object object, int index)
          Executes mappings related to the given list for the deletion of an object.
<T> void
onObjectReplaced(IUnary<T> object, T replacedObject)
          Executes the mapping when an object has been replaced by an other one.
 void removeMappingsUsingSource(java.lang.Object source)
          Removes the mappings that use the given object as source.
 void removeMappingsUsingSource(java.lang.Object source, java.lang.Class<? extends IMapping> clazz)
          Removes the mappings of the given type that use the given object as source.
 void removeMappingsUsingTarget(java.lang.Object target)
          Removes the mappings that use the given object as target.
 void removeMappingsUsingTarget(java.lang.Object target, java.lang.Class<? extends IMapping> clazz)
          Removes the mappings that use the given object as target.
 

Method Detail

initMappings

void initMappings()
At start, mappings must be executed one time to initialise the mapping.

Since:
0.2

addMapping

void addMapping(IMapping mapping)
Adds a mapping to the registry.

Parameters:
mapping - The mapping to add.
Since:
0.2

onObjectAdded

<T> void onObjectAdded(IActiveList<T> list,
                       T object,
                       int index)
Executes mappings related to the given list for the addition of an object.

Parameters:
list - The modified source list.
object - The added object.
index - The position where the object has been added.
Since:
0.2

onObjectRemoved

void onObjectRemoved(IActiveList<?> list,
                     java.lang.Object object,
                     int index)
Executes mappings related to the given list for the deletion of an object.

Parameters:
list - The modified source list.
object - The deleted object.
index - The position where the object has been deleted.
Since:
0.2

onListCleaned

void onListCleaned(java.lang.Object list)
Executes the mapping when all the elements of the source were removed.

Parameters:
list - The list before the cleaning, i.e. it still contains all the elements in order to know which elements have been removed.
Since:
3.0

onObjectMoved

<T> void onObjectMoved(IActiveList<T> list,
                       T object,
                       int srcIndex,
                       int targetIndex)
Executes mappings related to the given list for the move of an object.

Parameters:
list - The modified source list.
object - The move object.
srcIndex - The source position of the object.
targetIndex - The target position of the object.
Since:
0.2

onObjectModified

void onObjectModified(java.lang.Object object)
Executes mappings related to the given list for the modification of an object.

Parameters:
object - The modified object.
Since:
0.2

onObjectReplaced

<T> void onObjectReplaced(IUnary<T> object,
                          T replacedObject)
Executes the mapping when an object has been replaced by an other one.

Parameters:
object - The singleton that contains the new object.
replacedObject - The old object contained in the singleton that has been replaced.
Since:
0.2

removeMappingsUsingSource

void removeMappingsUsingSource(java.lang.Object source)
Removes the mappings that use the given object as source.

Parameters:
source - A source object of the mappings to remove.
Since:
0.2

removeMappingsUsingTarget

void removeMappingsUsingTarget(java.lang.Object target,
                               java.lang.Class<? extends IMapping> clazz)
Removes the mappings that use the given object as target.

Parameters:
target - A target object of the mappings to remove.
clazz - The type of the mappings to remove.
Since:
0.2

removeMappingsUsingTarget

void removeMappingsUsingTarget(java.lang.Object target)
Removes the mappings that use the given object as target.

Parameters:
target - A target object of the mappings to remove.
Since:
0.2

removeMappingsUsingSource

void removeMappingsUsingSource(java.lang.Object source,
                               java.lang.Class<? extends IMapping> clazz)
Removes the mappings of the given type that use the given object as source.

Parameters:
source - A source object of the mappings to remove.
clazz - The type of the mappings to remove.
Since:
0.2

getTargetFromSource

<T> T getTargetFromSource(java.lang.Object source,
                          java.lang.Class<T> targetType)
Parameters:
source - The source object used to find the target object matching the given class.
targetType - The class of the target object to find.
Returns:
The target object found using the given source object, or null.
Since:
0.2

getSourceFromTarget

<T> T getSourceFromTarget(java.lang.Object target,
                          java.lang.Class<T> sourceType)
Parameters:
target - The target object used to find the source object matching the given class.
sourceType - The class of the source object to find.
Returns:
The source object found using the given target object, or null.
Since:
0.2