org.fudgemsg
Class FudgeMsgField

java.lang.Object
  extended by org.fudgemsg.FudgeMsgField
All Implemented Interfaces:
Serializable, FudgeField

public class FudgeMsgField
extends Object
implements FudgeField, Serializable

A single immutable field in the Fudge system.

This is the standard immutable implementation of FudgeField.

This class is immutable and thread-safe but is not final.

See Also:
Serialized Form

Constructor Summary
FudgeMsgField(FudgeField field)
          Constructs a field as a copy of another.
FudgeMsgField(FudgeFieldType<?> type, Object value, String name, Short ordinal)
          Constructs a field from the type, value, name and ordinal.
 
Method Summary
 boolean equals(Object obj)
          Compares this field to another field.
 String getName()
          Gets the optional field name.
 Short getOrdinal()
          Gets the optional field ordinal.
 FudgeFieldType<?> getType()
          Gets the Fudge type of the value.
 Object getValue()
          Gets the field value.
static FudgeMsgField of(FudgeField field)
          Obtains an immutable version of the specified field.
static FudgeMsgField of(FudgeFieldType<?> type, Object value)
          Obtains a field from the type, value, name and ordinal.
static FudgeMsgField of(FudgeFieldType<?> type, Object value, Short ordinal)
          Obtains a field from the type, value, name and ordinal.
static FudgeMsgField of(FudgeFieldType<?> type, Object value, String name)
          Obtains a field from the type, value, name and ordinal.
static FudgeMsgField of(FudgeFieldType<?> type, Object value, String name, Short ordinal)
          Obtains a field from the type, value, name and ordinal.
 String toString()
          Gets a string description of the field.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FudgeMsgField

public FudgeMsgField(FudgeFieldType<?> type,
                     Object value,
                     String name,
                     Short ordinal)
Constructs a field from the type, value, name and ordinal.

Parameters:
type - the Fudge field type, not null
value - the payload value, may be null
name - the optional field name, null if no name
ordinal - the optional field ordinal, null if no ordinal

FudgeMsgField

public FudgeMsgField(FudgeField field)
Constructs a field as a copy of another.

Parameters:
field - the FudgeMsgField to copy.
Method Detail

of

public static FudgeMsgField of(FudgeField field)
Obtains an immutable version of the specified field.

If the field is an instance of this class, it is returned, otherwise a new instance is created.

Parameters:
field - the field to obtain data from, not null
Returns:
the equivalent immutable field, not null

of

public static FudgeMsgField of(FudgeFieldType<?> type,
                               Object value)
Obtains a field from the type, value, name and ordinal.

Parameters:
type - the Fudge field type, not null
value - the payload value, may be null
Returns:
the created immutable field, not null

of

public static FudgeMsgField of(FudgeFieldType<?> type,
                               Object value,
                               String name)
Obtains a field from the type, value, name and ordinal.

Parameters:
type - the Fudge field type, not null
value - the payload value, may be null
name - the optional field name, null if no name
Returns:
the created immutable field, not null

of

public static FudgeMsgField of(FudgeFieldType<?> type,
                               Object value,
                               Short ordinal)
Obtains a field from the type, value, name and ordinal.

Parameters:
type - the Fudge field type, not null
value - the payload value, may be null
ordinal - the optional field ordinal, null if no ordinal
Returns:
the created immutable field, not null

of

public static FudgeMsgField of(FudgeFieldType<?> type,
                               Object value,
                               String name,
                               Short ordinal)
Obtains a field from the type, value, name and ordinal.

Parameters:
type - the Fudge field type, not null
value - the payload value, may be null
name - the optional field name, null if no name
ordinal - the optional field ordinal, null if no ordinal
Returns:
the created immutable field, not null

getType

public FudgeFieldType<?> getType()
Gets the Fudge type of the value.

The type should match the value.

Specified by:
getType in interface FudgeField
Returns:
the Fudge field type, not null

getValue

public Object getValue()
Gets the field value.

The value is the payload of the field.

Specified by:
getValue in interface FudgeField
Returns:
the field value, may be null

getName

public String getName()
Gets the optional field name.

The name is a string that identifies the meaning of the data. This is similar to the tag name in XML.

Specified by:
getName in interface FudgeField
Returns:
the field name, null if the field has no name

getOrdinal

public Short getOrdinal()
Gets the optional field ordinal.

The ordinal is a number that identifies the meaning of the data. It is typically a reference into the taxonomy.

Specified by:
getOrdinal in interface FudgeField
Returns:
the field ordinal, null if the field has no ordinal

equals

public boolean equals(Object obj)
Compares this field to another field.

This checks the type, value, name and ordinal.

Overrides:
equals in class Object
Parameters:
obj - the other field, null returns false
Returns:
true if equal

toString

public String toString()
Gets a string description of the field.

Overrides:
toString in class Object
Returns:
the description, not null


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