* Copyright (C) 2007 The Guava Authors
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
method must be overridden to return the instance being decorated.
This class does not forward the
methods through to the backing object, but relies on
implementation. This is necessary to preserve the symmetry of
Custom definitions of equality are usually based on an interface, such as
List, so that the implementation of
cast the object being tested for equality to the custom interface.
ForwardingObject implements no such custom interfaces directly; they
are implemented only in subclasses. Therefore, forwarding
would break symmetry, as the forwarding object might consider itself equal to
the object being tested, but the reverse could not be true. This behavior is
consistent with the JDK's collection wrappers, such as
. Use an
interface-specific subclass of
ForwardingObject, such as
, to preserve equality behavior, or override
toString method is forwarded to the delegate. Although this
class does not implement
, a serializable subclass may be
created since this class has a parameter-less constructor.
. Concrete subclasses override this method to supply the instance being decorated.
/* No equals or hashCode. See class comments for details. */