public class MetamodelVersionDescriptor extends java.lang.Object implements java.lang.Iterable<VersionedItem<?>>
Encapsulates a list of VersionedItem
with convenience methods
and persistence methods.
Modifier and Type | Class and Description |
---|---|
static class |
MetamodelVersionDescriptor.Difference
We really miss C++ std::pair ...
|
static class |
MetamodelVersionDescriptor.DiffType
Compatibility diagnostic
|
Modifier | Constructor and Description |
---|---|
|
MetamodelVersionDescriptor()
Initialize an empty descriptor.
|
protected |
MetamodelVersionDescriptor(java.util.Map<java.lang.String,VersionedItem<?>> aContent)
Internal constructor.
|
|
MetamodelVersionDescriptor(MetamodelVersionDescriptor other)
copy constructor.
|
|
MetamodelVersionDescriptor(java.io.Reader is)
Read a collection of version descriptors written by write()
|
|
MetamodelVersionDescriptor(VersionedItem<?> v)
Builds a set from a version.
|
Modifier and Type | Method and Description |
---|---|
MetamodelVersionDescriptor |
addDescriptor(VersionedItem<?> d)
Add a descriptor.
|
boolean |
contains(java.lang.String mmname,
Version min,
Version max) |
MetamodelVersionDescriptor |
copy() |
boolean |
equals(java.lang.Object obj) |
MetamodelVersionDescriptor |
filter(java.util.function.Predicate<VersionedItem<?>> test)
Keep only elements that satisfy the given test.
|
java.util.Collection<MetamodelVersionDescriptor.Difference> |
getDifferencesWith(MetamodelVersionDescriptor other,
java.util.Collection<MetamodelVersionDescriptor.DiffType> filter)
Compare this metamodel versions with another one and get a differences report.
|
java.util.Collection<MetamodelVersionDescriptor.Difference> |
getIncompatibilities(MetamodelVersionDescriptor other,
boolean allowBuildCompatible)
Get a diagnostic about incompatibilities of the other metamodel relative to this one.
|
protected MetamodelVersionDescriptor.DiffType |
getRequiredVersionCompatibility(VersionedItem<?> fragVersionRequirement)
Compares the given fragment version descriptor with this metamodel and
gives the compatibility state of the requirement.
|
Version |
getVersion(java.lang.String mmname)
Get the version for the given metamodel.
|
boolean |
hasAtLeast(java.lang.String name,
Version minVersion)
To make compatibility tests.
|
int |
hashCode() |
boolean |
isCompatibleWith(MetamodelVersionDescriptor requirements,
boolean allowBuildCompatible)
Tells whether the metamodel is "build compatible" with the other metamodel.
|
boolean |
isEmpty()
Test whether the descriptor does not contain anything.
|
boolean |
isSame(MetamodelVersionDescriptor other)
Tells whether this set is the same as the given one.
|
java.util.Iterator<VersionedItem<?>> |
iterator() |
MetamodelVersionDescriptor |
put(java.lang.String mmName,
Version v) |
java.lang.String |
toString() |
MetamodelVersionDescriptor |
unmodifiable() |
void |
write(java.io.Writer out)
Write the versions to a java
Writer . |
public MetamodelVersionDescriptor()
public MetamodelVersionDescriptor(VersionedItem<?> v)
v
- a version.public MetamodelVersionDescriptor(java.io.Reader is) throws java.io.IOException
is
- the input readerjava.io.IOException
- in case of I/O error.public MetamodelVersionDescriptor(MetamodelVersionDescriptor other)
other
- the descriptor to copy.protected MetamodelVersionDescriptor(java.util.Map<java.lang.String,VersionedItem<?>> aContent)
aContent
- the map to directly use.public MetamodelVersionDescriptor addDescriptor(VersionedItem<?> d)
d
- a descriptor.put(String, Version)
public boolean contains(java.lang.String mmname, Version min, Version max)
mmname
- a metamodel namemin
- minimum version, includedmax
- maximum version , excludedpublic MetamodelVersionDescriptor copy()
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public MetamodelVersionDescriptor filter(java.util.function.Predicate<VersionedItem<?>> test)
test
- a test matching elements to keeppublic java.util.Collection<MetamodelVersionDescriptor.Difference> getIncompatibilities(MetamodelVersionDescriptor other, boolean allowBuildCompatible)
Incompatibilities include fragments in the other metamodel but missing in this one and version differences. Fragments in this metamodel but not in the other are ignored.
If 'allowBuildCompatible' is true, ignore if own version is newer by build number
other
- the other metamodelallowBuildCompatible
- ignore if own version is newer by build numberpublic Version getVersion(java.lang.String mmname)
mmname
- a metamodel namepublic boolean hasAtLeast(java.lang.String name, Version minVersion)
name
- the metamodel to look forminVersion
- the required minimum versionpublic int hashCode()
hashCode
in class java.lang.Object
public boolean isCompatibleWith(MetamodelVersionDescriptor requirements, boolean allowBuildCompatible)
This metamodel is "build" compatible if the only differences are that the build numbers are more recent in this current metamodel, or this metamodel has more fragments than the other.
requirements
- the metamodel requirementsallowBuildCompatible
- whether to allow build compatiblepublic boolean isEmpty()
public boolean isSame(MetamodelVersionDescriptor other)
other
- another version set.public java.util.Iterator<VersionedItem<?>> iterator()
iterator
in interface java.lang.Iterable<VersionedItem<?>>
public MetamodelVersionDescriptor put(java.lang.String mmName, Version v)
mmName
- the metamodel fragment namev
- the versionpublic java.lang.String toString()
toString
in class java.lang.Object
public MetamodelVersionDescriptor unmodifiable()
public void write(java.io.Writer out) throws java.io.IOException
Writer
.out
- the target writerjava.io.IOException
- in case of I/O errorprotected MetamodelVersionDescriptor.DiffType getRequiredVersionCompatibility(VersionedItem<?> fragVersionRequirement)
fragVersionRequirement
- a metamodel fragment version descriptor.public java.util.Collection<MetamodelVersionDescriptor.Difference> getDifferencesWith(MetamodelVersionDescriptor other, java.util.Collection<MetamodelVersionDescriptor.DiffType> filter)
Incompatibilities include fragments in the other metamodel but missing in this one and version differences. Fragments in this metamodel but not in the other are ignored.
The differences
other
- the other metamodelfilter
- the wanted differences type