/*
 * Copyright (c) 2012 Mateusz Parzonka, Eric Bodden
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 * Mateusz Parzonka - initial API and implementation
 */
package prm4j.api;

/**
 * A parameter which can be bound to an object.
 *
 * @param <T>
 *            the type of the object which can be bound to this parameter
 */
public class Parameter<T> implements Comparable<Parameter<T>>{

    private int parameterIndex = -1;
    private final String uniqueName;
    private boolean isStrong = false;

    public Parameter(String uniqueName) {
	this.uniqueName = uniqueName;
    }

    /**
     * Returns a unique index for this parameter.
     * It is mandatory that all indexes are in the interval [0, ..., n-1] with n = number of parameters.
     * @return
     */
    public final int getIndex() {
	return this.parameterIndex;
    }

    public void setIndex(int parameterIndex) {
	this.parameterIndex = parameterIndex;
    }

    public boolean isStrong() {
	return this.isStrong;
    }

    public void setStrong(boolean isStrong) {
	this.isStrong = isStrong;
    }

    @Override
    public String toString() {
	return this.uniqueName;
    }

    @Override
    public int compareTo(Parameter<T> o) {
	return parameterIndex - o.getIndex();
    }

}

@@ -599,16 +599,17 @@
 eter%3CT%3E%3E
+ 
 %7B%0A%0A    p
@@ -853,23 +853,16 @@
 rameter.
-%0A     *
  It is m
@@ -920,16 +920,23 @@
 .., n-1%5D
+%0A     *
  with n 
@@ -959,16 +959,23 @@
 meters.%0A
+     *%0A
      * @
@@ -1028,89 +1028,304 @@
  %7B%0A%09
-return this.parameterIndex;%0A    %7D%0A%0A    public void setIndex(int parameterIndex) %7B
+if (parameterIndex %3C 0) %7B%0A%09    throw new IllegalStateException(%22Parameter index was not set yet.%22);%0A%09%7D%0A%09return this.parameterIndex;%0A    %7D%0A%0A    public void setIndex(int parameterIndex) %7B%0A%09if (parameterIndex %3C 0) %7B%0A%09    throw new IllegalStateException(%22Parameter index has to be non-negative.%22);%0A%09%7D
 %0A%09th
@@ -1648,24 +1648,81 @@
  %7B%0A%09
-return p
+if (parameterIndex %3C 0) %7B%0A%09    throw new IllegalStateException(%22P
 arameter
 Inde
@@ -1721,28 +1721,75 @@
 eter
-I
+ i
 ndex 
-- o.getIndex()
+was not set yet.%22);%0A%09%7D%0A%09return o.getIndex() - parameterIndex
 ;%0A  

Fix compareTo in Parameter and add exceptions