Package com.storedobject.core
Class Link<L extends StoredObject>
java.lang.Object
com.storedobject.core.Link<L>
- Type Parameters:
L- Type of the child object.
A class to represent a link of the master object to a child object.
- Author:
- Syam
-
Constructor Summary
ConstructorsConstructorDescriptionLink(Class<? extends StoredObject> masterClass) Creates a new Link object with the specified master class. -
Method Summary
Modifier and TypeMethodDescriptionstatic Link<?> create(Class<? extends StoredObject> masterClass, String linkDetails) Creates a new Link object based on the specified master class and link details.createList(Class<? extends StoredObject> masterClass) Creates a list ofLinkobjects associated with the specified master class.createList(Class<? extends StoredObject> masterClass, StringList extraLinks) Creates a list ofLinkobjects associated with the specified master class and additional link details.booleanRetrieves the list of columns to be displayed in a browser for this link.Retrieves the condition associated with this link.Retrieves the class type of the link associated with this object.Retrieves the predicate used to evaluate load conditions.Class<? extends StoredObject> Retrieves the class of the master object associated with this link.getName()Retrieves the name associated with this link.Deprecated.Retrieves the order by clause for this link.intgetType()Retrieves the link type.booleanisAny()Checks if the 'any' flag is true.booleanisDetail()Determines if the link class is a detail of the specified master class.booleanisDetailOf(Class<? extends StoredObject> masterClass) Determines whether the current class is a detail of the specified master class.booleanChecks if the object is in a read-only state.Retrieves an iterator over a collection of objects linked to the specified master ID.list(StoredObject master) Creates an iterator for a list of objects linked to the specified master object.query(StoredObject master) Constructs and executes a query to retrieve linked objects from the specified StoredObject.voidsetAny()Set the "any" flag to specify whether any sun-classes of the link class should be included.voidsetBrowserColumns(StringList columns) Sets the browser columns for this link using aStringListof column names.voidsetBrowserColumns(String columns) Sets the browser columns for this link.voidsetCondition(String condition) Sets the condition associated with this link.voidsetLinkClass(Class<L> linkClass) Sets the class type of the link associated with this object.voidsetLinkClass(String className) Sets the class type of the link associated with this object using the class name.voidsetLoadPredicate(Predicate<L> loadPredicate) Sets the predicate used to determine whether a load operation should be performed for a given object of typeL.voidSets the name associated with this link.voidsetObjectClass(Class<L> linkClass) Deprecated.UsesetLinkClass(Class)instead.voidsetObjectClass(String className) Deprecated.UsesetLinkClass(String)instead.voidsetOrderBy(String orderBy) Sets the order by clause for this link.voidsetReadOnly(boolean readOnly) Sets the read-only status of the link.voidsetType(int type) Sets the type for this link.
-
Constructor Details
-
Link
Creates a new Link object with the specified master class.- Parameters:
masterClass- the class of the master object with which the link is associated; must be a subclass of StoredObject
-
-
Method Details
-
create
Creates a new Link object based on the specified master class and link details.Format of the link details: Name|Class name[/Any[/Link type]]|Order by|Columns Name|Class name[/Link type[/Any]]Order by|Columns- Parameters:
masterClass- the class of the master object with which the link is associated; must be a subclass of StoredObjectlinkDetails- a string defining the link details; the format of this string determines various properties of the created link- Returns:
- a newly created Link object configured according to the given master class and link details
- Throws:
SOClassError- if the link details are invalid for the specified master class
-
createList
Creates a list ofLinkobjects associated with the specified master class.- Parameters:
masterClass- the class of the master object with which the links are associated; must be a subclass ofStoredObject- Returns:
- a
ListofLinkobjects associated with the specified master class
-
createList
public static List<Link<?>> createList(Class<? extends StoredObject> masterClass, StringList extraLinks) Creates a list ofLinkobjects associated with the specified master class and additional link details.- Parameters:
masterClass- the class of the master object with which the links are associated; must be a subclass ofStoredObject.extraLinks- additional link details to be concatenated with the default links of the specified master class.- Returns:
- a
ListofLinkobjects created based on the specified master class and additional link details.
-
getObjectClass
Deprecated.UsegetLinkClass()instead.Retrieves the class type of the link associated with this object.- Returns:
- the
Classrepresenting the type of the link
-
getLinkClass
-
getMasterClass
Retrieves the class of the master object associated with this link.- Returns:
- the
Classrepresenting the master object type, which is a subclass ofStoredObject.
-
setObjectClass
Deprecated.UsesetLinkClass(Class)instead.Sets the class type of the link associated with this object.- Parameters:
linkClass- theClassobject representing the type of the link; must be compatible with the generic type parameterL
-
setLinkClass
-
setObjectClass
Deprecated.UsesetLinkClass(String)instead.Sets the class type of the link associated with this object using the class name. The class name will be resolved to determine the corresponding class type, which must be compatible with the generic type parameterL.- Parameters:
className- the fully qualified name of the class to be set as the link class; must correspond to a valid class type- Throws:
SORuntimeException- if any unexpected error occurs during class resolution
-
setLinkClass
Sets the class type of the link associated with this object using the class name. The class name will be resolved to determine the corresponding class type, which must be compatible with the generic type parameterL.- Parameters:
className- the fully qualified name of the class to be set as the link class; must correspond to a valid class type- Throws:
SORuntimeException- if any unexpected error occurs during class resolution
-
getName
Retrieves the name associated with this link.- Returns:
- the name of this link as a
String
-
setName
Sets the name associated with this link. The given name will be modified by replacing any underscore ('_') characters with a pipe ('|') character.- Parameters:
name- the name to be set; underscores in the provided string will be replaced with pipe characters
-
setBrowserColumns
Sets the browser columns for this link. If the provided string is empty or null, the browser columns will be set to null. Otherwise, the string will be processed and stored as a list of columns.- Parameters:
columns- a comma-separated string representing the browser columns to be set; if the string is null or consists entirely of whitespace, the browser columns will be cleared
-
setBrowserColumns
Sets the browser columns for this link using aStringListof column names. The provided list determines which columns will be displayed in the browser.- Parameters:
columns- aStringListcontaining the names of the browser columns to be set; if the list is null, the browser columns will be cleared.
-
getBrowseColumns
Retrieves the list of columns to be displayed in a browser for this link. If the browser columns have not been explicitly set but the link class is defined, the columns are determined based on the attributes of the link class.- Returns:
- a
StringListcontaining the names of the browser columns, ornullif no browser columns are defined and the link class is not specified.
-
setType
public void setType(int type) Sets the type for this link.- Parameters:
type- the integer value representing the type to be set
-
getType
public int getType()Retrieves the link type.- Returns:
- the link type as an integer
-
setOrderBy
Sets the order by clause for this link. This determines the order in which the linked objects will be retrieved or displayed.- Parameters:
orderBy- the order by clause to be set; should be a valid string representing the desired sort order, such as a column name or a comma-separated list of column names
-
getOrderBy
Retrieves the order by clause for this link. If the order by clause has not been explicitly set but the link class is defined, the order by clause is determined based on the attributes of the link class.- Returns:
- the order by clause as a
String, ornullif no order by clause is defined and the link class is not specified.
-
setCondition
Sets the condition associated with this link. This condition determines additional filtering or constraints for the linked objects.- Parameters:
condition- the condition to be set; should be a valid string representing the filtering criteria or constraints for the link.
-
getCondition
Retrieves the condition associated with this link. The condition specifies filtering or constraint criteria used for determining the linked objects.- Returns:
- the condition as a
String, ornullif no condition has been set.
-
setLoadPredicate
Sets the predicate used to determine whether a load operation should be performed for a given object of typeL. The provided predicate is applied during the load process to filter or control the loading mechanism. If the provided predicate isnull, a default predicate that always returnstruewill be assigned.- Parameters:
loadPredicate- the predicate to evaluate load conditions for objects of typeL, ornullto use a default predicate that always returnstrue.
-
getLoadPredicate
-
setAny
public void setAny()Set the "any" flag to specify whether any sun-classes of the link class should be included. -
isAny
public boolean isAny()Checks if the 'any' flag is true. This flag indicates that any sun-classes of the link class should be included.- Returns:
- true if the 'any' flag is true, false otherwise.
-
setReadOnly
public void setReadOnly(boolean readOnly) Sets the read-only status of the link.- Parameters:
readOnly- a boolean value wheretrueindicates that the link should be set to a read-only state, andfalseindicates that it should be writable.
-
isReadOnly
public boolean isReadOnly()Checks if the object is in a read-only state.- Returns:
- true if the object is read-only, false otherwise.
-
isDetail
public boolean isDetail()Determines if the link class is a detail of the specified master class.- Returns:
- true if the link class is a detail of the master class, false otherwise
-
isDetailOf
Determines whether the current class is a detail of the specified master class.- Parameters:
masterClass- the class to check if it is the master class for the detail- Returns:
- true if the current class is a detail of the specified master class, false otherwise
-
list
Retrieves an iterator over a collection of objects linked to the specified master ID. This method uses the `links` method internally.- Parameters:
master- the ID of the master element whose linked objects are to be retrieved.- Returns:
- an ObjectIterator over the linked objects.
-
list
Creates an iterator for a list of objects linked to the specified master object.- Parameters:
master- the master object whose linked objects are to be iterated. If the ID of the master object is null, an empty iterator is returned.- Returns:
- an iterator over the objects linked to the specified master object, or an empty iterator if the master object's ID is null.
-
query
Constructs and executes a query to retrieve linked objects from the specified StoredObject.- Parameters:
master- the StoredObject instance from which the links are queried- Returns:
- a Query object containing the results of the link query
-
equals
-
getLinkClass()instead.