io.permazen.encoding.ShortEncoding Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of permazen-encoding Show documentation
Show all versions of permazen-encoding Show documentation
Permazen classes for encoding Java values to/from binary representations.
The newest version!
/*
* Copyright (C) 2015 Archie L. Cobbs. All rights reserved.
*/
package io.permazen.encoding;
import org.dellroad.stuff.java.Primitive;
/**
* Short type.
*/
public class ShortEncoding extends IntegralEncoding {
private static final long serialVersionUID = 3817308228385115418L;
public ShortEncoding(EncodingId encodingId) {
super(encodingId, Primitive.SHORT);
}
@Override
protected Short convertNumber(Number value) {
return value.shortValue();
}
@Override
protected Short downCast(long value) {
return (short)value;
}
@Override
public Short validate(Object obj) {
if (obj instanceof Byte)
return ((Number)obj).shortValue();
return super.validate(obj);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy