Class VersionedModelInfos<M extends IModel>
java.lang.Object
net.ssehub.easy.basics.modelManagement.VersionedModelInfos<M>
- Type Parameters:
M- the specific type of model
Stores model information objects of the same version.
- Author:
- Holger Eichelberger
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionVersionedModelInfos(Version version) Creates a new versioned model information container. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a model information object.voidclear()Removes all stored model information objects.Finds a model information object based on a give URI.static <M extends IModel>
VersionedModelInfos<M> find(List<VersionedModelInfos<M>> infos, Version version) Retrieves the version model information container with the specified version.get(int index) Returns the specified model information object.Returns the model information objects withurias location.Returns the model information objects withmodelas resolved model.getByClosestUri(URI uri, List<String> modelPath) Returns the model information with the closest match touri, i.e.Returns the model information frominfoswith the closest match touri, i.e.getByEqualUri(URI uri) Returns the model information with the exact match touri.Returns the version all information objects in this instance are assigned to.static booleanisFileScheme(URI uri) Returns whether the given URI is a file (file scheme).private static booleanisMatching(String searchUriText, String importUriText, boolean contained) Checks whether thesearchUriTextandimportUrimatch.private static booleanisMatching(String searchUriText, List<String> modelPath, String importUriText, boolean contained) Checks whether thesearchUriText(with precedence) ore one of themodelPathURI paths matchimportUri, i.e.static final booleanChecks two URIs for equality.maxVersion(List<ModelInfo<M>> list) Returns the model information object with highest version number fromlist.static StringReturns the prefix path of the givenuriwithout the last fragment.remove(int index) Removes the specified model information object.booleanRemoves the specified model information object.Searches for the best match according to the IVML search conventions, first down along the given URI, then up along the hierarchy.Searches for the best match within the parent-parent folders ofuriif that folder starts with ".".Search in folders on the level of the parent folder ofuri.intsize()Returns the number of contained version information objects.Adds all model information objects to the givenlist.toString()Returns the textual representation of this instance.
-
Field Details
-
version
-
infos
-
-
Constructor Details
-
VersionedModelInfos
Creates a new versioned model information container.- Parameters:
version- the version of this container (may be null)
-
-
Method Details
-
add
Adds a model information object.- Parameters:
info- the object to be added- Throws:
IllegalArgumentException- if the version ofinfodoes not matchversionor the name ofinfodoes not match the name of the first stored model information object (if there is any)
-
isSame
Checks two URIs for equality.- Parameters:
uri1- the first URI (may be null)uri2- the second URI (may be null)- Returns:
trueif both are the same,falseelse
-
get
Returns the specified model information object.- Parameters:
index- the index of the object to be returned- Returns:
- the specified object
- Throws:
IndexOutOfBoundsException- ifindex<0 || index>=size()
-
get
Returns the model information objects withmodelas resolved model.- Parameters:
model- the (resolved) model to search for- Returns:
- the model information object or null if there is none
-
get
Returns the model information objects withurias location.- Parameters:
uri- the URI to search for- Returns:
- the model information object or null if there is none
-
size
public int size()Returns the number of contained version information objects.- Returns:
- the number of version information objects
-
remove
Removes the specified model information object.- Parameters:
index- the index of the object to be returned- Returns:
- the removed object
- Throws:
IndexOutOfBoundsException- ifindex<0 || index>=size()
-
clear
public void clear()Removes all stored model information objects. -
remove
Removes the specified model information object.- Parameters:
info- the information object to be removed- Returns:
trueif successfulfalseelse
-
getVersion
Returns the version all information objects in this instance are assigned to.- Returns:
- the version
-
getByEqualUri
Returns the model information with the exact match touri.- Parameters:
uri- the URI to match with (may be null then the first information object is returned)- Returns:
- the matching model information (or null if none matches)
-
getByClosestUri
Returns the model information with the closest match touri, i.e. in closest in the same hierarchy path.- Parameters:
uri- the URI to match with (may be null then the first information object is returned)modelPath- additional URIs prefixes which shall be considered for importing, similar to the Java classpath, may be null- Returns:
- the matching model information (or null if none matches)
-
getByClosestUri
public static <M extends IModel> ModelInfo<M> getByClosestUri(List<ModelInfo<M>> infos, URI uri, List<String> modelPath) Returns the model information frominfoswith the closest match touri, i.e. in closest in the same hierarchy path.- Type Parameters:
M- the model type- Parameters:
infos- the information objects to be considereduri- the URI to match with (may be null then the first information object is returned)modelPath- additional URIs prefixes which shall be considered for importing, similar to the Java classpath, may be null- Returns:
- the matching model information (or null if none matches)
-
search
private static <M extends IModel> ModelInfo<M> search(List<ModelInfo<M>> infos, String searchUriText, List<String> modelPath) Searches for the best match according to the IVML search conventions, first down along the given URI, then up along the hierarchy.- Type Parameters:
M- the model type- Parameters:
infos- the information objects to be consideredsearchUriText- the search folder URI as textmodelPath- additional URIs prefixes which shall be considered for importing, similar to the Java classpath, may be null- Returns:
- the matching model information (or null if none matches)
-
searchOnParentLevel
private static <M extends IModel> ModelInfo<M> searchOnParentLevel(List<ModelInfo<M>> infos, URI uri, List<String> modelPath) Searches for the best match within the parent-parent folders ofuriif that folder starts with ".". This enables cross-links among parent models according to the convention EASy places imported IVML files.- Type Parameters:
M- the model type- Parameters:
infos- the information objects to be considereduri- the URI to start searchingmodelPath- additional URIs prefixes which shall be considered for importing, similar to the Java classpath, may be null- Returns:
- the matching model information (or null if none matches)
-
searchOnSameFolderLevel
private static <M extends IModel> ModelInfo<M> searchOnSameFolderLevel(List<ModelInfo<M>> infos, URI uri, List<String> modelPath) Search in folders on the level of the parent folder ofuri.- Type Parameters:
M- the model type- Parameters:
infos- the information objects to be considereduri- the URI to start searchingmodelPath- additional URIs prefixes which shall be considered for importing, similar to the Java classpath, may be null- Returns:
- the matching model information but only if this is unique
-
isFileScheme
Returns whether the given URI is a file (file scheme).- Parameters:
uri- the URI to test for- Returns:
trueif it is a file,falseelse
-
isMatching
private static boolean isMatching(String searchUriText, List<String> modelPath, String importUriText, boolean contained) Checks whether thesearchUriText(with precedence) ore one of themodelPathURI paths matchimportUri, i.e. whetherimportUriis an appropriate URI for import.- Parameters:
searchUriText- the textual URI of the model stating the importmodelPath- additional URI paths, may be nullimportUriText- the URI path of the model being considered for importcontained- prefer contained or containing URIs- Returns:
trueif the specified data match,falseif not
-
isMatching
Checks whether thesearchUriTextandimportUrimatch.- Parameters:
searchUriText- the textual URI of the model stating the importimportUriText- the URI path of the model being considered for importcontained- prefer contained or containing URIs- Returns:
trueif the specified data match,falseif not
-
pathWithoutLastFragment
Returns the prefix path of the givenuriwithout the last fragment.- Parameters:
uri- the URI to be considered- Returns:
- the prefix path if possible, the
urielse
-
toList
Adds all model information objects to the givenlist.- Parameters:
list- the list to be modified as a side effect (may be null then a list is created)- Returns:
listor the created list
-
toString
Returns the textual representation of this instance. -
find
Finds a model information object based on a give URI.- Parameters:
uri- the URI to find the information object- Returns:
- the information object or null if not found
-
find
public static <M extends IModel> VersionedModelInfos<M> find(List<VersionedModelInfos<M>> infos, Version version) Retrieves the version model information container with the specified version.- Type Parameters:
M- the specific type of model- Parameters:
infos- a list of model information containers (may be null)version- the version to retrieve- Returns:
- the first matching container
-
maxVersion
Returns the model information object with highest version number fromlist. Unspecified versions are treated as implicit minimum.- Type Parameters:
M- the actual model type- Parameters:
list- the list of model information objects to determine the maximum from (may be null)- Returns:
- the maximum version
-