Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

object-mapper - change visibility of HectorObjectMapper#addToExtraIfCan to protected #583

Open
maciejmiklas opened this Issue Jan 21, 2013 · 0 comments

Comments

Projects
None yet
1 participant

HectorObjectMapper#addToExtraIfCan can be overwritten in order to modify mapping results.
This can be used to return modification timestamp additionally to column value.

Overwritten addToExtraIfCan-method could look like:

@Override protected <T> void addToExtraIfCan(....){
  if (null == meth) {throw new....}
    if (cfMapDef.getAnonymousValueType() == ColumnValue.class) {
      T value = (T) cfMapDef.getAnonymousValueSerializer().fromBytes(col.getValue());
      ColumnValue<T> val = new ColumnValue<T>(value, col.getClock());
      meth.invoke(obj, col.getName(), val);
    } else {
      meth.invoke(obj, col.getName(), cfMapDef.getAnonymousValueSerializer().fromBytes(col.getValue()));
   }
}
public final class ColumnValue<T> {
    public final T value;
    public final long timestamp;
    public ColumnValue(T value, long timestamp) {
        this.value = value;
        this.timestamp = timestamp;
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment