Skip to content

Commit

Permalink
Document ListSource.lightList regarding the serialization subtleties
Browse files Browse the repository at this point in the history
  • Loading branch information
kwvanderlinde committed Nov 2, 2023
1 parent b470610 commit eeedfaf
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/main/java/net/rptools/maptool/model/LightSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,20 @@ public enum Type {
private final @Nullable GUID id;
private final @Nonnull Type type;
private final boolean scaleWithToken;

/**
* This light segments that make up the light source.
*
* <p>In practice this will be an {@code ImmutableList} during runtime. However, previously
* serialized {@code LightSource} instances may have specified that it must be a {@code
* LinkedList} or other specific {@code List} implementation. So we need to keep this as a {@code
* List} in order to deserialize those.
*
* <p>There is also one case where it won't be an {@code ImmutableList}, and that is during
* serialization. At such a time, a temporary {@code LightSource} is created with an {@code
* ArrayList} instead. (see {@link #writeReplace()}) so that the XML does not depend on the use of
* {@code ImmutableList} or any other particular {@code List} implementation.
*/
private final @Nonnull List<Light> lightList;

// Lumens are now in the individual Lights. This field is only here for backwards compatibility
Expand Down

0 comments on commit eeedfaf

Please sign in to comment.