Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Applied Arvids suggestions: use generics instead of Object; also now …

…provides an abstract default class which IGeneratorParameter implementation can inherit for the basic get/set functionality
  • Loading branch information...
commit e3d70921c6e4578e852cb8de370f188dfc021d0c 1 parent 68749cb
Egon Willighagen egonw authored
12 src/main/org/openscience/cdk/renderer/generators/IGeneratorParameter.java
View
@@ -24,20 +24,16 @@
* not of atomic properties, rendering a circles for aromatic rings,
* etc.
*
- * <p>The choice of {@link Object} is a bit arbitrary, and allows a quick way
- * to accomodate different parameter types, {@link Boolean}, {@link Integer},
- * etc.
- *
* @cdk.module render
*/
-public interface IGeneratorParameter {
+public interface IGeneratorParameter<T> {
/**
* Sets the value for this parameter.
*
* @param value the new parameter value
*/
- public void setValue(Object value);
+ public void setValue(T value);
/**
* Gets the value for this parameter. It must provide a reasonable
@@ -45,7 +41,7 @@
*
* @param value the new parameter value
*/
- public Object getValue();
+ public T getValue();
/**
* Gets the default value for this parameter. This value is set by the
@@ -53,6 +49,6 @@
*
* @param value the default value for this parameter
*/
- public Object getDefault();
+ public T getDefault();
}
53 src/main/org/openscience/cdk/renderer/generators/parameter/AbstractGeneratorParameter.java
View
@@ -0,0 +1,53 @@
+/* Copyright (C) 2009 Egon Willighagen <egonw@users.sf.net>
+ *
+ * Contact: cdk-devel@list.sourceforge.net
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+package org.openscience.cdk.renderer.generators.parameter;
+
+import org.openscience.cdk.renderer.generators.IGeneratorParameter;
+
+/**
+ * Abstract class to provide the base functionality for
+ * {@link IGeneratorParameter} implementations.
+ *
+ * @cdk.module render
+ */
+public abstract class AbstractGeneratorParameter<T>
+ implements IGeneratorParameter<T>{
+
+ private T parameterSetting;
+
+ /**
+ * Sets the value for this parameter.
+ *
+ * @param value the new parameter value
+ */
+ public void setValue(T value) {
+ this.parameterSetting = value;
+ }
+
+ /**
+ * Gets the value for this parameter. It must provide a reasonable
+ * default when no other value has been set.
+ *
+ * @param value the new parameter value
+ */
+ public T getValue() {
+ return this.parameterSetting;
+ }
+
+}
Please sign in to comment.
Something went wrong with that request. Please try again.