Forum Stats

  • 3,760,200 Users
  • 2,251,663 Discussions
  • 7,871,021 Comments

Discussions

Generic class

843793
843793 Member Posts: 41,732 Green Ribbon
edited May 17, 2010 1:15PM in Generics
I have one inteface



public interface Semiring<L>{

public L join(L a);

public L meet(L a);

public L top();

public L bot();
}



one abstract class

abstract class Label<L extends Comparable<L>> implements Comparable<Label<L>>,Semiring<L>{

private L value;

/**
* Set the value of Label <tt>value</tt>.
*
* @param value
*/
public Label(L value){
this.value = value;
}

/**
* Get the value of Label <tt>value</tt>.
*
*/
public L getValue(){
return value;
}

/**
* Verify if Label <tt>label</tt> is equals to Label <tt>value</tt>.
*
* @param label
*/
public boolean equals(Label<L> label){
return value.equals(label.getValue());
}


/**
* Compare Label <tt>value</tt> to Label <tt>label</tt>
*
* @param label
*/
public int compareTo(Label<L> label) {
return value.compareTo(label.getValue());
}

@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((value == null) ? 0 : value.hashCode());
return result;
}

/**
* Verify if Label <tt>label</tt> is equals to Object <tt>obj</tt>.
*
* @param label
*/
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Label<?> other = (Label<?>) obj;
if (value == null) {
if (other.value != null)
return false;
} else if (!value.equals(other.value))
return false;
return true;
}
}

and 5 instances of Label
public class LabelBoolean extends Label<Boolean>
....
....
....

one class that use Label
public class Entry<S extends Comparable<S>, T extends Comparable<T>, L extends Label<?>> implements Comparable<Entry<S, T, L>>

Until here i dont have any problem, but with this class

public class EntrySetLRelation<S extends Comparable<S>, T extends Comparable<T>, L extends Label<?>>
extends AbstractLRelation<S, T ,L>


i have one error

public <U extends Comparable<U>> LRelation<S, U, L> compose(LRelation<T, U, L> relation) {
/*if (relation instanceof DelayedTransitiveClosure) {
return (LRelation<S, U, L>)this.compose(LRelations.multiSourceReachMark((LRelation<T, T, L>)relation, this.range()));
}*/
LRelation<S, U, L> result = new EntrySetLRelation<S, U, L>();
for (Entry<S, T, L> e : set) {
for (Entry<T, U, L> e2 : relation) {
if (e.getSecond().equals(e2.getFirst())){

result.add(new Entry<S, U, L>(e.getFirst(), e2.getSecond(), new L(e.getLabel().meet(e2.getLabel().getValue()))));
}
}
}
return result;
}

"
The method meet(capture#4-of ?) in the type Semiring<capture#4-of ?> is not applicable for the
arguments (capture#1-of ?)
"

Comments

This discussion has been closed.