/** * @throws IllegalArgumentException if {@code type.isArray()} is {@code false} */ public MultiGenericPropertyState(String name, Iterable<String> values, Type<?> type) { super(name, values); checkArgument(type.isArray()); this.type = type; }
/** * Create a new instance for building {@code PropertyState} instances * of the given {@code type}. * @param type type of the {@code PropertyState} instances to be built. * @throws IllegalArgumentException if {@code type.isArray()} is {@code true}. */ public PropertyBuilder(Type<T> type) { checkArgument(!type.isArray(), "type must not be array"); this.type = type; }
/** * @return An empty list if {@code type.isArray()} is {@code true}. * @throws IllegalArgumentException {@code type.isArray()} is {@code false}. */ @SuppressWarnings("unchecked") @Nonnull @Override public <T> T getValue(Type<T> type) { checkArgument(type.isArray(), "Type must be an array type"); return (T) Collections.emptyList(); }
/** * @throws IllegalArgumentException if {@code type.isArray()} is {@code true} */ public GenericPropertyState( @NotNull String name, @NotNull String value, @NotNull Type<?> type) { super(name); this.value = checkNotNull(value); this.type = checkNotNull(type); checkArgument(!type.isArray()); }
/** * @throws IllegalArgumentException if {@code type.isArray()} is {@code true} */ public GenericPropertyState( @Nonnull String name, @Nonnull String value, @Nonnull Type<?> type) { super(name); this.value = checkNotNull(value); this.type = checkNotNull(type); checkArgument(!type.isArray()); }
/** * Determine the array type which has this type as base type * @return array type with this type as base type * @throws IllegalStateException if {@code isArray} is true. */ public Type<?> getArrayType() { checkState(!isArray(), "Not a simply type"); return fromTag(tag, true); }
/** * Determine the base type of array types * @return base type * @throws IllegalStateException if {@code isArray} is false. */ public Type<?> getBaseType() { checkState(isArray(), "Not an array"); return fromTag(tag, false); }
/** * Determine the base type of array types * @return base type * @throws IllegalStateException if {@code isArray} is false. */ public Type<?> getBaseType() { checkState(isArray(), "Not an array"); return fromTag(tag, false); }
/** * Determine the base type of array types * @return base type * @throws IllegalStateException if {@code isArray} is false. */ public Type<?> getBaseType() { checkState(isArray(), "Not an array"); return fromTag(tag, false); }
/** * Determine the array type which has this type as base type * @return array type with this type as base type * @throws IllegalStateException if {@code isArray} is true. */ public Type<?> getArrayType() { checkState(!isArray(), "Not a simply type"); return fromTag(tag, true); }
@Override @NotNull public <T> T getValue(Type<T> type, int index) { checkNotNull(type); checkArgument(!type.isArray(), "Type must not be an array type"); Segment segment = getSegment(); ListRecord values = getValueList(segment); checkElementIndex(index, values.size()); return getValue(values.getEntry(index), type); }
@NotNull @Override public PropertyDefinition getDefinition( Tree parent, PropertyState property, boolean exactTypeMatch) throws RepositoryException { Type<?> type = property.getType(); EffectiveNodeType effective = getEffectiveNodeType(parent); return effective.getPropertyDefinition( property.getName(), type.isArray(), type.tag(), exactTypeMatch); }
@NotNull @Override public PropertyDefinition getDefinition( Tree parent, PropertyState property, boolean exactTypeMatch) throws RepositoryException { Type<?> type = property.getType(); EffectiveNodeType effective = getEffectiveNodeType(parent); return effective.getPropertyDefinition( property.getName(), type.isArray(), type.tag(), exactTypeMatch); }
@Override public boolean isMultiValueRestriction(String restrictionName) throws RepositoryException { for (RestrictionDefinition definition : getRestrictionProvider().getSupportedRestrictions(getOakPath())) { String jcrName = namePathMapper.getJcrName(definition.getName()); if (jcrName.equals(restrictionName)) { return definition.getRequiredType().isArray(); } } // not a supported restriction => return false. return false; }
@Override public boolean isMultiValueRestriction(String restrictionName) { for (RestrictionDefinition definition : getRestrictionProvider().getSupportedRestrictions(getOakPath())) { String jcrName = namePathMapper.getJcrName(definition.getName()); if (jcrName.equals(restrictionName)) { return definition.getRequiredType().isArray(); } } // not a supported restriction => return false. return false; }
@Override public void performVoid() throws RepositoryException { Type<?> type = dlg.getPropertyState().getType(); if (type.isArray()) { throw new ValueFormatException( "This is a multi-valued property"); } Value converted = ValueHelper.convert( value, type.tag(), getValueFactory()); dlg.setState(createSingleState(dlg.getName(), converted, type)); }
@Override public void performVoid() throws RepositoryException { Type<?> type = dlg.getPropertyState().getType(); if (type.isArray()) { throw new ValueFormatException( "This is a multi-valued property"); } Value converted = ValueHelper.convert( value, type.tag(), getValueFactory()); dlg.setState(createSingleState(dlg.getName(), converted, type)); }
private void assertTypeLessThan(Type<?> a, Type<?> b) { assertTrue(a.compareTo(b) < 0); assertTrue(b.compareTo(a) > 0); if (a.tag() > b.tag()) { fail("Types should be ordered by increasing tag value"); } if (b.tag() == a.tag() && a.isArray() && !b.isArray()) { fail("If their tag is the same, types should be ordered by multiplicity"); } }
@Test public void testIsMultiValueRestriction() { AbstractAccessControlList acl = createEmptyACL(); for (RestrictionDefinition def : getRestrictionProvider().getSupportedRestrictions(getTestPath())) { boolean isMv = acl.isMultiValueRestriction(getNamePathMapper().getJcrName(def.getName())); assertEquals(def.getRequiredType().isArray(), isMv); } }