net.sf.latexdraw.glib.views
Class CreateViewCmd<M,V,F extends CreateViewCmd<M,V,F>>

java.lang.Object
  extended by net.sf.latexdraw.glib.views.CreateViewCmd<M,V,F>
Type Parameters:
M - The type of the model used to create the view.
V - The type of the view to create.
F - The type of the next command.
Direct Known Subclasses:
LViewsFactory.CreateView2DCmd, PSTViewsFactory.CreateViewPSTCmd, SVGShapesFactory.CreateViewSVGCmd

public abstract class CreateViewCmd<M,V,F extends CreateViewCmd<M,V,F>>
extends java.lang.Object

Defines a generic command mixed with a chain of responsibility. The goal is to tame the cyclomatic complexity of factories by linking the commands together. If a command cannot create the view using the given objects, the next command is called.
this class has three generics: the first one define the model of the view; the second one the view; the third one is the type of the next element of the chain of responsibility.

This file is part of LaTeXDraw
Copyright (c) 2005-2012 Arnaud BLOUIN

LaTeXDraw 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.

LaTeXDraw 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.

11/25/11

Since:
3.0
Version:
3.0
Author:
Arnaud BLOUIN

Field Summary
protected  java.lang.Class<? extends M> clazz
          The type of the model supported by the command.
protected  F next
          The next command.
 
Constructor Summary
CreateViewCmd(F next, java.lang.Class<? extends M> clazz)
          Creates the command.
 
Method Summary
protected abstract  V create(M model)
          Creates an instance of the view corresponding to the given shape.
 V execute(M model)
          Launches the creation process.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

next

protected F extends CreateViewCmd<M,V,F> next
The next command.


clazz

protected java.lang.Class<? extends M> clazz
The type of the model supported by the command.

Constructor Detail

CreateViewCmd

public CreateViewCmd(F next,
                     java.lang.Class<? extends M> clazz)
Creates the command.

Parameters:
next - The next command in the chain of responsibility. Can be null.
clazz - The class of the model.
Since:
3.0
Method Detail

execute

public V execute(M model)
Launches the creation process.

Parameters:
model - The model used to create the view.
Returns:
The created view or null.
Since:
3.0

create

protected abstract V create(M model)
Creates an instance of the view corresponding to the given shape.

Parameters:
model - The model used to create the view.
Returns:
The created view.
Since:
3.0