1717 * <p>
1818 * The class can be used as an argument or return type for serialization-based RPC technologies like RMI.
1919 * <p>
20- * There are three ways to use this class to serialize instances which have an optional attribute .
20+ * There are three ways to use this class to serialize instances which have an optional field .
2121 * <p>
22- * <h2>Transform On Serialization</h2> The attribute can be declared as {@code transient Optional<T> optionalAttribute },
22+ * <h2>Transform On Serialization</h2> The field can be declared as {@code transient Optional<T> optionalField },
2323 * which will exclude it from serialization.
2424 * <p>
2525 * The class then needs to implement custom (de)serialization methods {@code writeObject} and {@code readObject}. They
26- * must transform the {@code optionalAttribute } to a {@code SerializableOptional} when writing the object and after
26+ * must transform the {@code optionalField } to a {@code SerializableOptional} when writing the object and after
2727 * reading such an instance transform it back to an {@code Optional}.
2828 * <p>
2929 * <h3>Code Example</h3>
3232 * private void writeObject(ObjectOutputStream out) throws IOException {
3333 * out.defaultWriteObject();
3434 * out.writeObject(
35- * SerializableOptional.fromOptional(optionalAttribute ));
35+ * SerializableOptional.fromOptional(optionalField ));
3636 * }
3737 *
3838 * private void readObject(ObjectInputStream in)
3939 * throws IOException, ClassNotFoundException {
4040 *
4141 * in.defaultReadObject();
42- * optionalAttribute =
42+ * optionalField =
4343 * ((SerializableOptional<T>) in.readObject()).toOptional();
4444 * }
4545 * </pre>
4646 * <p>
4747 * <h2>Transform On Replace</h2> If the class is serialized using the Serialization Proxy Pattern (see <i>Effective
4848 * Java</i> by Joshua Bloch, Item 78), the proxy can have an instance of {@link SerializableOptional} to clearly denote
49- * the attribute as being optional.
49+ * the field as being optional.
5050 * <p>
5151 * In this case, the proxy needs to transform the {@code Optional} to {@code SerializableOptional} in its constructor
5252 * (using {@link SerializableOptional#fromOptional(Optional)}) and the other way in {@code readResolve()} (with
5353 * {@link SerializableOptional#asOptional()}).
5454 * <p>
55- * <h2>Transform On Access</h2> The attribute can be declared as {@code SerializableOptional<T> optionalAttribute }. This
55+ * <h2>Transform On Access</h2> The field can be declared as {@code SerializableOptional<T> optionalField }. This
5656 * will include it in the (de)serialization process so it does not need to be customized.
5757 * <p>
58- * But methods interacting with the attribute need to get an {@code Optional} instead. This can easily be done by
59- * writing the accessor methods such that they transform the attribute on each access.
58+ * But methods interacting with the field need to get an {@code Optional} instead. This can easily be done by writing
59+ * the accessor methods such that they transform the field on each access.
6060 * <p>
6161 * Note that {@link #asOptional()} simply returns the {@code Optional} which with this instance was created so no
6262 * constructor needs to be invoked.
6363 * <p>
64- * <h3>Code Example</h3> Note that it is rarely useful to expose an optional attribute via accessor methods. Hence the
64+ * <h3>Code Example</h3> Note that it is rarely useful to expose an optional field via accessor methods. Hence the
6565 * following are private and for use inside the class.
6666 *
6767 * <pre>
68- * private Optional<T> getOptionalAttribute () {
69- * return optionalAttribute .asOptional();
68+ * private Optional<T> getOptionalField () {
69+ * return optionalField .asOptional();
7070 * }
7171 *
72- * private void setOptionalAttribute (Optional<T> optionalAttribute ) {
73- * this.optionalAttribute = SerializableOptional.fromOptional(optionalAttribute );
72+ * private void setOptionalField (Optional<T> optionalField ) {
73+ * this.optionalField = SerializableOptional.fromOptional(optionalField );
7474 * }
7575 * </pre>
7676 *
@@ -85,8 +85,7 @@ public final class SerializableOptional<T extends Serializable> implements Seria
8585 private static final long serialVersionUID = -652697447004597911L ;
8686
8787 /**
88- * The wrapped {@link Optional}. Note that this attribute is transient so it will not be (de)serializd
89- * automatically.
88+ * The wrapped {@link Optional}. Note that this field is transient so it will not be (de)serializd automatically.
9089 */
9190 private final Optional <T > optional ;
9291
0 commit comments