Skip to content

Commit

Permalink
Preliminarily fixing MID-3922.
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed May 19, 2017
1 parent d889af1 commit f88e714
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
Expand Up @@ -289,7 +289,7 @@ public boolean hasRealValue(PrismValue value) {
}

public boolean isSingleValue() {
// We are not sure about multiplicity if there is no definition or the definition is dynamic
// TODO what about dynamic definitions? See MID-3922
if (getDefinition() != null) {
if (getDefinition().isMultiValue()) {
return false;
Expand Down
Expand Up @@ -143,6 +143,7 @@ public PrismContainerValue<C> getValue() {
throw new IllegalStateException("Attempt to get single value from a multivalued container "+ getElementName());
}
// We are not sure about multiplicity if there is no definition or the definition is dynamic
// TODO why testing for isDynamic? consider Item.isSingleValue (we already removed this condition from there); see MID-3922
if (getDefinition() != null && !getDefinition().isDynamic()) {
if (getDefinition().isSingleValue()) {
// Insert first empty value. This simulates empty single-valued container. It the container exists
Expand Down
Expand Up @@ -106,7 +106,12 @@ public void setDefinition(PrismPropertyDefinition<T> definition) {
}

public PrismPropertyValue<T> getValue() {
if (!isSingleValue()) {
// I know of no reason why we should not return a value if it's only one (even for multivalued items) (see MID-3922)
// TODO reconsider this
if (getValues().size() == 1) {
return getValues().get(0);
}
if (!isSingleValue()) {
throw new IllegalStateException("Attempt to get single value from property " + getElementName()
+ " with multiple values");
}
Expand Down
Expand Up @@ -56,11 +56,12 @@ public PrismReference(QName name) {
/**
* {@inheritDoc}
*/
public PrismReferenceDefinition getDefinition() {
return (PrismReferenceDefinition) super.getDefinition();
}

public PrismReferenceValue getValue() {
// I know of no reason why we should not return a value if it's only one (even for multivalued items) (see MID-3922)
// TODO reconsider this
if (getValues().size() == 1) {
return getValues().get(0);
}
// We are not sure about multiplicity if there is no definition or the definition is dynamic
if (getDefinition() != null && !getDefinition().isDynamic()) {
if (getDefinition().isMultiValue()) {
Expand Down

0 comments on commit f88e714

Please sign in to comment.