private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); Type<E> type = SerializationContext.getType(entityClass); EntityProxy<E> proxy = type.proxyProvider().apply(entity); for (Property<E, ?> property : proxy.filterProperties(getPropertyFilter())) { Object value = property.get(); stream.writeObject(value); } }
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); Type<E> type = SerializationContext.getType(entityClass); entity = type.factory().get(); EntityProxy<E> proxy = type.proxyProvider().apply(entity); for (Property<E, ?> property : proxy.filterProperties(getPropertyFilter())) { Object value = stream.readObject(); property.setObject(value, PropertyState.LOADED); } }