first commit

This commit is contained in:
2025-07-28 13:56:49 +05:30
commit e9eb805edb
3438 changed files with 520990 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
package org.apache.commons.beanutils.converters;
import org.apache.commons.beanutils.ConversionException;
import org.apache.commons.beanutils.Converter;
public final class ByteConverter implements Converter {
private Object defaultValue;
private boolean useDefault;
public ByteConverter() {
this.defaultValue = null;
this.useDefault = true;
this.defaultValue = null;
this.useDefault = false;
}
public ByteConverter(Object defaultValue) {
this.defaultValue = null;
this.useDefault = true;
this.defaultValue = defaultValue;
this.useDefault = true;
}
public Object convert(Class type, Object value) {
if (value == null) {
if (this.useDefault)
return this.defaultValue;
throw new ConversionException("No value specified");
}
if (value instanceof Byte)
return value;
if (value instanceof Number)
return new Byte(((Number)value).byteValue());
try {
return new Byte(value.toString());
} catch (Exception e) {
if (this.useDefault)
return this.defaultValue;
throw new ConversionException(e);
}
}
}