package com.grayben.riskExtractor.headingMarker;

import java.util.List;

public class TextCandidate {
	private List<String> list;

    public TextCandidate(List<String> list, int index) {
        if(index < 0 || index >= list.size())
            throw new IndexOutOfBoundsException("The index " +
                    "passed is not within the bounds " +
                    "of the list passed");
        this.list = list;
        this.index = index;
    }

    public List<String> getList() {
        return list;
    }

    private int index;

    public int getIndex() {
        return index;
    }

    public boolean textIsEqualTo(List<String> other){
        if(this.getList().equals(other))
            return true;
        return false;
    }

	public boolean textIsEqualTo(TextCandidate other){
        if(this.textIsEqualTo(other.getList()))
            return true;
        return false;
    }

    public boolean textIsNotEqualTo(List<String> other){
        return !this.textIsEqualTo(other);
    }

    public boolean textIsNotEqualTo(TextCandidate other){
        return !this.textIsEqualTo(other);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        TextCandidate that = (TextCandidate) o;

        if (index != that.index) return false;
        return list.equals(that.list);

    }

    @Override
    public int hashCode() {
        int result = list.hashCode();
        result = 31 * result + index;
        return result;
    }
}

@@ -43,16 +43,46 @@
 arker;%0A%0A
+import java.util.Collections;%0A
 import j
@@ -533,20 +533,50 @@
  return 
+Collections.unmodifiableList(
 list
+)
 ;%0A    %7D%0A

Make TextCandidate.getList() return immutable object