Commit 89539d3d authored by Eric Tobias's avatar Eric Tobias
Browse files

Major code review to prepare for merging intern's dev branch into regular dev branch.

~ Changed preference files to use the correct null check in Eclipse.
+ Removed code from the neverfear namespace as it was integrated rather than use a library. This required the removal of some tests. These should be reintegrated when the project was moved to maven and the library containing that namespace can be integrated correctly.
~ Changed some naming in the properties file.
+ Corrected some errors while doing code review.
+ Refactored some of the adapter code related to drops, lift, and updates to centralized code and reduce redundancy.
~ Preparing for a review of the drawing mechanism. Hence, changed some names in the Corona class and it's Image child.
parent e73bfd50
...@@ -9,11 +9,11 @@ org.eclipse.jdt.core.codeComplete.staticFieldPrefixes= ...@@ -9,11 +9,11 @@ org.eclipse.jdt.core.codeComplete.staticFieldPrefixes=
org.eclipse.jdt.core.codeComplete.staticFieldSuffixes= org.eclipse.jdt.core.codeComplete.staticFieldSuffixes=
org.eclipse.jdt.core.codeComplete.staticFinalFieldPrefixes= org.eclipse.jdt.core.codeComplete.staticFinalFieldPrefixes=
org.eclipse.jdt.core.codeComplete.staticFinalFieldSuffixes= org.eclipse.jdt.core.codeComplete.staticFinalFieldSuffixes=
org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=enabled org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled
org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
org.eclipse.jdt.core.compiler.annotation.nonnull=dbc.annotation.NonNull org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull
org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=dbc.annotation.NonNullByDefault org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault
org.eclipse.jdt.core.compiler.annotation.nullable=dbc.annotation.Nullable org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable
org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
org.eclipse.jdt.core.compiler.doc.comment.support=enabled org.eclipse.jdt.core.compiler.doc.comment.support=enabled
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
......
...@@ -20,8 +20,8 @@ centred = false ...@@ -20,8 +20,8 @@ centred = false
# Properties for the calibration of the object manager # Properties for the calibration of the object manager
#The value below is best left at or above 1024 #The value below is best left at or above 1024
cursorIDRemappingConstant = 1024 cursor.id.remapping.constant = 1024
# Add the property "tableAdapter" with the adapter to load # The low-level computer vision (or similar) adapter to load.
# Syntax is : tableAdapter = packageName.ClassName # Syntax is : adapter.class = packageName.ClassName
# i.e : tableAdapter = lu.list.itis.dkd.tui.adapter.TuioAdapter adapter.class = lu.list.itis.dkd.tui.adapter.TuioAdapter
\ No newline at end of file \ No newline at end of file
...@@ -105,33 +105,28 @@ public abstract class TangibleApplication { ...@@ -105,33 +105,28 @@ public abstract class TangibleApplication {
interfaceManager = new TangibleInterfaceManager(this, logger, properties); interfaceManager = new TangibleInterfaceManager(this, logger, properties);
try { try {
adapter = (TuiAdapter) Class.forName(properties.getProperty("tableAdapter")).getConstructor(TangibleInterfaceManager.class).newInstance(interfaceManager); //$NON-NLS-1$ adapter = (TuiAdapter) Class.forName(properties.getProperty("adapter.class")).getConstructor(TangibleInterfaceManager.class).newInstance(interfaceManager); //$NON-NLS-1$
} catch (InstantiationException e) { } catch (InstantiationException e) {
logger.log(Level.SEVERE, "Cannot instantiate adapter. You try to instantiate an abstract class or an interface!"); //$NON-NLS-1$s logger.log(Level.SEVERE, "Cannot instantiate adapter. The adapter must be a concrete class, not an interface or abstract class and it must directly inherit from TuiAdapter! Check your properties file and set adapter.class accordingly."); //$NON-NLS-1$s
System.exit(42); System.exit(42);
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
logger.log(Level.SEVERE, "The currently executing method does not have access to the definition of the constructor."); //$NON-NLS-1$ logger.log(Level.SEVERE, "The currently executing method does not have access to the definition of the constructor."); //$NON-NLS-1$
System.exit(42); System.exit(42);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
logger.log(Level.SEVERE, "A wrong argument has been passed to the adapter."); //$NON-NLS-1$ logger.log(Level.SEVERE, "A erroneous argument has been passed to the adapter."); //$NON-NLS-1$
System.exit(42); System.exit(42);
} catch (InvocationTargetException e) { } catch (InvocationTargetException e) {
logger.log(Level.SEVERE, "An exception has been thrown in the constructor of the adapter"); //$NON-NLS-1$ logger.log(Level.SEVERE, "An exception has been thrown in the constructor of the adapter."); //$NON-NLS-1$
System.exit(42); System.exit(42);
} catch (NoSuchMethodException e) { } catch (NoSuchMethodException e) {
logger.log(Level.SEVERE, "The called method was not found"); //$NON-NLS-1$ logger.log(Level.SEVERE, "The called method was not found. Make sure your implementation supports the method."); //$NON-NLS-1$
System.exit(42); System.exit(42);
} catch (SecurityException e) { } catch (SecurityException e) {
logger.log(Level.SEVERE, "Security violation"); //$NON-NLS-1$ logger.log(Level.SEVERE, "Security violation."); //$NON-NLS-1$
System.exit(42); System.exit(42);
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
logger.log(Level.SEVERE, "The class " + properties.getProperty("tableAdapter") + " was not found. Check the spelling !"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ logger.log(Level.SEVERE, "The class " + properties.getProperty("adapter.class") + " was not found. Check your spelling!"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
System.exit(42); System.exit(42);
} }
......
...@@ -40,8 +40,9 @@ import java.util.logging.Logger; ...@@ -40,8 +40,9 @@ import java.util.logging.Logger;
* locks to synchronise all calls to manage objects. * locks to synchronise all calls to manage objects.
* *
* @author Eric TOBIAS [eric.tobias@list.lu] * @author Eric TOBIAS [eric.tobias@list.lu]
* @author Nicolas Gilmard
* @since 1.0 * @since 1.0
* @version 1.0.2 * @version 2.0.2
*/ */
@NonNullByDefault @NonNullByDefault
public abstract class TangibleObjectManager { public abstract class TangibleObjectManager {
...@@ -85,7 +86,7 @@ public abstract class TangibleObjectManager { ...@@ -85,7 +86,7 @@ public abstract class TangibleObjectManager {
* widgets to use by implementing this method. <b>By default, no widgets are instantiated</b>.<br> * widgets to use by implementing this method. <b>By default, no widgets are instantiated</b>.<br>
* <br> * <br>
* *
* When adding Widgets to map to cursors, refer to {@link IDMapper#remapCursorID(int)}. Cursor * When adding Widgets to map to cursors, refer to {@link IDMapper#remapCursorId(int)}. Cursor
* IDs are remapped as not to clash with any symbol ID assigned by reacTIVision. A good practice * IDs are remapped as not to clash with any symbol ID assigned by reacTIVision. A good practice
* is to reason with regular cursor IDs and add them to the map by calling for example: * is to reason with regular cursor IDs and add them to the map by calling for example:
* <code>objectList.put(remapCursorID(0), W extends BaseWidget);</code> to the first cursor that * <code>objectList.put(remapCursorID(0), W extends BaseWidget);</code> to the first cursor that
...@@ -172,7 +173,6 @@ public abstract class TangibleObjectManager { ...@@ -172,7 +173,6 @@ public abstract class TangibleObjectManager {
cursorList.get(tangibleObject.getObjectId()).actionDrop(tangibleObject); cursorList.get(tangibleObject.getObjectId()).actionDrop(tangibleObject);
ensureConsistency(); ensureConsistency();
break; break;
case OBJECT: case OBJECT:
...@@ -184,11 +184,12 @@ public abstract class TangibleObjectManager { ...@@ -184,11 +184,12 @@ public abstract class TangibleObjectManager {
break; break;
case BLOB: case BLOB:
// TODO This line add a small shadow with each blob. This behaviour might not be
// desired but needs to be investigated. Opening issue #27.
blobList.putIfAbsent(tangibleObject.getObjectId(), new BaseWidgetBuilder().withCorona(tangibleObject.getObjectId(), new ShadowBuilder(new Point()).withShape(ShapeFactory.buildCircle(5)).build()).build()); blobList.putIfAbsent(tangibleObject.getObjectId(), new BaseWidgetBuilder().withCorona(tangibleObject.getObjectId(), new ShadowBuilder(new Point()).withShape(ShapeFactory.buildCircle(5)).build()).build());
blobList.get(tangibleObject.getObjectId()).actionDrop(tangibleObject); blobList.get(tangibleObject.getObjectId()).actionDrop(tangibleObject);
ensureConsistency(); break;
default: default:
logger.log(Level.WARNING, "The recognised symbol was not assigned to a widget!"); //$NON-NLS-1$ logger.log(Level.WARNING, "The recognised symbol was not assigned to a widget!"); //$NON-NLS-1$
break; break;
...@@ -224,6 +225,7 @@ public abstract class TangibleObjectManager { ...@@ -224,6 +225,7 @@ public abstract class TangibleObjectManager {
if (blobList.containsKey(tangibleObject.getObjectId())) { if (blobList.containsKey(tangibleObject.getObjectId())) {
blobList.remove(tangibleObject.getObjectId()).actionLift(tangibleObject); blobList.remove(tangibleObject.getObjectId()).actionLift(tangibleObject);
} }
break;
default: default:
logger.log(Level.WARNING, "The recognised symbol was not assigned to a widget!"); //$NON-NLS-1$ logger.log(Level.WARNING, "The recognised symbol was not assigned to a widget!"); //$NON-NLS-1$
break; break;
...@@ -261,6 +263,7 @@ public abstract class TangibleObjectManager { ...@@ -261,6 +263,7 @@ public abstract class TangibleObjectManager {
} else { } else {
logger.log(Level.WARNING, "The blob could not be recognised!"); //$NON-NLS-1$ logger.log(Level.WARNING, "The blob could not be recognised!"); //$NON-NLS-1$
} }
break;
default: default:
logger.log(Level.WARNING, "The recognised symbol was not assigned to a widget!"); //$NON-NLS-1$ logger.log(Level.WARNING, "The recognised symbol was not assigned to a widget!"); //$NON-NLS-1$
break; break;
......
...@@ -17,6 +17,7 @@ import lu.list.itis.dkd.tui.TangibleApplication; ...@@ -17,6 +17,7 @@ import lu.list.itis.dkd.tui.TangibleApplication;
import lu.list.itis.dkd.tui.utility.Point; import lu.list.itis.dkd.tui.utility.Point;
import lu.tudor.ssi.kiss.dbc.annotation.NonNullByDefault; import lu.tudor.ssi.kiss.dbc.annotation.NonNullByDefault;
import lu.tudor.ssi.kiss.dbc.annotation.Nullable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.logging.Level; import java.util.logging.Level;
...@@ -79,7 +80,10 @@ public class TangibleObject { ...@@ -79,7 +80,10 @@ public class TangibleObject {
/** The rotation acceleration value. */ /** The rotation acceleration value. */
protected float rotationAccel; protected float rotationAccel;
/** A Vector of {@link Point} containing all the previous positions of the tangible object. */ /**
* An {@link ArrayList} of {@link Point} containing all the previous positions of the tangible
* object.
*/
protected ArrayList<Point> path; protected ArrayList<Point> path;
/** Reflects the current state of the {@link TangibleObject} */ /** Reflects the current state of the {@link TangibleObject} */
...@@ -94,6 +98,7 @@ public class TangibleObject { ...@@ -94,6 +98,7 @@ public class TangibleObject {
this.identifier = identifier; this.identifier = identifier;
} }
@Nullable
static State getState(int id) { static State getState(int id) {
switch (id) { switch (id) {
case 0: case 0:
...@@ -110,10 +115,8 @@ public class TangibleObject { ...@@ -110,10 +115,8 @@ public class TangibleObject {
return State.ROTATING; return State.ROTATING;
default: default:
logger.log(Level.WARNING, "Unrecognised state identifier!"); //$NON-NLS-1$ logger.log(Level.WARNING, "Unrecognised state identifier!"); //$NON-NLS-1$
break; return null;
} }
return null;
} }
/** /**
...@@ -137,9 +140,10 @@ public class TangibleObject { ...@@ -137,9 +140,10 @@ public class TangibleObject {
/** /**
* Default constructor * Default constructor.
* *
* @param tangibleObjectBuilder * @param tangibleObjectBuilder
* The builder holding the values from which to instantiate this object.
* *
*/ */
public TangibleObject(TangibleObjectBuilder tangibleObjectBuilder) { public TangibleObject(TangibleObjectBuilder tangibleObjectBuilder) {
...@@ -474,4 +478,4 @@ public class TangibleObject { ...@@ -474,4 +478,4 @@ public class TangibleObject {
public void setArea(float area) { public void setArea(float area) {
this.area = area; this.area = area;
} }
} }
\ No newline at end of file
...@@ -22,15 +22,13 @@ import lu.tudor.ssi.kiss.dbc.annotation.NonNullByDefault; ...@@ -22,15 +22,13 @@ import lu.tudor.ssi.kiss.dbc.annotation.NonNullByDefault;
import java.util.ArrayList; import java.util.ArrayList;
/** /**
* REFACTORED Method names should be refactored due to them not being additions as suggested. Use
* the "with" naming style such as "withMotionAcceleration".
* *
* {@link TangibleObjectBuilder} class used to construct a {@link TangibleObject} by providing * {@link TangibleObjectBuilder} class used to construct a {@link TangibleObject} by providing
* methods to set all parameters. * methods to set all parameters.
* *
* @author Nicolas GILMARD [nicolas.gilmard@list.lu] * @author Nicolas GILMARD [nicolas.gilmard@list.lu]
* @since 2.0 * @since 2.0
* @version 2.0.1 * @version 2.0.2
*/ */
@NonNullByDefault @NonNullByDefault
@SuppressWarnings("hiding") @SuppressWarnings("hiding")
...@@ -87,8 +85,9 @@ public class TangibleObjectBuilder { ...@@ -87,8 +85,9 @@ public class TangibleObjectBuilder {
* Constructor setting the required fields of a tangibleObject * Constructor setting the required fields of a tangibleObject
* *
* @param objectId * @param objectId
* The id of the tangibleObject * The id of the tangible object.
* @param type * @param type
* The {@link Type} of the tangible object.
* @param x * @param x
* The X coordinate * The X coordinate
* @param y * @param y
...@@ -271,8 +270,9 @@ public class TangibleObjectBuilder { ...@@ -271,8 +270,9 @@ public class TangibleObjectBuilder {
* Method for building a {@link TangibleObject} with the values set by the builder. * Method for building a {@link TangibleObject} with the values set by the builder.
* *
* @return An instance of {@link TangibleObject} as by the values issued to the builder. * @return An instance of {@link TangibleObject} as by the values issued to the builder.
* @pre objectId and path != null * @pre objectId != <code>null</code>
* @pre path contains at least one point * @pre path != <code>null</code>
* @pre path != empty
*/ */
public TangibleObject build() { public TangibleObject build() {
return new TangibleObject(this); return new TangibleObject(this);
......
...@@ -20,15 +20,18 @@ import lu.list.itis.dkd.tui.logging.EventLogger; ...@@ -20,15 +20,18 @@ import lu.list.itis.dkd.tui.logging.EventLogger;
import lu.tudor.ssi.kiss.dbc.annotation.NonNullByDefault; import lu.tudor.ssi.kiss.dbc.annotation.NonNullByDefault;
import java.util.Collection; import java.util.Collection;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JComponent; import javax.swing.JComponent;
/** /**
* Abstract class managing interaction with a tangible table using a typical protocol. * Abstract class managing interaction with a tangible table using a typical protocol.
* *
* @author Nicolas GILMARD [nicolas.gilmard@list.lu] * @author Nicolas GILMARD
* @author Eric TOBIAS [eric.tobias@list.lu]
* @since 2.0 * @since 2.0
* @version 2.0.1 * @version 2.0.2
*/ */
@NonNullByDefault @NonNullByDefault
public abstract class TuiAdapter { public abstract class TuiAdapter {
...@@ -101,7 +104,7 @@ public abstract class TuiAdapter { ...@@ -101,7 +104,7 @@ public abstract class TuiAdapter {
* Method returning the {@link TangibleObject} (cursor) with the given id * Method returning the {@link TangibleObject} (cursor) with the given id
* *
* @param id * @param id
* of the cursor to get * The ID of the cursor to get.
* *
* @return The {@link TangibleObject} with objectId = id. * @return The {@link TangibleObject} with objectId = id.
*/ */
...@@ -111,7 +114,7 @@ public abstract class TuiAdapter { ...@@ -111,7 +114,7 @@ public abstract class TuiAdapter {
* Method returning the {@link TangibleObject} (object) with the given id * Method returning the {@link TangibleObject} (object) with the given id
* *
* @param id * @param id
* of the object to get * The ID of the object to get.
* *
* @return The {@link TangibleObject} with objectId = id. * @return The {@link TangibleObject} with objectId = id.
*/ */
...@@ -121,46 +124,35 @@ public abstract class TuiAdapter { ...@@ -121,46 +124,35 @@ public abstract class TuiAdapter {
* Method returning the {@link TangibleObject} (blob) with the given id * Method returning the {@link TangibleObject} (blob) with the given id
* *
* @param id * @param id
* of the blob to get * The ID of the blob to get.
* *
* @return The {@link TangibleObject} with objectId = id. * @return The {@link TangibleObject} with objectId = id.
*/ */
public abstract TangibleObject getBlob(long id); public abstract TangibleObject getBlob(long id);
/**
* create a string representation of a tangible object to the logging mechanism
*
* @param tangibleObject
* is the concerned object.
* @param operation
* is the move done.
*/
public synchronized void addObjInfo(TangibleObject tangibleObject, String operation) {
EventLogger.getInstance().addObjInfo(tangibleObject.getObjectId(), tangibleObject.getX(), tangibleObject.getY(), tangibleObject.getAngle(), operation, tangibleObject.getTotalMilliseconds());
}
/**
* create a string representation of a tangible object to the logging mechanism
*
* @param tangibleObject
* is the concerned cursor.
* @param operation
* is the move done.
*/
public synchronized void addCurInfo(TangibleObject tangibleObject, String operation) {
EventLogger.getInstance().addCurInfo(tangibleObject.getObjectId(), tangibleObject.getX(), tangibleObject.getY(), operation, tangibleObject.getTotalMilliseconds());
}
/** /**
* create a string representation of a tangible object to the logging mechanism * Method called to log all available information of a {@link TangibleObject}.
* *
* @param tangibleObject * @param tangibleObject
* is the concerned blob. * The cursor for which to log the info for.
* @param operation * @param operation
* is the move done. * The operation to register.
*/ */
public synchronized void addBlobInfo(TangibleObject tangibleObject, String operation) { public synchronized void logInfo(TangibleObject tangibleObject, String operation) {
EventLogger.getInstance().addObjInfo(tangibleObject.getObjectId(), tangibleObject.getX(), tangibleObject.getY(), tangibleObject.getAngle(), operation, tangibleObject.getTotalMilliseconds()); switch (tangibleObject.getType()) {
case BLOB:
EventLogger.getInstance().addObjInfo(tangibleObject.getObjectId(), tangibleObject.getX(), tangibleObject.getY(), tangibleObject.getAngle(), operation, tangibleObject.getTotalMilliseconds());
break;
case CURSOR:
EventLogger.getInstance().addCurInfo(tangibleObject.getObjectId(), tangibleObject.getX(), tangibleObject.getY(), operation, tangibleObject.getTotalMilliseconds());
break;
case OBJECT:
EventLogger.getInstance().addObjInfo(tangibleObject.getObjectId(), tangibleObject.getX(), tangibleObject.getY(), tangibleObject.getAngle(), operation, tangibleObject.getTotalMilliseconds());
break;
default:
Logger.getLogger(TuiAdapter.class.getSimpleName()).log(Level.WARNING, "A logging attempt was made for a tangible object that did not conform to any prescribed type. The type was:" + tangibleObject.getType()); //$NON-NLS-1$
break;
}
} }
}
} \ No newline at end of file
...@@ -67,7 +67,7 @@ public abstract class Content implements Comparable<Content> { ...@@ -67,7 +67,7 @@ public abstract class Content implements Comparable<Content> {
/** /**
* Getter method for the draw priority. The method will have to do the computation to account * Getter method for the draw priority. The method will have to do the computation to account
* for the offset and the current position of the widget influencing the content if any. * for the initialTranslation and the current position of the widget influencing the content if any.
* *
* @return The draw priority of this content instance. * @return The draw priority of this content instance.
*/ */
......
...@@ -48,7 +48,7 @@ public class BluetoothClient extends ClientAdapter { ...@@ -48,7 +48,7 @@ public class BluetoothClient extends ClientAdapter {
* Default constructor which assign uuidService. * Default constructor which assign uuidService.
* *
* @param uuidService * @param uuidService
* is the uuid of the service to connect to. * The UUID of the service to connect to.
*/ */
public BluetoothClient(String uuidService) { public BluetoothClient(String uuidService) {
this.uuidService = uuidService; this.uuidService = uuidService;
......
...@@ -18,13 +18,15 @@ import lu.tudor.ssi.kiss.dbc.annotation.NonNullByDefault; ...@@ -18,13 +18,15 @@ import lu.tudor.ssi.kiss.dbc.annotation.NonNullByDefault;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket; import java.net.Socket;
import java.net.UnknownHostException; import java.net.UnknownHostException;
/** /**
* Adapter class managing a communication over TCP using {@link Socket}. * Adapter class managing a communication over TCP using {@link Socket}.
* *
* @author Nicolas GILMARD [nicolas.gilmard@list.lu] * @author Nicolas GILMARD
* @since 2.0 * @since 2.0
* @version 2.0.41 * @version 2.0.41
*/ */
...@@ -65,7 +67,10 @@ public class TcpClient extends ClientAdapter { ...@@ -65,7 +67,10 @@ public class TcpClient extends ClientAdapter {
* {@inheritDoc} * {@inheritDoc}
* *
* @throws IOException * @throws IOException
* Thrown if an I/O error occurs when creating the socket or if an I/O error occurs when
* creating the input/output stream or if the socket is not connected.
* @throws UnknownHostException * @throws UnknownHostException
* Thrown if the IP address of the host could not be determined.
*/ */
@Override @Override
public void connect() throws UnknownHostException, IOException { public void connect() throws UnknownHostException, IOException {
...@@ -78,6 +83,8 @@ public class TcpClient extends ClientAdapter { ...@@ -78,6 +83,8 @@ public class TcpClient extends ClientAdapter {
* {@inheritDoc} * {@inheritDoc}
* *
* @throws IOException * @throws IOException
* See {@link OutputStream#close()}, {@link InputStream#close}, and
* {@link Socket#close()}.
*/ */
@Override @Override
public void disconnect() throws IOException { public void disconnect() throws IOException {
...@@ -91,4 +98,4 @@ public class TcpClient extends ClientAdapter { ...@@ -91,4 +98,4 @@ public class TcpClient extends ClientAdapter {
client.close(); client.close();
} }
} }
} }
\ No newline at end of file
...@@ -60,17 +60,20 @@ public class XbeeAdapter extends ClientAdapter { ...@@ -60,17 +60,20 @@ public class XbeeAdapter extends ClientAdapter {
* Default constructor * Default constructor
* *
* @param port * @param port
* != null
* @param baudRate * @param baudRate
* == 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200 or 230400 *
* @pre port != null
* @pre baudRate == (1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200 or 230400)
*/ */
public XbeeAdapter(String port, int baudRate) { public XbeeAdapter(String port, int baudRate) {
Preconditions.checkState(baudRate == 1200 || baudRate == 2400 || baudRate == 4800 || baudRate == 9600 || baudRate == 19200 || baudRate == 38400 || baudRate == 57600 || baudRate == 115200 || baudRate == 230400, "The baud rate must be equals to 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200 or 230400"); //$NON-NLS-1$ Preconditions.checkState(baudRate == 1200 || baudRate == 2400 || baudRate == 4800 || baudRate == 9600 || baudRate == 19200 || baudRate == 38400 || baudRate == 57600 || baudRate == 115200 || baudRate == 230400, "The baud rate must be equals to 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200 or 230400"); //$NON-NLS-1$
// TODO Add precondition for port number.
this.port = port; this.port = port;
this.baudRate = baudRate; this.baudRate = baudRate;
portId = null; portId = null;
Enumeration portEnum = CommPortIdentifier.getPortIdentifiers(); Enumeration<?> portEnum = CommPortIdentifier.getPortIdentifiers();
// find an instance of serial port as set in port field. // find an instance of serial port as set in port field.
while (portEnum.hasMoreElements()) { while (portEnum.hasMoreElements()) {
......