MaxValue not respected for StringValue in 2.1.4

31 views
Skip to first unread message

Randy Prager

unread,
Jun 15, 2015, 4:36:32 PM6/15/15
to java-ch...@googlegroups.com
Here is the class

public interface ValueVOInterface {
public StringValue getPayload();
public void setPayload(@MaxSize(500) StringValue payload);
}


And here is the generated code


public class StringValue$$Native implements StringValue, BytesMarshallable, Byteable, Copyable<net.openhft.lang.values.StringValue> {
    private static final int VALUE = 0;


    private Bytes _bytes;
    private long _offset;



    public void setValue(java.lang.CharSequence $) {
        _bytes.writeUTFΔ(_offset + VALUE, 64, $);
    }

    public java.lang.String getValue() {
        return _bytes.readUTFΔ(_offset + VALUE);
    }

    public java.lang.StringBuilder getUsingValue(StringBuilder builder){
     _bytes.position(_offset + VALUE);
     _bytes.readUTFΔ(builder);
     return builder;
    }

    @Override
    public void copyFrom(net.openhft.lang.values.StringValue from) {
        setValue(from.getValue());
    }

    @Override
    public void writeMarshallable(Bytes out) {
        {
            long pos = out.position();
        out.writeUTFΔ(getValue());
            long newPos = pos + 64;
            out.zeroOut(out.position(), newPos);
            out.position(newPos);
        }
    }
    @Override
    public void readMarshallable(Bytes in) {
        setValue(in.readUTFΔ());
    }
    @Override
    public void bytes(Bytes bytes, long offset) {
       this._bytes = bytes;
       this._offset = offset;
    }
    @Override
    public Bytes bytes() {
       return _bytes;
    }
    @Override
    public long offset() {
        return _offset;
    }
    @Override
    public int maxSize() {
       return 64;
    }
    public int hashCode() {
        long lhc = longHashCode();
        return (int) ((lhc >>> 32) ^ lhc);
    }

    public long longHashCode() {
        return calcLongHashCode(getValue());
    }

    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof StringValue)) return false;
        StringValue that = (StringValue) o;

        if(!isEqual(getValue(), that.getValue())) return false;
        return true;
    }

    public String toString() {
        if (_bytes == null) return "bytes is null";
        StringBuilder sb = new StringBuilder();
        sb.append("StringValue{ ");
            sb.append("value= ").append(getValue());
        sb.append(" }");
        return sb.toString();
    }
}

Roman Leventov

unread,
Jun 19, 2015, 11:37:35 PM6/19/15
to java-ch...@googlegroups.com
@StringValue is "data class" itself, considered fixed-sized, when used as a field in another data class (nesting). @MaxValue would work if payload was CharSequence.

--
You received this message because you are subscribed to the Google Groups "Chronicle" group.
To unsubscribe from this group and stop receiving emails from it, send an email to java-chronicl...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages