org.fudgemsg
Class ImmutableFudgeMsg

java.lang.Object
  extended by org.fudgemsg.FudgeMsgBase
      extended by org.fudgemsg.ImmutableFudgeMsg
All Implemented Interfaces:
Serializable, Iterable<FudgeField>, FudgeFieldContainer, ImmutableFudgeFieldContainer

public class ImmutableFudgeMsg
extends FudgeMsgBase
implements ImmutableFudgeFieldContainer

An immutable message in the Fudge system.

The message consists of a list of Fudge fields. This class holds the entire message in memory.

Applications are recommended to store and manipulate a ImmutableFudgeFieldContainer instance rather than this class for future flexibility.

This class can be created as a copy of an existing FudgeFieldContainer. For efficiency, the reference to a FudgeContext is kept and the context is not copied. In that scenario, changes made to the context will be made visible through this class, for example the behavior of FudgeMsgBase.getFieldValue(java.lang.Class, org.fudgemsg.FudgeField). If this is not desired, create a ImmutableFudgeContext from your underlying FudgeContext for use in cloning messages. Message fields are copied at one level deep only. Any sub-messages, or referenced objects may be still be mutable.

This class is intended to be immutable but not all contents will necessarily be immutable.

See Also:
Serialized Form

Constructor Summary
protected ImmutableFudgeMsg(FudgeContext fudgeContext)
          Creates an immutable empty message.
  ImmutableFudgeMsg(FudgeFieldContainer fields, FudgeContext fudgeContext)
          Creates a new ImmutableFudgeMsg by copying fields from another FudgeFieldContainer using the specified FudgeContext for type resolution.
  ImmutableFudgeMsg(FudgeMsgBase fudgeMsg)
          Creates a new instance by copying another message.
 
Method Summary
 boolean equals(Object obj)
          Checks if this message equals another.
 
Methods inherited from class org.fudgemsg.FudgeMsgBase
fieldNameEquals, fieldOrdinalEquals, getAllByName, getAllByOrdinal, getAllFieldNames, getAllFields, getBoolean, getBoolean, getByIndex, getByName, getByOrdinal, getByte, getByte, getDouble, getDouble, getFields, getFieldValue, getFirstTypedValue, getFirstTypedValue, getFloat, getFloat, getFudgeContext, getInt, getInt, getLong, getLong, getMessage, getMessage, getNumFields, getShort, getShort, getString, getString, getValue, getValue, getValue, getValue, hasField, hasField, hashCode, isEmpty, iterator, setNamesFromTaxonomy, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.fudgemsg.FudgeFieldContainer
getAllByName, getAllByOrdinal, getAllFieldNames, getAllFields, getBoolean, getBoolean, getByIndex, getByName, getByOrdinal, getByte, getByte, getDouble, getDouble, getFieldValue, getFloat, getFloat, getInt, getInt, getLong, getLong, getMessage, getMessage, getNumFields, getShort, getShort, getString, getString, getValue, getValue, getValue, getValue, hasField, hasField, isEmpty, iterator
 

Constructor Detail

ImmutableFudgeMsg

public ImmutableFudgeMsg(FudgeMsgBase fudgeMsg)
Creates a new instance by copying another message.

The new instance will share the same Fudge context which may be undesirable as that context may be mutable.

Parameters:
fudgeMsg - the message to copy, not null

ImmutableFudgeMsg

public ImmutableFudgeMsg(FudgeFieldContainer fields,
                         FudgeContext fudgeContext)
Creates a new ImmutableFudgeMsg by copying fields from another FudgeFieldContainer using the specified FudgeContext for type resolution.

Parameters:
fields - the message to copy, not null
fudgeContext - the context to use for the new message, not null

ImmutableFudgeMsg

protected ImmutableFudgeMsg(FudgeContext fudgeContext)
Creates an immutable empty message.

Parameters:
fudgeContext - the context, not null
Method Detail

equals

public boolean equals(Object obj)
Checks if this message equals another.

The check is performed on the entire list of fields in the message.

Overrides:
equals in class FudgeMsgBase
Parameters:
obj - the object to compare to, null returns false
Returns:
true if equal


Copyright 2009-Present by OpenGamma Inc. and individual contributors
Released under the Apache License, Version 2.0