use of uk.gov.gchq.gaffer.serialisation.Serialiser in project Gaffer by gchq.
the class ElementCloner method cloneElement.
/**
* Clone an {@link Element}, based on a target {@link Schema}.
*
* @param element the element to clone
* @param schema the schema
* @return the cloned element
*/
public Element cloneElement(final Element element, final Schema schema) {
try {
final Element clone = element.emptyClone();
final SchemaElementDefinition sed = schema.getElement(clone.getGroup());
for (final String propertyName : element.getProperties().keySet()) {
final Object property = element.getProperty(propertyName);
if (null == sed.getPropertyTypeDef(propertyName) || null == sed.getPropertyTypeDef(propertyName).getSerialiser()) {
// This can happen if transient properties are derived - they will not have serialisers.
LOGGER.warn("Can't find Serialisation for {}, returning uncloned property", propertyName);
clone.putProperty(propertyName, property);
} else if (null != property) {
final Serialiser serialiser = sed.getPropertyTypeDef(propertyName).getSerialiser();
clone.putProperty(propertyName, serialiser.deserialise(serialiser.serialise(property)));
} else {
clone.putProperty(propertyName, null);
}
}
return clone;
} catch (final SerialisationException e) {
throw new RuntimeException("SerialisationException converting elements", e);
}
}
use of uk.gov.gchq.gaffer.serialisation.Serialiser in project gaffer-doc by gchq.
the class PropertiesWalkthrough method listOtherSerialisers.
protected boolean listOtherSerialisers(final Class<?> clazz) {
final List<String> serialiserClasses = new ArrayList<>();
for (final Serialiser serialise : SERIALISERS) {
if (serialise.canHandle(clazz)) {
serialiserClasses.add(WalkthroughStrSubstitutor.getJavaDocLink(serialise.getClass(), false, 3));
}
}
if (!serialiserClasses.isEmpty()) {
print(SERIALISERS_KEY, "\nOther Serialisers:");
print(SERIALISERS_KEY, "\n- " + StringUtils.join(serialiserClasses, "\n- "));
}
return !serialiserClasses.isEmpty();
}
use of uk.gov.gchq.gaffer.serialisation.Serialiser in project gaffer-doc by gchq.
the class PropertiesWalkthrough method getSerialisers.
private static List<Serialiser> getSerialisers() {
final List<Serialiser> serialisers = getSubClassInstances(Serialiser.class);
serialisers.removeIf(c -> {
boolean contains = false;
for (final ToBytesSerialiser serialiser : TO_BYTES_SERIALISERS) {
if (serialiser.getClass().equals(c.getClass())) {
contains = true;
break;
}
}
return contains;
});
return serialisers;
}
Aggregations