@Override public int hashCode() { int result = id; result = 31 * result + (externalizer.getClass() != null ? externalizer.getClass().hashCode() : 0); return result; }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; ExternalizerAdapter that = (ExternalizerAdapter) o; if (id != that.id) return false; if (externalizer != null ? !externalizer.getClass().equals(that.externalizer.getClass()) : that.externalizer != null) return false; return true; }
private void loadForeignMarshallables(GlobalConfiguration globalCfg) { log.trace("Loading user defined externalizers"); for (Map.Entry<Integer, AdvancedExternalizer<?>> config : globalCfg.serialization().advancedExternalizers().entrySet()) { AdvancedExternalizer<?> ext = config.getValue(); // If no XML or programmatic config, id in annotation is used // as long as it's not default one (meaning, user did not set it). // If XML or programmatic config in use ignore @Marshalls annotation and use value in config. Integer id = ext.getId(); if (config.getKey() == null && id == null) throw new CacheConfigurationException( String.format( "No advanced externalizer identifier set for externalizer %s", ext.getClass().getName())); else if (config.getKey() != null) id = config.getKey(); id = checkForeignIdLimit(id, ext); updateExtReadersWritersWithTypes( new ForeignExternalizerAdapter(id, ext), generateForeignReaderIndex(id)); } }
@Override public String toString() { // Each adapter is represented by the externalizer it delegates to, so just return the class // name return externalizer.getClass().getName(); }
@Override public void writeObject(Marshaller output, Object object) throws IOException { output.write(id); externalizer.writeObject(output, object); }
public Object readObject(Unmarshaller input) throws IOException, ClassNotFoundException { return externalizer.readObject(input); }
void addInternalExternalizer(AdvancedExternalizer<?> ext) { int id = checkInternalIdLimit(ext.getId(), ext); updateExtReadersWritersWithTypes(new ExternalizerAdapter(id, ext)); }