mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
Reduce line padding.
This commit is contained in:
@@ -37,7 +37,6 @@ import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* @author Rob Austin.
|
||||
*/
|
||||
@@ -45,6 +44,45 @@ public class DataValueConverter implements Converter {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(DataValueConverter.class);
|
||||
|
||||
private static Object toNativeValueObjects(HierarchicalStreamReader reader,
|
||||
final Class aClass,
|
||||
UnmarshallingContext context) {
|
||||
|
||||
final Object o = DataValueClasses.newDirectInstance(aClass);
|
||||
|
||||
try {
|
||||
|
||||
final BeanInfo info = Introspector.getBeanInfo(o.getClass()); // new BeanGenerator
|
||||
|
||||
for (PropertyDescriptor p : info.getPropertyDescriptors()) {
|
||||
|
||||
if (!p.getName().equals("value"))
|
||||
continue;
|
||||
|
||||
final String value = reader.getValue();
|
||||
|
||||
if (StringValue.class.isAssignableFrom(o.getClass())) {
|
||||
((StringValue) o).setValue(value);
|
||||
return o;
|
||||
}
|
||||
|
||||
final Class<?> propertyType = p.getPropertyType();
|
||||
|
||||
final Object o1 = context.convertAnother(value, propertyType);
|
||||
p.getWriteMethod().invoke(o, o1);
|
||||
|
||||
return o;
|
||||
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new ConversionException("class=" + aClass.getName(), e);
|
||||
}
|
||||
|
||||
throw new ConversionException("setValue(..) method not found in class=" +
|
||||
aClass.getCanonicalName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void marshal(Object o, HierarchicalStreamWriter writer, MarshallingContext context) {
|
||||
|
||||
@@ -78,7 +116,6 @@ public class DataValueConverter implements Converter {
|
||||
throw new ConversionException("class=" + canonicalName);
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
DataValueModel<?> dataValueModel = DataValueModels.acquireModel(interfaceClass(o.getClass()));
|
||||
|
||||
@@ -138,7 +175,6 @@ public class DataValueConverter implements Converter {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
|
||||
final Method readMethod = fileModel.getter();
|
||||
@@ -161,7 +197,6 @@ public class DataValueConverter implements Converter {
|
||||
LOG.error("class=" + fileModel.name(), e);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
} catch (ClassNotFoundException e) {
|
||||
@@ -188,7 +223,6 @@ public class DataValueConverter implements Converter {
|
||||
return Class.forName(nodeName);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object unmarshal(HierarchicalStreamReader reader,
|
||||
UnmarshallingContext context) {
|
||||
@@ -289,46 +323,6 @@ public class DataValueConverter implements Converter {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static Object toNativeValueObjects(HierarchicalStreamReader reader,
|
||||
final Class aClass,
|
||||
UnmarshallingContext context) {
|
||||
|
||||
final Object o = DataValueClasses.newDirectInstance(aClass);
|
||||
|
||||
try {
|
||||
|
||||
final BeanInfo info = Introspector.getBeanInfo(o.getClass()); // new BeanGenerator
|
||||
|
||||
for (PropertyDescriptor p : info.getPropertyDescriptors()) {
|
||||
|
||||
if (!p.getName().equals("value"))
|
||||
continue;
|
||||
|
||||
final String value = reader.getValue();
|
||||
|
||||
if (StringValue.class.isAssignableFrom(o.getClass())) {
|
||||
((StringValue) o).setValue(value);
|
||||
return o;
|
||||
}
|
||||
|
||||
final Class<?> propertyType = p.getPropertyType();
|
||||
|
||||
final Object o1 = context.convertAnother(value, propertyType);
|
||||
p.getWriteMethod().invoke(o, o1);
|
||||
|
||||
return o;
|
||||
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new ConversionException("class=" + aClass.getName(), e);
|
||||
}
|
||||
|
||||
throw new ConversionException("setValue(..) method not found in class=" +
|
||||
aClass.getCanonicalName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConvert(Class clazz) {
|
||||
final String canonicalName = clazz.getCanonicalName();
|
||||
|
||||
Reference in New Issue
Block a user