public class

OEntityKey

extends Object
java.lang.Object
   ↳ org.odata4j.core.OEntityKey

Class Overview

An immutable entity-key, made up of either a single unnamed-value or multiple named-values. Every entity must have an entity-key. The entity-key must be unique within the entity-set, and thus defines an entity's identity. (see OEntityId)

An entity-key made up a a single unnamed-value is called a single key. An entity-key made up of multiple named-values is called a complex key.

The string representation of an entity-key is wrapped with parentheses, such as (2), ('foo') or (a=1,foo='bar').

Entity-keys are equal if their string representations are equal.

Summary

Nested Classes
enum OEntityKey.KeyType SINGLE or COMPLEX  
Fields
private static final Set<Class<?>> EDM_SIMPLE_JAVA_TYPES
private boolean isGuid
private String keyString
private final Object[] values
Public Methods
Set<OProperty<?>> asComplexProperties()
Gets the values of complex entity-key.
Set<NamedValue<?>> asComplexValue()
Gets the values of a complex entity-key.
Object asSingleValue()
Gets a the value of a single-valued entity-key.
static OEntityKey create(Object... values)
Creates an entity-key.
static OEntityKey create(Map<String, Object> values)
Creates an entity-key from a map of names and values.
boolean equals(Object obj)
OEntityKey.KeyType getKeyType()
Gets the entity-key type: SINGLE or COMPLEX.
int hashCode()
static OEntityKey infer(EdmEntitySet entitySet, List<OProperty<?>> props)
Creates an entity-key using key information from the given entity-set and values from the given property list.
boolean isGuid()
static OEntityKey parse(String keyString)
Creates an entity-key from its standard string representation.
void setIsGuid(boolean isGuid)
String toKeyString()
Gets the standard string representation of this entity-key, including parentheses.
String toKeyStringWithoutParentheses()
Gets the standard string representation of this entity-key, excluding parentheses.
String toString()
[Expand]
Inherited Methods
From class java.lang.Object

Fields

private static final Set<Class<?>> EDM_SIMPLE_JAVA_TYPES

private boolean isGuid

private String keyString

private final Object[] values

Public Methods

public Set<OProperty<?>> asComplexProperties ()

Gets the values of complex entity-key.

Returns
  • the key values as a set of properties

public Set<NamedValue<?>> asComplexValue ()

Gets the values of a complex entity-key.

Returns
  • the key values as a set of named-values

public Object asSingleValue ()

Gets a the value of a single-valued entity-key.

Returns
  • the key value

public static OEntityKey create (Object... values)

Creates an entity-key.

  • OEntityKey.create(2)
  • ,
  • OEntityKey.create("foo")
  • OEntityKey.create("a",1,"foo","bar")
  • OEntityKey.create(NamedValues.create("a",1),NamedValues.create("foo","bar"))

Parameters
values The key values
Returns
  • a newly-created entity-key

public static OEntityKey create (Map<String, Object> values)

Creates an entity-key from a map of names and values.

Parameters
values The map of names and values
Returns
  • a newly-created entity-key

public boolean equals (Object obj)

Parameters
obj

public OEntityKey.KeyType getKeyType ()

Gets the entity-key type: SINGLE or COMPLEX.

Returns
  • SINGLE or COMPLEX

public int hashCode ()

public static OEntityKey infer (EdmEntitySet entitySet, List<OProperty<?>> props)

Creates an entity-key using key information from the given entity-set and values from the given property list.

Parameters
entitySet An entity-set to provide key information
props A list of properties to provide key values
Returns
  • a newly-created entity-key

public boolean isGuid ()

public static OEntityKey parse (String keyString)

Creates an entity-key from its standard string representation.

Parameters
keyString A standard key-string
Returns
  • a newly-created entity-key

public void setIsGuid (boolean isGuid)

Parameters
isGuid

public String toKeyString ()

Gets the standard string representation of this entity-key, including parentheses.

Returns
  • the standard key-string

public String toKeyStringWithoutParentheses ()

Gets the standard string representation of this entity-key, excluding parentheses.

Returns
  • the standard key-string, without parentheses

public String toString ()