-
Notifications
You must be signed in to change notification settings - Fork 123
Using bijection from java
johnynek edited this page Jan 12, 2013
·
3 revisions
Here's an example of implementing a bijection in Java:
// This is not a mathematically correct bijection for all strings,
// since only the subset of canonical representations of Long as valid inputs.
// It is here only as a convenient example implementation
public class StringToLong extends AbstractBijection<String,Long> {
@Override
public Long apply(String a) {
return Long.parseLong(a);
}
@Override
public String invert(Long b) {
return b.toString();
}
}