I'm stepping into an open source project, currently built using Maven2. I imported the project into Eclipse and this bit of code is giving me problems:
public static enum HierarchyType implements Function<MonetarySummary, SumOfMoney>, Predicate<Txaction> {
EARNINGS {
@Override
public SumOfMoney apply(MonetarySummary summary) {
return summary.getEarnings();
}
@Override
public boolean apply(Txaction txaction) {
return txaction.getAmount().signum() > 0;
}
},
SPENDING {
@Override
public SumOfMoney apply(MonetarySummary summary) {
return summary.getSpending();
}
@Override
public boolean apply(Txaction txaction) {
return txaction.getAmount().signum() < 0;
}
},
NET {
@Override
public SumOfMoney apply(MonetarySummary summary) {
return summary.getNet();
}
@Override
public boolean apply(Txaction txaction) {
return true;
}
}
}
Both Function
and Predicate
have apply
methods (they're from the Google commons):
public interface Function<F, T> {
T apply(@Nullable F from);
...
}
public interface Predicate<T> {
boolean apply(@Nullable T input);
}
Here's the error I get, in Eclipse only:
Description Resource Path Location Type
Name clash: The method apply(F) of type Function<F,T> has the same erasure as apply(T) of type Predicate<T> but does not override it
Name clash: The method apply(F) of type Function<F,T> has the same erasure as apply(T) of type Predicate<T> but does not override it
Name clash: The method apply(F) of type Function<F,T> has the same erasure as apply(T) of type Predicate<T> but does not override it
Name clash: The method apply(T) of type Predicate<T> has the same erasure as apply(F) of type Function<F,T> but does not override it
Name clash: The method apply(T) of type Predicate<T> has the same erasure as apply(F) of type Function<F,T> but does not override it
Name clash: The method apply(T) of type Predicate<T> has the same erasure as apply(F) of type Function<F,T> but does not override it
So, what's going on here? Is it a compiler flag?
For what it's worth, I'm running Eclipse 3.6, and maven is building using Java 1.6 on my OSX box:
Version: Helios Release
Build id: 20100617-1415
javac -version
javac 1.6.0_20